You can instruct Connext DDS to locally ignore a publication or subscription. A publication/subscription is defined by the association of a Topic name, user data and partition set on the Publisher/Subscriber. After this call, any data written related to associated DataWriter/DataReader will be ignored.
The entity to ignore is identified by the handle argument. For ignore_publication(), the handle will be that of a DataWriter. For ignore_subscription(), that handle will be that of a DataReader.
This operation can be used to ignore local and remote entities:
DDS_ReturnCode_t ignore_publication (const DDS_InstanceHandle_t & handle) DDS_ReturnCode_t ignore_subscription (const DDS_InstanceHandle_t & handle)
Caution: There is no way to reverse these operations.
Figure 2 provides an example.
Figure 2 Ignoring Publications
class MyPublicationBuiltinTopicDataListener : public DDSDataReaderListener { public: virtual void on_data_available(DDSDataReader *reader); // ...... }; void MyPublicationBuiltinTopicdataListener::on_data_available( DDSDataReader *reader) { DDSPublicationBuiltinTopicDataReader *builtinTopicDataReader = (DDS_PublicationBuiltinTopicDataReader *)reader; DDS_PublicationBuiltinTopicDataSeq data_seq; DDS_SampleInfoSeq info_seq; int = 0; if (builtinTopicDataReader->take(data_seq, info_seq, DDS_LENGTH_UNLIMITED, DDS_ANY_SAMPLE_STATE, DDS_ANY_VIEW_STATE, DDS_ANY_INSTANCE_STATE) != DDS_RETCODE_OK) { // ... error } for (i = 0; i < data_seq.length(); ++i) { if (info_seq[i].valid_data) { // check user_data for access control if (data_seq[i].user_data[0] != 0x9) { if (builtinTopicDataReader->get_subscriber() ->get_participant() ->ignore_publication( info_seq[i].instance_handle) != DDS_RETCODE_OK) { // ... error } } } } if (builtinTopicDataReader->return_loan(data_seq, info_seq) != DDS_RETCODE_OK) { ...
© 2015 RTI