DDS_SubscriberQos subscriber_qos; DDS_ReturnCode_t retcode; // MySubscriberListener is user defined and // extends DDSSubscriberListener DDSSubscriberListener* subscriber_listener = new MySubscriberListener(); // or = NULL retcode = participant->get_default_subscriber_qos(subscriber_qos); if (retcode != DDS_RETCODE_OK) { // ... error }; DDSSubscriber* subscriber = participant->create_subscriber(subscriber_qos, subscriber_listener, DDS_STATUS_MASK_ALL); if (subscriber == NULL) { // ... error };
DDSDataReaderSeq reader_seq; // holder for list/set of readers DDS_SampleStateMask sample_state_mask = DDS_NOT_READ_SAMPLE_STATE; DDS_ViewStateMask view_state_mask = DDS_ANY_VIEW_STATE; DDS_InstanceStateMask instance_state_mask = DDS_ANY_INSTANCE_STATE; DDS_ReturnCode_t retcode; // get_datareadersX is not supported yet. retcode = subscriber->get_datareaders(reader_seq, sample_state_mask, view_state_mask, instance_state_mask); if (retcode != DDS_RETCODE_OK) { // ... check for cause of failure }
for(int i = 0; i < reader_seq.length(); ++i) { TDataReader* reader = reader_seq[i]; // Take the data from reader, // OR // Read the data from reader }
retcode = subscriber->notify_datareaders(); if (retcode != DDS_RETCODE_OK) { // ... check for cause of failure }
retcode = subscriber->begin_access(); if (retcode != DDS_RETCODE_OK) { // ... check for cause of failure }
retcode = subscriber->end_access(); if (retcode != DDS_RETCODE_OK) { // ... check for cause of failure }
DDS_ReturnCode_t retcode; retcode = participant->delete_subscriber(subscriber); if (retcode != DDS_RETCODE_OK) { // ... check for cause of failure }