Example #1
0
void recreate_data_writer_and_topic(DataWriter_var& dw, const DataReader_var& dr)
{
  DataWriterQos dw_qos;
  dw->get_qos(dw_qos);

  Topic_var topic = dw->get_topic();
  TopicQos topic_qos;
  topic->get_qos(topic_qos);
  CORBA::String_var topic_name = topic->get_name(),
    type_name = topic->get_type_name();

  Publisher_var pub = dw->get_publisher();
  DomainParticipant_var dp = pub->get_participant();
  pub->delete_datawriter(dw);
  dw = 0;

  dp->delete_topic(topic);
  topic = 0;

  // Wait until the data reader is not associated with the writer.
  wait_match (dr, 0);

  topic = dp->create_topic(topic_name, type_name, topic_qos, 0, 0);
  if (!topic) {
    ACE_DEBUG((LM_ERROR, "ERROR: %P failed to re-create topic\n"));
    return;
  }

  dw = pub->create_datawriter(topic, dw_qos, 0, 0);
  if (!dw) {
    ACE_DEBUG((LM_ERROR, "ERROR: %P failed to re-create data writer\n"));
  }
}
Example #2
0
 Writer(const Publisher_var& pub, const char* topic_name,
        const DomainParticipant_var& other_participant)
   : ts_(new typename ::OpenDDS::DCPS::DDSTraits<MessageType>::TypeSupportTypeImpl())
 {
   DomainParticipant_var dp = pub->get_participant();
   check(ts_->register_type(dp, ""));
   check(ts_->register_type(other_participant, ""));
   CORBA::String_var type_name = ts_->get_type_name();
   Topic_var topic = dp->create_topic(topic_name, type_name,
     TOPIC_QOS_DEFAULT, 0, DEFAULT_STATUS_MASK);
   Topic_var topic2 = other_participant->create_topic(topic_name, type_name,
     TOPIC_QOS_DEFAULT, 0, DEFAULT_STATUS_MASK);
   dw_ = pub->create_datawriter(topic,
     DATAWRITER_QOS_DEFAULT, 0, DEFAULT_STATUS_MASK);
 }