Deleting Publishers

(Note: in the Modern C++ API, Entities are automatically destroyed, see Creating and Deleting DDS Entities)

This section applies to both implicitly and explicitly created Publishers.

To delete a Publisher:

  1. You must first delete all DataWriters that were created with the Publisher. Use the Publisher’s delete_datawriter() operation to delete them one at a time, or use the delete_contained_entities() operation (Deleting Contained DataWriters) to delete them all at the same time.
   DDS_ReturnCode_t delete_datawriter (DDSDataWriter *a_datawriter)
  1. Delete the Publisher by using the DomainParticipant’s delete_publisher() operation.
   DDS_ReturnCode_t delete_publisher (DDSPublisher *p)

Note: A Publisher cannot be deleted within a Listener callback, see Restricted Operations in Listener Callbacks.

Deleting Contained DataWriters

The Publisher’s delete_contained_entities() operation deletes all the DataWriters that were created by the Publisher.

DDS_ReturnCode_t delete_contained_entities () 

After this operation returns successfully, the application may delete the Publisher (see Deleting Publishers).

© 2018 RTI