00001
00002
00003
00004
00005
00006
00007
00008 #include "DcpsInfo_pch.h"
00009 #include "DCPS_IR_Domain.h"
00010
00011 #include "DCPS_IR_Participant.h"
00012 #include "DCPS_IR_Topic_Description.h"
00013 #include "DomainParticipantListener_i.h"
00014
00015 #include "dds/DCPS/Service_Participant.h"
00016 #include "dds/DCPS/BuiltInTopicUtils.h"
00017 #include "dds/DCPS/Marked_Default_Qos.h"
00018 #include "dds/DCPS/PublisherImpl.h"
00019 #include "dds/DCPS/GuidUtils.h"
00020 #include "dds/DCPS/InfoRepoDiscovery/InfoC.h"
00021 #include "dds/DCPS/RepoIdConverter.h"
00022
00023 #if !defined (DDS_HAS_MINIMUM_BIT)
00024 #include "dds/DCPS/transport/framework/TransportRegistry.h"
00025 #include "dds/DCPS/BuiltInTopicUtils.h"
00026 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00027
00028 #include "dds/DCPS/Transient_Kludge.h"
00029
00030 #include "tao/debug.h"
00031
00032 #include <algorithm>
00033 #include <sstream>
00034
00035
00036 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00037
00038 DCPS_IR_Domain::DCPS_IR_Domain(DDS::DomainId_t id, OpenDDS::DCPS::RepoIdGenerator& generator)
00039 : id_(id),
00040 participantIdGenerator_(generator),
00041 useBIT_(false)
00042 {
00043 }
00044
00045 DCPS_IR_Domain::~DCPS_IR_Domain()
00046 {
00047 }
00048
00049 const DCPS_IR_Participant_Map&
00050 DCPS_IR_Domain::participants() const
00051 {
00052 return this->participants_;
00053 }
00054
00055 DCPS_IR_Participant*
00056 DCPS_IR_Domain::participant(const OpenDDS::DCPS::RepoId& id) const
00057 {
00058 DCPS_IR_Participant_Map::const_iterator where
00059 = this->participants_.find(id);
00060
00061 if (where != this->participants_.end()) {
00062 return where->second.in();
00063
00064 } else {
00065 return 0;
00066 }
00067 }
00068
00069 int DCPS_IR_Domain::add_participant(DCPS_IR_Participant_rch participant)
00070 {
00071 OpenDDS::DCPS::RepoId participantId = participant->get_id();
00072 OpenDDS::DCPS::RepoIdConverter converter(participantId);
00073
00074 DCPS_IR_Participant_Map::iterator where
00075 = this->participants_.find(participantId);
00076
00077 if (where == this->participants_.end()) {
00078 this->participants_.insert(
00079 DCPS_IR_Participant_Map::value_type(participantId, participant));
00080
00081
00082 publish_participant_bit(participant.in());
00083
00084 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00085 ACE_DEBUG((LM_DEBUG,
00086 ACE_TEXT("(%P|%t) DCPS_IR_Domain::add_participant: ")
00087 ACE_TEXT("added participant %C in domain %d ")
00088 ACE_TEXT("at 0x%x.\n"),
00089 std::string(converter).c_str(),
00090 id_,
00091 participant.in()));
00092 }
00093
00094 } else {
00095 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00096 ACE_DEBUG((LM_NOTICE,
00097 ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Domain::add_participant: ")
00098 ACE_TEXT("attempt to add already existing participant %C in domain %d.\n"),
00099 std::string(converter).c_str(),
00100 id_));
00101 }
00102
00103 return 1;
00104 }
00105
00106 return 0;
00107 }
00108
00109 int DCPS_IR_Domain::remove_participant(const OpenDDS::DCPS::RepoId& participantId,
00110 CORBA::Boolean notify_lost)
00111 {
00112 DCPS_IR_Participant_Map::iterator where
00113 = this->participants_.find(participantId);
00114
00115 if (where != this->participants_.end()) {
00116
00117 DCPS_IR_Participant_rch participant = where->second;
00118
00119
00120
00121 participant->remove_all_dependents(notify_lost);
00122
00123
00124 this->participants_.erase(where);
00125
00126 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00127 OpenDDS::DCPS::RepoIdConverter converter(participantId);
00128 ACE_DEBUG((LM_DEBUG,
00129 ACE_TEXT("(%P|%t) DCPS_IR_Domain::remove_participant: ")
00130 ACE_TEXT("removed participant %C at 0x%x from domain %d.\n"),
00131 std::string(converter).c_str(),
00132 participant.in(),
00133 id_));
00134 }
00135
00136 dispose_participant_bit(participant.get());
00137 return 0;
00138
00139 } else {
00140 OpenDDS::DCPS::RepoIdConverter converter(participantId);
00141 ACE_ERROR((LM_ERROR,
00142 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::remove_participant: ")
00143 ACE_TEXT("unable to find participant %C in domain %d.\n"),
00144 std::string(converter).c_str(),
00145 id_));
00146 return 1;
00147 }
00148 }
00149
00150 OpenDDS::DCPS::TopicStatus DCPS_IR_Domain::add_topic(OpenDDS::DCPS::RepoId_out topicId,
00151 const char * topicName,
00152 const char * dataTypeName,
00153 const DDS::TopicQos & qos,
00154 DCPS_IR_Participant* participantPtr)
00155 {
00156 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00157
00158 bool isBIT = OpenDDS::DCPS::topicIsBIT(topicName, dataTypeName);
00159 OpenDDS::DCPS::RepoId new_topic_id = participantPtr->get_next_topic_id(isBIT);
00160 OpenDDS::DCPS::TopicStatus status = add_topic_i(new_topic_id, topicName
00161 , dataTypeName
00162 , qos, participantPtr, isBIT);
00163
00164 if (status == OpenDDS::DCPS::CREATED) {
00165 topicId = new_topic_id;
00166 }
00167
00168 return status;
00169 }
00170
00171 OpenDDS::DCPS::TopicStatus
00172 DCPS_IR_Domain::force_add_topic(const OpenDDS::DCPS::RepoId& topicId,
00173 const char* topicName,
00174 const char* dataTypeName,
00175 const DDS::TopicQos & qos,
00176 DCPS_IR_Participant* participantPtr)
00177 {
00178 OpenDDS::DCPS::RepoId topic_id = topicId;
00179 bool isBIT = OpenDDS::DCPS::topicIsBIT(topicName, dataTypeName);
00180 OpenDDS::DCPS::TopicStatus status = add_topic_i(topic_id, topicName
00181 , dataTypeName
00182 , qos, participantPtr, isBIT);
00183
00184 return status;
00185 }
00186
00187 OpenDDS::DCPS::TopicStatus DCPS_IR_Domain::add_topic_i(OpenDDS::DCPS::RepoId& topicId,
00188 const char * topicName,
00189 const char * dataTypeName,
00190 const DDS::TopicQos & qos,
00191 DCPS_IR_Participant* participantPtr,
00192 bool isBIT)
00193 {
00194 DCPS_IR_Topic_Description* description;
00195 int descriptionLookup = find_topic_description(topicName, dataTypeName, description);
00196
00197 if (1 == descriptionLookup) {
00198 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00199 return OpenDDS::DCPS::CONFLICTING_TYPENAME;
00200
00201 } else if (-1 == descriptionLookup) {
00202 using namespace OpenDDS::DCPS;
00203 unique_ptr<DCPS_IR_Topic_Description> desc( new
00204 DCPS_IR_Topic_Description(
00205 this,
00206 topicName,
00207 dataTypeName));
00208 description = desc.get();
00209 int descriptionAddition = add_topic_description(move(desc));
00210
00211 if (0 != descriptionAddition) {
00212 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00213
00214 if (2 == descriptionAddition) {
00215 return OpenDDS::DCPS::CONFLICTING_TYPENAME;
00216
00217 } else {
00218 return OpenDDS::DCPS::NOT_FOUND;
00219 }
00220 }
00221 }
00222
00223 OpenDDS::DCPS::unique_ptr<DCPS_IR_Topic> topic( new
00224 DCPS_IR_Topic(
00225 topicId,
00226 qos,
00227 this,
00228 participantPtr,
00229 description,
00230 isBIT));
00231
00232 OpenDDS::DCPS::TopicStatus topicStatus = OpenDDS::DCPS::NOT_FOUND;
00233
00234 switch (description->add_topic(topic.get())) {
00235 case 0: {
00236 switch (participantPtr->add_topic_reference(topic.get())) {
00237 case 0: {
00238 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00239 OpenDDS::DCPS::RepoIdConverter converter(topicId);
00240 ACE_DEBUG((LM_DEBUG,
00241 ACE_TEXT("(%P|%t) DCPS_IR_Domain::add_topic_i: ")
00242 ACE_TEXT("Domain %d successfully added topic %C ")
00243 ACE_TEXT("at 0x%x.\n"),
00244 this->id_,
00245 std::string(converter).c_str(),
00246 topic.get()));
00247 }
00248
00249 topicStatus = OpenDDS::DCPS::CREATED;
00250
00251
00252 publish_topic_bit(topic.get());
00253
00254
00255 this->idToTopicMap_[topicId] = move(topic);
00256
00257 }
00258 break;
00259
00260 case 1:
00261
00262 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00263 OpenDDS::DCPS::RepoIdConverter converter(topicId);
00264 ACE_DEBUG((LM_NOTICE,
00265 ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Domain::add_topic_i: ")
00266 ACE_TEXT("Domain %d declined to add duplicate topic %C at 0x%x.\n"),
00267 this->id_,
00268 std::string(converter).c_str(),
00269 topic.get()));
00270 }
00271
00272 topicStatus = OpenDDS::DCPS::NOT_FOUND;
00273 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00274 description->remove_topic(topic.get());
00275 break;
00276
00277 case -1: {
00278 OpenDDS::DCPS::RepoIdConverter converter(topicId);
00279 ACE_ERROR((LM_ERROR,
00280 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::add_topic_i: ")
00281 ACE_TEXT("Domain %d failed to add topic %C at 0x%x.\n"),
00282 this->id_,
00283 std::string(converter).c_str(),
00284 topic.get()));
00285 topicStatus = OpenDDS::DCPS::NOT_FOUND;
00286 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00287 description->remove_topic(topic.get());
00288 }
00289 break;
00290 }
00291 }
00292 break;
00293
00294 case 1:
00295
00296 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00297 OpenDDS::DCPS::RepoIdConverter converter(topicId);
00298 ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%P|%t) WARNING: DCPS_IR_Domain::add_topic ")
00299 ACE_TEXT("Unable to add topic 0x%x id %C to Topic Description\n"),
00300 topic.get(),
00301 std::string(converter).c_str()));
00302 }
00303
00304 topicStatus = OpenDDS::DCPS::NOT_FOUND;
00305 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00306 break;
00307
00308 case -1: {
00309 OpenDDS::DCPS::RepoIdConverter converter(topicId);
00310 ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::add_topic ")
00311 ACE_TEXT("Unable to add topic 0x%x id %C to Topic Description\n"),
00312 topic.get(),
00313 std::string(converter).c_str()));
00314 topicStatus = OpenDDS::DCPS::NOT_FOUND;
00315 topicId = OpenDDS::DCPS::GUID_UNKNOWN;
00316 }
00317 break;
00318 }
00319
00320 return topicStatus;
00321 }
00322
00323 OpenDDS::DCPS::TopicStatus
00324 DCPS_IR_Domain::find_topic(const char* topicName, DCPS_IR_Topic*& topic)
00325 {
00326 DCPS_IR_Topic_Description_Set::iterator which
00327 = this->topicDescriptions_.find(topicName);
00328
00329 if (which != this->topicDescriptions_.end()) {
00330
00331 topic = which->second->get_first_topic();
00332
00333 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00334 OpenDDS::DCPS::RepoId topicId = topic->get_id();
00335 OpenDDS::DCPS::RepoIdConverter converter(topicId);
00336 ACE_DEBUG((LM_DEBUG,
00337 ACE_TEXT("(%P|%t) DCPS_IR_Domain::find_topic: ")
00338 ACE_TEXT("located topic %C in domain %d.\n"),
00339 std::string(converter).c_str(),
00340 id_));
00341 }
00342
00343 return OpenDDS::DCPS::FOUND;
00344
00345 } else {
00346
00347 return OpenDDS::DCPS::NOT_FOUND;
00348 }
00349 }
00350
00351 DCPS_IR_Topic*
00352 DCPS_IR_Domain::find_topic(const OpenDDS::DCPS::RepoId& id)
00353 {
00354 IdToTopicMap::const_iterator location = this->idToTopicMap_.find(id);
00355
00356 if (location == this->idToTopicMap_.end()) {
00357 return 0;
00358 }
00359
00360 return location->second.get();
00361 }
00362
00363 OpenDDS::DCPS::TopicStatus DCPS_IR_Domain::remove_topic(DCPS_IR_Participant* part,
00364 DCPS_IR_Topic*& topic)
00365 {
00366 DCPS_IR_Topic_Description* description = topic->get_topic_description();
00367
00368 if (description->remove_topic(topic) != 0) {
00369
00370
00371
00372 throw OpenDDS::DCPS::Invalid_Topic();
00373 }
00374
00375 if (description->get_number_topics() == 0) {
00376
00377 if (remove_topic_description(description) != 0) {
00378
00379
00380 ACE_ERROR((LM_ERROR,
00381 ACE_TEXT("(%P|%t) ERROR: Topic Description %C %C ")
00382 ACE_TEXT("was not correctly removed from Domain %d"),
00383 description->get_name(),
00384 description->get_dataTypeName(),
00385 id_));
00386
00387 }
00388 }
00389
00390
00391
00392 if (part->remove_topic_reference(topic->get_id(), topic) != 0) {
00393 OpenDDS::DCPS::RepoIdConverter part_converter(part->get_id());
00394 OpenDDS::DCPS::RepoIdConverter topic_converter(topic->get_id());
00395 ACE_ERROR((LM_ERROR,
00396 ACE_TEXT("(%P|%t) ERROR: Domain %d Topic %C ")
00397 ACE_TEXT("was not correctly removed from Participant %C"),
00398 id_,
00399 std::string(topic_converter).c_str(),
00400 std::string(part_converter).c_str()));
00401 }
00402
00403
00404 dispose_topic_bit(topic);
00405
00406 topic->release(true);
00407 topic = 0;
00408 return OpenDDS::DCPS::REMOVED;
00409 }
00410
00411 int
00412 DCPS_IR_Domain::find_topic_description(
00413 const char* name,
00414 const char* dataTypeName,
00415 DCPS_IR_Topic_Description*& desc)
00416 {
00417 DCPS_IR_Topic_Description_Set::iterator which
00418 = this->topicDescriptions_.find(name);
00419
00420 if (which != this->topicDescriptions_.end()) {
00421 if (0 == ACE_OS::strcmp(dataTypeName, which->second->get_dataTypeName())) {
00422 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00423 ACE_DEBUG((LM_DEBUG,
00424 ACE_TEXT("(%P|%t) DCPS_IR_Domain::find_topic_description: ")
00425 ACE_TEXT("located topic description %C/%C in domain %d.\n"),
00426 name,
00427 dataTypeName,
00428 id_));
00429 }
00430
00431 desc = which->second.get();
00432 return 0;
00433
00434 } else {
00435 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00436 ACE_DEBUG((LM_NOTICE,
00437 ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Domain::find_topic_description: ")
00438 ACE_TEXT("searching for topic description %C/%C, ")
00439 ACE_TEXT("located topic description %C/%C instead in domain %d.\n"),
00440 name,
00441 dataTypeName,
00442 which->second->get_name(),
00443 which->second->get_dataTypeName(),
00444 id_));
00445 }
00446
00447
00448 return 1;
00449 }
00450
00451 } else {
00452
00453 return -1;
00454 }
00455 }
00456
00457 #if defined (DDS_HAS_MINIMUM_BIT)
00458 int DCPS_IR_Domain::init_built_in_topics(bool , bool )
00459 {
00460 return 1;
00461 }
00462 #else
00463 int DCPS_IR_Domain::init_built_in_topics(bool federated, bool persistent)
00464 {
00465
00466 TheTransientKludge->enable();
00467
00468 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00469 ACE_DEBUG((LM_DEBUG,
00470 ACE_TEXT("(%P|%t) DCPS_IR_Domain::init_built_in_topics() ")
00471 ACE_TEXT(" Initializing Built In Topics for domain %d\n"),
00472 id_));
00473 }
00474
00475 try {
00476 bitParticipantFactory_ = TheParticipantFactory;
00477
00478 bitParticipantListener_ = new OPENDDS_DCPS_DomainParticipantListener_i;
00479
00480 bitParticipant_ =
00481 bitParticipantFactory_->create_participant(id_,
00482 PARTICIPANT_QOS_DEFAULT,
00483 bitParticipantListener_.in(),
00484 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00485
00486 if (CORBA::is_nil(bitParticipant_.in())) {
00487 ACE_ERROR_RETURN((LM_ERROR,
00488 ACE_TEXT("(%P|%t) ERROR: ")
00489 ACE_TEXT("Nil DomainParticipant in ")
00490 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n")),
00491 1);
00492 }
00493
00494
00495 int transportResult = init_built_in_topics_transport(persistent);
00496
00497 if (0 != transportResult) {
00498 return transportResult;
00499 }
00500
00501 int topicsResult = init_built_in_topics_topics();
00502
00503 if (0 != topicsResult) {
00504 return topicsResult;
00505 }
00506
00507 int datawritersResult = init_built_in_topics_datawriters(federated);
00508
00509 if (0 != datawritersResult) {
00510 return datawritersResult;
00511 }
00512
00513 } catch (const CORBA::Exception& ex) {
00514 ex._tao_print_exception("ERROR: Exception caught in DCPS_IR_Domain::init_built_in-topics()");
00515 return 1;
00516 }
00517
00518
00519 useBIT_ = true;
00520 return 0;
00521 }
00522 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00523
00524 #if defined (DDS_HAS_MINIMUM_BIT)
00525 int DCPS_IR_Domain::reassociate_built_in_topic_pubs()
00526 {
00527 return 1;
00528 }
00529 #else
00530 int DCPS_IR_Domain::reassociate_built_in_topic_pubs()
00531 {
00532 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00533 ACE_DEBUG((LM_DEBUG,
00534 ACE_TEXT("(%P|%t) DCPS_IR_Domain::reassociate_built_in_topic_pubs() ")
00535 ACE_TEXT(" Re-associating Built In Topics for domain %d\n"),
00536 id_));
00537 }
00538
00539 DCPS_IR_Participant_Map::iterator participantIter = participants_.begin();
00540 DCPS_IR_Participant_Map::iterator end = participants_.end();
00541 while (participantIter != end
00542 && !participantIter->second->isBitPublisher() ) {
00543 participantIter++;
00544 }
00545
00546 if (participantIter != end) {
00547 for (DCPS_IR_Topic_Map::const_iterator topicIter
00548 = participantIter->second->topics().begin();
00549 topicIter != participantIter->second->topics().end();
00550 ++topicIter) {
00551 topicIter->second->reassociate_all_publications();
00552 }
00553 }
00554
00555 return 0;
00556 }
00557 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00558
00559 int DCPS_IR_Domain::init_built_in_topics_topics()
00560 {
00561 #if !defined (DDS_HAS_MINIMUM_BIT)
00562
00563 try {
00564 DDS::TopicQos topic_qos;
00565 bitParticipant_->get_default_topic_qos(topic_qos);
00566
00567
00568 DDS::ParticipantBuiltinTopicDataTypeSupport_var
00569 participantTypeSupport(new DDS::ParticipantBuiltinTopicDataTypeSupportImpl());
00570
00571 if (DDS::RETCODE_OK !=
00572 participantTypeSupport->register_type(bitParticipant_.in(),
00573 OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC_TYPE)) {
00574 ACE_ERROR((LM_ERROR,
00575 ACE_TEXT("(%P|%t) ERROR: Failed to register the ParticipantBuiltinTopicDataTypeSupport.")));
00576 return 1;
00577 }
00578
00579 bitParticipantTopic_ =
00580 bitParticipant_->create_topic(OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC,
00581 OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC_TYPE,
00582 topic_qos,
00583 DDS::TopicListener::_nil(),
00584 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00585
00586 if (CORBA::is_nil(bitParticipantTopic_.in())) {
00587 ACE_ERROR_RETURN((LM_ERROR,
00588 ACE_TEXT("(%P|%t) ERROR: ")
00589 ACE_TEXT("Nil %C Topic from ")
00590 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n"),
00591 OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC),
00592 1);
00593 }
00594
00595
00596 DDS::TopicBuiltinTopicDataTypeSupport_var
00597 topicTypeSupport(new DDS::TopicBuiltinTopicDataTypeSupportImpl());
00598
00599 if (DDS::RETCODE_OK !=
00600 topicTypeSupport->register_type(bitParticipant_.in(),
00601 OpenDDS::DCPS::BUILT_IN_TOPIC_TOPIC_TYPE)) {
00602 ACE_ERROR((LM_ERROR,
00603 ACE_TEXT("(%P|%t) ERROR: Failed to register the TopicBuiltinTopicDataTypeSupport.")));
00604 return 1;
00605 }
00606
00607 bitTopicTopic_ =
00608 bitParticipant_->create_topic(OpenDDS::DCPS::BUILT_IN_TOPIC_TOPIC,
00609 OpenDDS::DCPS::BUILT_IN_TOPIC_TOPIC_TYPE,
00610 topic_qos,
00611 DDS::TopicListener::_nil(),
00612 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00613
00614 if (CORBA::is_nil(bitTopicTopic_.in())) {
00615 ACE_ERROR_RETURN((LM_ERROR,
00616 ACE_TEXT("(%P|%t) ERROR: ")
00617 ACE_TEXT("Nil %C Topic from ")
00618 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n"),
00619 OpenDDS::DCPS::BUILT_IN_TOPIC_TOPIC),
00620 1);
00621 }
00622
00623
00624 DDS::SubscriptionBuiltinTopicDataTypeSupport_var
00625 subscriptionTypeSupport(new DDS::SubscriptionBuiltinTopicDataTypeSupportImpl());
00626
00627 if (DDS::RETCODE_OK !=
00628 subscriptionTypeSupport->register_type(bitParticipant_.in(),
00629 OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC_TYPE)) {
00630 ACE_ERROR((LM_ERROR,
00631 ACE_TEXT("(%P|%t) ERROR: Failed to register the SubscriptionBuiltinTopicDataTypeSupport.")));
00632 return 1;
00633 }
00634
00635 bitSubscriptionTopic_ =
00636 bitParticipant_->create_topic(OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC,
00637 OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC_TYPE,
00638 topic_qos,
00639 DDS::TopicListener::_nil(),
00640 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00641
00642 if (CORBA::is_nil(bitSubscriptionTopic_.in())) {
00643 ACE_ERROR_RETURN((LM_ERROR,
00644 ACE_TEXT("(%P|%t) ERROR: ")
00645 ACE_TEXT("Nil %C Topic from ")
00646 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n"),
00647 OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC),
00648 1);
00649 }
00650
00651
00652 DDS::PublicationBuiltinTopicDataTypeSupport_var
00653 publicationTypeSupport(new DDS::PublicationBuiltinTopicDataTypeSupportImpl());
00654
00655 if (DDS::RETCODE_OK !=
00656 publicationTypeSupport->register_type(bitParticipant_.in(),
00657 OpenDDS::DCPS::BUILT_IN_PUBLICATION_TOPIC_TYPE)) {
00658 ACE_ERROR((LM_ERROR,
00659 ACE_TEXT("(%P|%t) ERROR: Failed to register the PublicationBuiltinTopicDataTypeSupport.")));
00660 return 1;
00661 }
00662
00663 bitPublicationTopic_ =
00664 bitParticipant_->create_topic(OpenDDS::DCPS::BUILT_IN_PUBLICATION_TOPIC,
00665 OpenDDS::DCPS::BUILT_IN_PUBLICATION_TOPIC_TYPE,
00666 topic_qos,
00667 DDS::TopicListener::_nil(),
00668 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00669
00670 if (CORBA::is_nil(bitPublicationTopic_.in())) {
00671 ACE_ERROR_RETURN((LM_ERROR,
00672 ACE_TEXT("(%P|%t) ERROR: ")
00673 ACE_TEXT("Nil %C Topic from ")
00674 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n"),
00675 OpenDDS::DCPS::BUILT_IN_PUBLICATION_TOPIC),
00676 1);
00677 }
00678
00679 } catch (const CORBA::Exception& ex) {
00680 ex._tao_print_exception(
00681 "ERROR: Exception caught in DCPS_IR_Domain::init_built_in_topics_topics:");
00682 return 1;
00683 }
00684
00685 return 0;
00686
00687 #else
00688
00689 return 1;
00690 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00691 }
00692
00693 #if defined (DDS_HAS_MINIMUM_BIT)
00694 int DCPS_IR_Domain::init_built_in_topics_datawriters(bool )
00695 {
00696 return 1;
00697 }
00698 #else
00699 int DCPS_IR_Domain::init_built_in_topics_datawriters(bool federated)
00700 {
00701
00702 try {
00703 DDS::DataWriter_var datawriter;
00704
00705 DDS::DataWriterQos participantWriterQos;
00706 bitPublisher_->get_default_datawriter_qos(participantWriterQos);
00707 participantWriterQos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
00708
00709 if (federated) {
00710 participantWriterQos.liveliness.lease_duration.nanosec = 0;
00711 participantWriterQos.liveliness.lease_duration.sec
00712 = TheServiceParticipant->federation_liveliness();
00713 }
00714
00715
00716 datawriter =
00717 bitPublisher_->create_datawriter(bitParticipantTopic_.in(),
00718 participantWriterQos,
00719 DDS::DataWriterListener::_nil(),
00720 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00721
00722 bitParticipantDataWriter_ =
00723 DDS::ParticipantBuiltinTopicDataDataWriter::_narrow(datawriter.in());
00724
00725 if (CORBA::is_nil(bitParticipantDataWriter_.in())) {
00726 ACE_ERROR_RETURN((LM_ERROR,
00727 ACE_TEXT("(%P|%t) ERROR: ")
00728 ACE_TEXT("Nil DomainParticipant DataWriter from ")
00729 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n")),
00730 1);
00731 }
00732
00733 DDS::DataWriterQos dw_qos;
00734 bitPublisher_->get_default_datawriter_qos(dw_qos);
00735 dw_qos.durability.kind = DDS::TRANSIENT_LOCAL_DURABILITY_QOS;
00736
00737
00738 datawriter =
00739 bitPublisher_->create_datawriter(bitTopicTopic_.in(),
00740 dw_qos,
00741 DDS::DataWriterListener::_nil(),
00742 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00743
00744 bitTopicDataWriter_ =
00745 DDS::TopicBuiltinTopicDataDataWriter::_narrow(datawriter.in());
00746
00747 if (CORBA::is_nil(bitTopicDataWriter_.in())) {
00748 ACE_ERROR_RETURN((LM_ERROR,
00749 ACE_TEXT("(%P|%t) ERROR: ")
00750 ACE_TEXT("Nil Topic DataWriter from ")
00751 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n")),
00752 1);
00753 }
00754
00755
00756 datawriter =
00757 bitPublisher_->create_datawriter(bitSubscriptionTopic_.in(),
00758 dw_qos,
00759 DDS::DataWriterListener::_nil(),
00760 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00761
00762 bitSubscriptionDataWriter_ =
00763 DDS::SubscriptionBuiltinTopicDataDataWriter::_narrow(
00764 datawriter.in());
00765
00766 if (CORBA::is_nil(bitSubscriptionDataWriter_.in())) {
00767 ACE_ERROR_RETURN((LM_ERROR,
00768 ACE_TEXT("(%P|%t) ERROR: ")
00769 ACE_TEXT("Nil Subscription DataWriter from ")
00770 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n")),
00771 1);
00772 }
00773
00774
00775 datawriter =
00776 bitPublisher_->create_datawriter(bitPublicationTopic_.in(),
00777 dw_qos,
00778 DDS::DataWriterListener::_nil(),
00779 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00780
00781 bitPublicationDataWriter_ =
00782 DDS::PublicationBuiltinTopicDataDataWriter::_narrow(datawriter.in());
00783
00784 if (CORBA::is_nil(bitPublicationDataWriter_.in())) {
00785 ACE_ERROR_RETURN((LM_ERROR,
00786 ACE_TEXT("(%P|%t) ERROR: ")
00787 ACE_TEXT("Nil Publication DataWriter from ")
00788 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n")),
00789 1);
00790 }
00791
00792 } catch (const CORBA::Exception& ex) {
00793 ex._tao_print_exception(
00794 "ERROR: Exception caught in DCPS_IR_Domain::init_built_in_topics_datawriters:");
00795 return 1;
00796 }
00797 return 0;
00798 }
00799 #endif // defined (DDS_HAS_MINIMUM_BIT)
00800
00801 int DCPS_IR_Domain::init_built_in_topics_transport(bool persistent)
00802 {
00803 #if !defined (DDS_HAS_MINIMUM_BIT)
00804
00805 try {
00806 std::string config_name =
00807 OpenDDS::DCPS::TransportRegistry::DEFAULT_INST_PREFIX
00808 + std::string("InfoRepoBITTransportConfig");
00809 transportConfig_ =
00810 OpenDDS::DCPS::TransportRegistry::instance()->get_config(config_name);
00811
00812
00813 bitPublisher_ =
00814 bitParticipant_->create_publisher(PUBLISHER_QOS_DEFAULT,
00815 DDS::PublisherListener::_nil(),
00816 OpenDDS::DCPS::DEFAULT_STATUS_MASK);
00817
00818 if (CORBA::is_nil(bitPublisher_.in())) {
00819 ACE_ERROR_RETURN((LM_ERROR,
00820 ACE_TEXT("(%P|%t) ERROR: ")
00821 ACE_TEXT("Nil Publisher from ")
00822 ACE_TEXT("DCPS_IR_Domain::init_built_in_topics.\n")),
00823 1);
00824 }
00825
00826
00827 if (persistent) {
00828 DDS::DataWriterQos qos;
00829 bitPublisher_->get_default_datawriter_qos(qos);
00830 qos.writer_data_lifecycle.autodispose_unregistered_instances = false;
00831 bitPublisher_->set_default_datawriter_qos(qos);
00832 }
00833
00834
00835 OpenDDS::DCPS::TransportRegistry::instance()->bind_config(transportConfig_,
00836 bitPublisher_.in());
00837
00838 } catch (const CORBA::Exception& ex) {
00839 ex._tao_print_exception(
00840 "ERROR: Exception caught in DCPS_IR_Domain::init_built_in_topics_transport:");
00841 return 1;
00842 }
00843
00844 return 0;
00845 #else
00846
00847 return 1;
00848 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00849 }
00850
00851 int DCPS_IR_Domain::cleanup_built_in_topics()
00852 {
00853 #if !defined (DDS_HAS_MINIMUM_BIT)
00854
00855 if (useBIT_) {
00856
00857 bitParticipant_->delete_contained_entities();
00858 bitPublisher_ = 0;
00859 bitParticipantDataWriter_ = 0;
00860 bitTopicDataWriter_ = 0;
00861 bitSubscriptionDataWriter_ = 0;
00862 bitPublicationDataWriter_ = 0;
00863 bitParticipantTopic_ = 0;
00864 bitTopicTopic_ = 0;
00865 bitSubscriptionTopic_ = 0;
00866 bitPublicationTopic_ = 0;
00867
00868 bitParticipantFactory_->delete_participant(bitParticipant_);
00869 }
00870
00871 return 0;
00872
00873 #else
00874 return 1;
00875 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00876 }
00877
00878 int DCPS_IR_Domain::add_topic_description(OpenDDS::DCPS::unique_ptr<DCPS_IR_Topic_Description> desc)
00879 {
00880 using OpenDDS::DCPS::move;
00881 DCPS_IR_Topic_Description* discard = 0;
00882 DCPS_IR_Topic_Description* desc_ptr = desc.get();
00883
00884 switch (this->find_topic_description(
00885 desc->get_name(),
00886 desc->get_dataTypeName(),
00887 discard)) {
00888 case -1:
00889 this->topicDescriptions_[desc_ptr->get_name()] = move(desc);
00890
00891 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
00892 ACE_DEBUG((LM_DEBUG,
00893 ACE_TEXT("(%P|%t) DCPS_IR_Domain::add_topic_description: ")
00894 ACE_TEXT("added Topic Description 0x%x in domain %d.\n"),
00895 desc_ptr,
00896 id_));
00897 }
00898
00899 return 0;
00900
00901 case 0:
00902 ACE_DEBUG((LM_NOTICE,
00903 ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Domain::add_topic_description: ")
00904 ACE_TEXT("attempt to add existing Topic Description 0x%x to domain %d.\n"),
00905 desc_ptr,
00906 id_));
00907 return 1;
00908
00909 case 1:
00910 ACE_DEBUG((LM_NOTICE,
00911 ACE_TEXT("(%P|%t) NOTICE: DCPS_IR_Domain::add_topic_description: ")
00912 ACE_TEXT("attempt to add incompatible Topic Description 0x%x to domain %d.\n"),
00913 desc_ptr,
00914 id_));
00915 return 2;
00916
00917 default:
00918 ACE_ERROR((LM_ERROR,
00919 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::add_topic_description: ")
00920 ACE_TEXT("unknown error adding Topic Description 0x%x to domain %d.\n"),
00921 desc_ptr,
00922 id_));
00923 return 2;
00924 }
00925 }
00926
00927 int DCPS_IR_Domain::remove_topic_description(DCPS_IR_Topic_Description* desc)
00928 {
00929 DCPS_IR_Topic_Description_Set::iterator where
00930 = this->topicDescriptions_.find(desc->get_name());
00931
00932 if (where != this->topicDescriptions_.end()) {
00933 this->topicDescriptions_.erase(where);
00934 return 0;
00935
00936 } else {
00937 ACE_ERROR((LM_ERROR,
00938 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::remove_topic_description: ")
00939 ACE_TEXT("unable to remove Topic Description 0x%x from domain %d.\n"),
00940 desc,
00941 id_));
00942 return -1;
00943 }
00944 }
00945
00946 void DCPS_IR_Domain::add_dead_participant(DCPS_IR_Participant_rch participant)
00947 {
00948 deadParticipants_.insert(participant);
00949 }
00950
00951 void DCPS_IR_Domain::remove_dead_participants()
00952 {
00953 if (0 < deadParticipants_.size()) {
00954 DCPS_IR_Participant_rch dead;
00955 DCPS_IR_Participant_Set::iterator iter = deadParticipants_.begin();
00956
00957
00958
00959 while (iter != deadParticipants_.end()) {
00960 dead = *iter;
00961 ++iter;
00962
00963 OpenDDS::DCPS::RepoIdConverter converter(dead->get_id());
00964 ACE_ERROR((LM_ERROR,
00965 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::remove_dead_participants () ")
00966 ACE_TEXT("Removing dead participant 0x%x id %C\n"),
00967 dead.in(),
00968 std::string(converter).c_str()));
00969 deadParticipants_.erase(dead);
00970
00971 dead->set_alive(0);
00972
00973 CORBA::Boolean notify_lost = 1;
00974 remove_participant(dead->get_id(), notify_lost);
00975 }
00976 }
00977 }
00978
00979 DDS::DomainId_t DCPS_IR_Domain::get_id()
00980 {
00981 return id_;
00982 }
00983
00984 OpenDDS::DCPS::RepoId
00985 DCPS_IR_Domain::get_next_participant_id()
00986 {
00987 return this->participantIdGenerator_.next();
00988 }
00989
00990 void
00991 DCPS_IR_Domain::last_participant_key(long key)
00992 {
00993 this->participantIdGenerator_.last(key);
00994 }
00995
00996 #if !defined (DDS_HAS_MINIMUM_BIT)
00997 namespace {
00998 void get_BuiltinTopicKey(DDS::BuiltinTopicKey_t& key,
00999 const OpenDDS::DCPS::RepoId& id)
01000 {
01001 OpenDDS::DCPS::RepoIdConverter c(id);
01002 key.value[0] = c.federationId();
01003 key.value[1] = c.participantId();
01004 key.value[2] = c.entityId();
01005 }
01006 }
01007 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01008
01009 void DCPS_IR_Domain::publish_participant_bit(DCPS_IR_Participant* participant)
01010 {
01011 #if !defined (DDS_HAS_MINIMUM_BIT)
01012
01013 if (useBIT_ && !participant->isBitPublisher()) {
01014 try {
01015 const DDS::DomainParticipantQos* participantQos = participant->get_qos();
01016
01017 DDS::ParticipantBuiltinTopicData data;
01018 get_BuiltinTopicKey(data.key, participant->get_id());
01019 data.user_data = participantQos->user_data;
01020
01021 DDS::InstanceHandle_t handle
01022 = bitParticipantDataWriter_->register_instance(data);
01023
01024 participant->set_handle(handle);
01025
01026 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
01027 ACE_DEBUG((LM_DEBUG,
01028 "(%P|%t) DCPS_IR_Domain::publish_participant_bit: [ %d, 0x%x, 0x%x], handle %d.\n",
01029 data.key.value[0], data.key.value[1], data.key.value[2], handle));
01030 }
01031
01032 bitParticipantDataWriter_->write(data, handle);
01033
01034 } catch (const CORBA::Exception& ex) {
01035 ex._tao_print_exception(
01036 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::publish_participant_bit:");
01037 }
01038 }
01039
01040 #else
01041 ACE_UNUSED_ARG(participant);
01042 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01043 }
01044
01045 void DCPS_IR_Domain::publish_topic_bit(DCPS_IR_Topic* topic)
01046 {
01047 #if !defined (DDS_HAS_MINIMUM_BIT)
01048
01049 if (useBIT_) {
01050 DCPS_IR_Topic_Description* desc =
01051 topic->get_topic_description();
01052 const char* name = desc->get_name();
01053 const char* type = desc->get_dataTypeName();
01054
01055 if (!OpenDDS::DCPS::topicIsBIT(name, type)) {
01056 try {
01057 const DDS::TopicQos* topicQos = topic->get_topic_qos();
01058
01059 DDS::TopicBuiltinTopicData data;
01060 get_BuiltinTopicKey(data.key, topic->get_id());
01061 data.name = name;
01062 data.type_name = type;
01063 data.durability = topicQos->durability;
01064 data.durability_service = topicQos->durability_service;
01065 data.deadline = topicQos->deadline;
01066 data.latency_budget = topicQos->latency_budget;
01067 data.liveliness = topicQos->liveliness;
01068 data.reliability = topicQos->reliability;
01069 data.transport_priority = topicQos->transport_priority;
01070 data.lifespan = topicQos->lifespan;
01071 data.destination_order = topicQos->destination_order;
01072 data.history = topicQos->history;
01073 data.resource_limits = topicQos->resource_limits;
01074 data.ownership = topicQos->ownership;
01075 data.topic_data = topicQos->topic_data;
01076
01077 DDS::InstanceHandle_t handle =
01078 bitTopicDataWriter_->register_instance(data);
01079
01080 topic->set_handle(handle);
01081
01082 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
01083 ACE_DEBUG((LM_DEBUG,
01084 "(%P|%t) DCPS_IR_Domain::publish_topic_bit: [ %d, 0x%x, 0x%x], handle %d.\n",
01085 data.key.value[0], data.key.value[1], data.key.value[2], handle));
01086 }
01087
01088 bitTopicDataWriter_->write(data, handle);
01089
01090 } catch (const CORBA::Exception& ex) {
01091 ex._tao_print_exception(
01092 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::publish_topic_bit:");
01093 }
01094
01095 } else {
01096 topic->set_bit_status(1);
01097 }
01098 }
01099
01100 #else
01101 ACE_UNUSED_ARG(topic);
01102 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01103 }
01104
01105 void DCPS_IR_Domain::publish_subscription_bit(DCPS_IR_Subscription* subscription)
01106 {
01107
01108 #if !defined (DDS_HAS_MINIMUM_BIT)
01109
01110 if (useBIT_) {
01111 DCPS_IR_Topic_Description* desc =
01112 subscription->get_topic_description();
01113 const char* name = desc->get_name();
01114 const char* type = desc->get_dataTypeName();
01115
01116 if (!OpenDDS::DCPS::topicIsBIT(name, type)) {
01117 try {
01118 const DDS::DataReaderQos* readerQos = subscription->get_datareader_qos();
01119 const DDS::SubscriberQos* publisherQos = subscription->get_subscriber_qos();
01120
01121 DCPS_IR_Topic* topic = subscription->get_topic();
01122 const DDS::TopicQos* topicQos = topic->get_topic_qos();
01123
01124 DDS::SubscriptionBuiltinTopicData data;
01125 get_BuiltinTopicKey(data.key, subscription->get_id());
01126 get_BuiltinTopicKey(data.participant_key,
01127 subscription->get_participant_id());
01128 data.topic_name = name;
01129 data.type_name = type;
01130 data.durability = readerQos->durability;
01131 data.deadline = readerQos->deadline;
01132 data.latency_budget = readerQos->latency_budget;
01133 data.liveliness = readerQos->liveliness;
01134 data.reliability = readerQos->reliability;
01135 data.ownership = readerQos->ownership;
01136 data.destination_order = readerQos->destination_order;
01137 data.user_data = readerQos->user_data;
01138 data.time_based_filter = readerQos->time_based_filter;
01139 data.presentation = publisherQos->presentation;
01140 data.partition = publisherQos->partition;
01141 data.topic_data = topicQos->topic_data;
01142 data.group_data = publisherQos->group_data;
01143
01144 DDS::InstanceHandle_t handle
01145 = bitSubscriptionDataWriter_->register_instance(data);
01146
01147 subscription->set_handle(handle);
01148
01149 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
01150 ACE_DEBUG((LM_DEBUG,
01151 "(%P|%t) DCPS_IR_Domain::publish_subscription_bit: [ %d, 0x%x, 0x%x], handle %d.\n",
01152 data.key.value[0], data.key.value[1], data.key.value[2], handle));
01153 }
01154
01155 bitSubscriptionDataWriter_->write(data,
01156 handle);
01157
01158 } catch (const CORBA::Exception& ex) {
01159 ex._tao_print_exception(
01160 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::publish_subscription_bit:");
01161 }
01162
01163 } else {
01164 subscription->set_bit_status(1);
01165 }
01166 }
01167
01168 #else
01169 ACE_UNUSED_ARG(subscription);
01170 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01171
01172 }
01173
01174 void DCPS_IR_Domain::publish_publication_bit(DCPS_IR_Publication* publication)
01175 {
01176 #if !defined (DDS_HAS_MINIMUM_BIT)
01177
01178 if (useBIT_) {
01179
01180 DCPS_IR_Topic_Description* desc =
01181 publication->get_topic_description();
01182
01183 const char* dataTypeName = desc->get_dataTypeName();
01184
01185 bool isNotBIT =
01186 ACE_OS::strcmp(dataTypeName, OpenDDS::DCPS::BUILT_IN_PARTICIPANT_TOPIC_TYPE) &&
01187 ACE_OS::strcmp(dataTypeName, OpenDDS::DCPS::BUILT_IN_TOPIC_TOPIC_TYPE) &&
01188 ACE_OS::strcmp(dataTypeName, OpenDDS::DCPS::BUILT_IN_SUBSCRIPTION_TOPIC_TYPE) &&
01189 ACE_OS::strcmp(dataTypeName, OpenDDS::DCPS::BUILT_IN_PUBLICATION_TOPIC_TYPE);
01190
01191 if (isNotBIT) {
01192 try {
01193 const DDS::DataWriterQos* writerQos = publication->get_datawriter_qos();
01194 const DDS::PublisherQos* publisherQos = publication->get_publisher_qos();
01195
01196 DCPS_IR_Topic* topic = publication->get_topic();
01197 const DDS::TopicQos* topicQos = topic->get_topic_qos();
01198
01199 DDS::PublicationBuiltinTopicData data;
01200 get_BuiltinTopicKey(data.key, publication->get_id());
01201 get_BuiltinTopicKey(data.participant_key,
01202 publication->get_participant_id());
01203 data.topic_name = desc->get_name();
01204 data.type_name = desc->get_dataTypeName();
01205 data.durability = writerQos->durability;
01206 data.durability_service = writerQos->durability_service;
01207 data.deadline = writerQos->deadline;
01208 data.latency_budget = writerQos->latency_budget;
01209 data.liveliness = writerQos->liveliness;
01210 data.reliability = writerQos->reliability;
01211 data.lifespan = writerQos->lifespan;
01212 data.user_data = writerQos->user_data;
01213 data.ownership = writerQos->ownership;
01214 data.ownership_strength = writerQos->ownership_strength;
01215 data.destination_order = writerQos->destination_order;
01216 data.presentation = publisherQos->presentation;
01217 data.partition = publisherQos->partition;
01218 data.topic_data = topicQos->topic_data;
01219 data.group_data = publisherQos->group_data;
01220
01221 DDS::InstanceHandle_t handle
01222 = bitPublicationDataWriter_->register_instance(data);
01223
01224 publication->set_handle(handle);
01225
01226 if (OpenDDS::DCPS::DCPS_debug_level > 0) {
01227 ACE_DEBUG((LM_DEBUG,
01228 "(%P|%t) DCPS_IR_Domain::publish_publication_bit: [ %d, 0x%x, 0x%x], handle %d.\n",
01229 data.key.value[0], data.key.value[1], data.key.value[2], handle));
01230 }
01231
01232 DDS::ReturnCode_t status = bitPublicationDataWriter_->write(data, handle);
01233 if (status != DDS::RETCODE_OK) {
01234 ACE_ERROR((LM_ERROR,
01235 "(%P|%t) DCPS_IR_Domain::publish_publication_bit: write() status of %d\n",
01236 status));
01237 }
01238
01239 } catch (const CORBA::Exception& ex) {
01240 ex._tao_print_exception(
01241 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::publish_publication_bit:");
01242 }
01243
01244 } else {
01245 publication->set_bit_status(1);
01246 }
01247 }
01248
01249 #else
01250 ACE_UNUSED_ARG(publication);
01251 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01252
01253 }
01254
01255 void DCPS_IR_Domain::dispose_participant_bit(DCPS_IR_Participant* participant)
01256 {
01257 #if !defined (DDS_HAS_MINIMUM_BIT)
01258
01259 if (useBIT_) {
01260 if (!participant->isBitPublisher()) {
01261 try {
01262 DDS::ParticipantBuiltinTopicData key_data;
01263 DDS::InstanceHandle_t handle = participant->get_handle();
01264
01265 DDS::ReturnCode_t retGetKey
01266 = bitParticipantDataWriter_->get_key_value(key_data,
01267 handle);
01268
01269 if (DDS::RETCODE_OK != retGetKey) {
01270 OpenDDS::DCPS::RepoIdConverter converter(participant->get_id());
01271 ACE_ERROR((LM_ERROR,
01272 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_participant_bit ")
01273 ACE_TEXT("Unable to get_key_value for participant %C handle %d.\n"),
01274 std::string(converter).c_str(),
01275 handle));
01276 }
01277
01278 DDS::ReturnCode_t retDispose =
01279 bitParticipantDataWriter_->dispose(key_data,
01280 handle);
01281
01282 if (DDS::RETCODE_OK != retDispose) {
01283 OpenDDS::DCPS::RepoIdConverter converter(participant->get_id());
01284 ACE_ERROR((LM_ERROR,
01285 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_participant_bit ")
01286 ACE_TEXT("Unable to dispose for participant %C handle %d.\n"),
01287 std::string(converter).c_str(),
01288 handle));
01289 }
01290
01291 } catch (const CORBA::Exception& ex) {
01292 ex._tao_print_exception(
01293 "ERROR: Exception caught in DCPS_IR_Domain::dispose_participant_bit:");
01294 }
01295 }
01296 }
01297
01298 #else
01299 ACE_UNUSED_ARG(participant);
01300 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01301 }
01302
01303 void DCPS_IR_Domain::dispose_topic_bit(DCPS_IR_Topic* topic)
01304 {
01305 #if !defined (DDS_HAS_MINIMUM_BIT)
01306
01307 if (useBIT_) {
01308 if (!topic->is_bit()) {
01309 try {
01310 DDS::TopicBuiltinTopicData key_data;
01311 DDS::InstanceHandle_t handle = topic->get_handle();
01312
01313 DDS::ReturnCode_t retGetKey
01314 = bitTopicDataWriter_->get_key_value(key_data,
01315 handle);
01316
01317 if (DDS::RETCODE_OK != retGetKey) {
01318 ACE_ERROR((LM_ERROR,
01319 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_topic_bit ")
01320 ACE_TEXT("Unable to get_key_value for topic ptr 0x%x handle %d. ")
01321 ACE_TEXT("Call returned %d.\n"),
01322 topic,
01323 handle,
01324 retGetKey));
01325 }
01326
01327 DDS::ReturnCode_t retDispose =
01328 bitTopicDataWriter_->dispose(key_data,
01329 handle);
01330
01331 if (DDS::RETCODE_OK != retDispose) {
01332 ACE_ERROR((LM_ERROR,
01333 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_topic_bit ")
01334 ACE_TEXT("Unable to dispose for topic ptr 0x%x handle %d. ")
01335 ACE_TEXT("Call returned %d.\n"),
01336 topic,
01337 handle,
01338 retDispose));
01339 }
01340
01341 } catch (const CORBA::Exception& ex) {
01342 ex._tao_print_exception(
01343 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::dispose_topic_bit:");
01344 }
01345 }
01346 }
01347
01348 #else
01349 ACE_UNUSED_ARG(topic);
01350 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01351 }
01352
01353 void DCPS_IR_Domain::dispose_subscription_bit(DCPS_IR_Subscription* subscription)
01354 {
01355 #if !defined (DDS_HAS_MINIMUM_BIT)
01356
01357 if (useBIT_) {
01358 if (!subscription->is_bit()) {
01359 try {
01360 DDS::SubscriptionBuiltinTopicData key_data;
01361 DDS::InstanceHandle_t handle = subscription->get_handle();
01362
01363 DDS::ReturnCode_t retGetKey
01364 = bitSubscriptionDataWriter_->get_key_value(key_data,
01365 handle);
01366
01367 if (DDS::RETCODE_OK != retGetKey) {
01368 ACE_ERROR((LM_ERROR,
01369 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_subscription_bit ")
01370 ACE_TEXT("Unable to get_key_value for subscription ptr 0x%x handle %d. ")
01371 ACE_TEXT("Call returned %d.\n"),
01372 subscription,
01373 handle,
01374 retGetKey));
01375 }
01376
01377 DDS::ReturnCode_t retDispose =
01378 bitSubscriptionDataWriter_->dispose(key_data,
01379 handle);
01380
01381 if (DDS::RETCODE_OK != retDispose) {
01382 ACE_ERROR((LM_ERROR,
01383 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_subscription_bit ")
01384 ACE_TEXT("Unable to dispose for subscription ptr 0x%x handle %d. ")
01385 ACE_TEXT("Call returned %d.\n"),
01386 subscription,
01387 handle,
01388 retDispose));
01389 }
01390
01391 } catch (const CORBA::Exception& ex) {
01392 ex._tao_print_exception(
01393 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::dispose_subscription_bit:");
01394 }
01395 }
01396 }
01397
01398 #else
01399 ACE_UNUSED_ARG(subscription);
01400 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01401 }
01402
01403 void DCPS_IR_Domain::dispose_publication_bit(DCPS_IR_Publication* publication)
01404 {
01405 #if !defined (DDS_HAS_MINIMUM_BIT)
01406
01407 if (useBIT_) {
01408 if (!publication->is_bit()) {
01409 try {
01410 DDS::PublicationBuiltinTopicData key_data;
01411 DDS::InstanceHandle_t handle = publication->get_handle();
01412
01413 DDS::ReturnCode_t retGetKey
01414 = bitPublicationDataWriter_->get_key_value(key_data, handle);
01415
01416 if (DDS::RETCODE_OK != retGetKey) {
01417 ACE_ERROR((LM_ERROR,
01418 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_publication_bit ")
01419 ACE_TEXT("Unable to get_key_value for publication ptr 0x%x handle %d. ")
01420 ACE_TEXT("Call returned %d.\n"),
01421 publication,
01422 handle,
01423 retGetKey));
01424 }
01425
01426 DDS::ReturnCode_t retDispose =
01427 bitPublicationDataWriter_->dispose(key_data,
01428 handle);
01429
01430 if (DDS::RETCODE_OK != retDispose) {
01431 ACE_ERROR((LM_ERROR,
01432 ACE_TEXT("(%P|%t) ERROR: DCPS_IR_Domain::dispose_publication_bit ")
01433 ACE_TEXT("Unable to dispose for publication ptr 0x%x handle %d. ")
01434 ACE_TEXT("Call returned %d.\n"),
01435 publication,
01436 handle,
01437 retDispose));
01438 }
01439
01440 } catch (const CORBA::Exception& ex) {
01441 ex._tao_print_exception(
01442 "(%P|%t) ERROR: Exception caught in DCPS_IR_Domain::dispose_publication_bit:");
01443 }
01444 }
01445 }
01446
01447 #else
01448 ACE_UNUSED_ARG(publication);
01449 #endif // !defined (DDS_HAS_MINIMUM_BIT)
01450 }
01451
01452 void DCPS_IR_Domain::remove_topic_id_mapping(const OpenDDS::DCPS::RepoId& topicId)
01453 {
01454 IdToTopicMap::iterator map_entry = this->idToTopicMap_.find(topicId);
01455 if (map_entry != this->idToTopicMap_.end())
01456 idToTopicMap_.erase(map_entry);
01457 }
01458
01459 std::string DCPS_IR_Domain::dump_to_string(const std::string& prefix, int depth) const
01460 {
01461 std::string str;
01462 #if !defined (OPENDDS_INFOREPO_REDUCED_FOOTPRINT)
01463 for (int i=0; i < depth; i++)
01464 str += prefix;
01465 std::string indent = str + prefix;
01466 std::ostringstream os;
01467 os << "DCPS_IR_Domain[" << id_ << "]";
01468 str += os.str();
01469 if (useBIT_)
01470 str += " BITS";
01471 str += "\n";
01472
01473 str += indent + "Participants:\n";
01474 for (DCPS_IR_Participant_Map::const_iterator pm = participants_.begin();
01475 pm != participants_.end();
01476 pm++)
01477 {
01478 str += pm->second->dump_to_string(prefix, depth+1);
01479 }
01480
01481 str += indent + "Dead Participants:\n";
01482 for (DCPS_IR_Participant_Set::const_iterator dp = deadParticipants_.begin();
01483 dp != deadParticipants_.end();
01484 dp++)
01485 {
01486 OpenDDS::DCPS::RepoIdConverter sub_converter((*dp)->get_id());
01487 str += indent + std::string(sub_converter);
01488 str += "\n";
01489 }
01490
01491 str += indent + "Topic Descriptions:\n";
01492 for (DCPS_IR_Topic_Description_Set::const_iterator tdi = topicDescriptions_.begin();
01493 tdi != topicDescriptions_.end();
01494 tdi++)
01495 {
01496 str += tdi->second->dump_to_string(prefix, depth+1);
01497 }
01498 #endif // !defined (OPENDDS_INFOREPO_REDUCED_FOOTPRINT)
01499 return str;
01500 }
01501
01502 OPENDDS_END_VERSIONED_NAMESPACE_DECL
01503