There is no factory for creating or deleting a Listener; use the natural means in each language binding (for example, “new” or “delete” in C++ or Java). For example:
class HelloWorldListener : public DDSDataReaderListener { virtual void on_data_available(DDSDataReader* reader); }; void HelloWorldListener::on_data_available(DDSDataReader* reader) { printf("received data\n"); } // Create a Listener HelloWorldListener *reader_listener = NULL; reader_listener = new HelloWorldListener(); // Delete a Listener delete reader_listener;
A listener cannot be deleted until the entity it is attached to has been deleted. For example, you must delete the DataReader before deleting the DataReader’s listener.
Note: Due to a thread-safety issue, the destruction of a DomainParticipantListener from an enabled DomainParticipant should be avoided—even if the DomainParticipantListener has been removed from the DomainParticipant. (This limitation does not affect the Java API.)
© 2016 RTI