void DdsDomainParticipantRepository::remove(std::string const& name) throw(ENotRegistered) { DDS::DomainParticipantFactory * dpf = DDS::DomainParticipantFactory::get_instance(); InstanceMap::iterator i = instances_.find(name); if (i != instances_.end()) { DDS::DomainParticipant * p = dynamic_cast<DDS::DomainParticipant *>(i->second); DDS::ReturnCode_t rc = p->delete_contained_entities(); if (rc != DDS::RETCODE_OK) { MIRO_LOG_OSTR(LL_ERROR, "Error deleting contained entities: " << DdsSupport::getError(rc)); } rc = dpf->delete_participant(p); if (rc != DDS_RETCODE_OK) { MIRO_LOG_OSTR(LL_ERROR, "Error deleting DDS domain particpant: " << DdsSupport::getError(rc)); } instances_.erase(i); if (instances_.size() == 0) SingletonType::ACE_Singleton_Type::close(); return; } throw ENotRegistered(name); }
// specializations DdsDomainParticipantRepository::~DdsDomainParticipantRepository() throw() { MIRO_LOG_DTOR("DdsDomainParticipantRepository"); DDS::DomainParticipantFactory * dpf = DDS::DomainParticipantFactory::get_instance(); // just to make sure, the repository should actually be empty at this point. InstanceMap::iterator first, last = instances_.end(); for (first = instances_.begin(); first != last; ++first) { DDS::DomainParticipant * p = dynamic_cast<DDS::DomainParticipant *>(first->second); DDS::ReturnCode_t rc = p->delete_contained_entities(); if (rc != DDS::RETCODE_OK) { MIRO_LOG_OSTR(LL_ERROR, "Error deleting contained entities: " << DdsSupport::getError(rc)); } rc = dpf->delete_participant(dynamic_cast<DDS::DomainParticipant *>(p)); if (rc != DDS_RETCODE_OK) { MIRO_LOG_OSTR(LL_ERROR, "Error deleting DDS domain particpant: " << DdsSupport::getError(rc)); } } }
void Transport::initialize() { const char* const METHOD_NAME = "initialize"; if(m_participant == NULL) { std::string errorMessage; DDS::DomainParticipantFactory *factory = getFactory(m_domainId); DDS::DomainParticipantQos participantQos; DDS::PublisherQos publisherQos; DDS::SubscriberQos subscriberQos; if(factory != NULL) { factory->get_default_participant_qos(participantQos); #if defined(RTI_WIN32) || defined(RTI_LINUX) setTransport(participantQos, NULL); #endif // In some DDS middleware is good increase the buffer of sockets. increase_buffers(participantQos); // Creating the domain participant that will be used to create DDS entities. m_participant = factory->create_participant( m_domainId, participantQos, NULL /* listener */, STATUS_MASK_NONE); if (m_participant != NULL) { if(m_participant->get_qos(participantQos) == DDS_RETCODE_OK) { #if defined(OPENDDS) setTransport(participantQos, m_participant); #endif m_participant->set_qos(participantQos); // Creating the publisher that will be used to create datawriter entities. m_publisher = m_participant->create_publisher(PUBLISHER_QOS_DEFAULT, NULL, STATUS_MASK_NONE); if(m_publisher != NULL) { if(m_publisher->get_qos(publisherQos) == DDS_RETCODE_OK) { publisherQos.entity_factory.autoenable_created_entities = BOOLEAN_FALSE; m_publisher->set_qos(publisherQos); // Creating the subscriber that will be used to create datareader entities. m_subscriber = m_participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, NULL, STATUS_MASK_NONE); if(m_subscriber != NULL) { if(m_subscriber->get_qos(subscriberQos) == DDS_RETCODE_OK) { subscriberQos.entity_factory.autoenable_created_entities = BOOLEAN_FALSE; m_subscriber->set_qos(subscriberQos); return; } else { errorMessage = "subscriber get_qos() error"; } m_participant->delete_subscriber(m_subscriber); } else { errorMessage = "create_subscriber() error"; } } else { errorMessage = "publisher get_qos() error"; } m_participant->delete_publisher(m_publisher); } else { errorMessage = "create_publisher() error"; } } factory->delete_participant(m_participant); } else { errorMessage = "create_participant error"; } } else { errorMessage = "create factory error"; } printf("ERROR<%s::%s>: %s\n", CLASS_NAME, METHOD_NAME, errorMessage.c_str()); throw InitializeException(std::move(errorMessage)); } }