예제 #1
0
  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);
  }
예제 #2
0
  // 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));
      }
    }
  }