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