The get_implicit_publisher() operation allows you to access the DomainParticipant’s implicit Publisher. If one does not already exist, this operation creates an implicit Publisher.
There is a similar operation for implicit Subscribers:
DDSPublisher * get_implicit_publisher ()
DDSSubscriber * get_implicit_subscriber()
There can only be one implicit Publisher and one implicit Subscriber per DomainParticipant. They are created with default QoS values (DDS_PUBLISHER_QOS_DEFAULT) and no Listener. For more information, see Creating Publishers Explicitly vs. Implicitly. You can use an implicit Publisher or implicit Subscriber just like an explicitly created one.
An implicit Publisher/Subscriber is deleted automatically when delete_contained_entities() is called. It can also be deleted by calling delete_publisher/subscriber() with the implicit Publisher/Subscriber as a parameter.
When a DomainParticipant is deleted, if there are no attached DataReaders that belong to the implicit Subscriber or no attached DataWriters that belong to the implicit Publisher, any implicit Publisher/Subscriber will be deleted by the middleware implicitly.
Note: It is not safe to create an implicit Publisher/Subscriber while another thread may be simultaneously calling set_default_[publisher/subscriber]_qos().
using namespace DDS; ... Publisher * publisher = NULL; Subscriber * subscriber = NULL; PublisherQos publisher_qos; SubscriberQos subscriber_qos; ... publisher = participant->get_implicit_publisher(); /* Change implicit publisher QoS */ publisher->get_qos(publisher_qos); publisher_qos.partition.name.maximum(3); publisher_qos.partition.name.length(3); publisher_qos.partition.name[0] = DDS_String_dup("partition_A"); publisher_qos.partition.name[1] = DDS_String_dup("partition_B"); publisher_qos.partition.name[2] = DDS_String_dup("partition_C"); publisher->set_qos(publisher_qos); /* Get implicit subscriber */ subscriber = participant->get_implicit_subscriber(); /* Change implicit subscriber QoS */ subscriber_qos.partition.name.maximum(3); subscriber _qos.partition.name.length(3); subscriber _qos.partition.name[0] = DDS_String_dup("partition_A"); subscriber _qos.partition.name[1] = DDS_String_dup("partition_B"); subscriber _qos.partition.name[2] = DDS_String_dup("partition_C"); subscriber->set_qos(subscriber_qos);
© 2015 RTI