Working with subscribers.
Working with subscribers.
Setting up a subscriber
- Set up participant
- Create a DDSSubscriber
new MySubscriberListener();
retcode = participant->get_default_subscriber_qos(subscriber_qos);
};
participant->create_subscriber(subscriber_qos,
subscriber_listener,
if (subscriber == NULL) {
};
<<interface>> DDSListener for status about a subscriber.
Definition: subscription.ifcxx:224
<<interface>> A subscriber is the object responsible for actually receiving data from a subscription.
Definition: subscription.ifcxx:366
DDS_ReturnCode_t
Type for return codes.
Definition: infrastructure.ifc:1336
@ DDS_RETCODE_OK
Successful return.
Definition: infrastructure.ifc:1339
#define DDS_STATUS_MASK_ALL
All bits are set.
Definition: infrastructure.ifc:1416
QoS policies supported by a DDSSubscriber entity.
Definition: subscription.ifc:1878
Set up subscriber to access received data
Access received data via a subscriber
- Ensure subscriber is set up to access received data
- Get the list of readers that have data samples available:
sample_state_mask,
view_state_mask,
instance_state_mask);
}
Declares IDL sequence < DDSDataReader > .
Definition: subscription.ifcxx:163
virtual DDS_ReturnCode_t get_datareaders(DDSDataReaderSeq &readers, DDS_SampleStateMask sample_states, DDS_ViewStateMask view_states, DDS_InstanceStateMask instance_states)=0
Allows the application to access the DDSDataReader objects that contain samples with the specified sa...
DDS_UnsignedLong DDS_InstanceStateMask
A bit-mask (list) of instance states, i.e. DDS_InstanceStateKind.
Definition: subscription.ifc:1090
const DDS_InstanceStateMask DDS_ANY_INSTANCE_STATE
Any instance state ALIVE_INSTANCE_STATE | NOT_ALIVE_DISPOSED_INSTANCE_STATE | NOT_ALIVE_NO_WRITERS_IN...
DDS_UnsignedLong DDS_SampleStateMask
A bit-mask (list) of sample states, i.e. DDS_SampleStateKind.
Definition: subscription.ifc:1017
@ DDS_NOT_READ_SAMPLE_STATE
Sample has not been read.
Definition: subscription.ifc:1007
const DDS_ViewStateMask DDS_ANY_VIEW_STATE
Any view state DDS_NEW_VIEW_STATE | DDS_NOT_NEW_VIEW_STATE.
DDS_UnsignedLong DDS_ViewStateMask
A bit-mask (list) of view states, i.e. DDS_ViewStateKind.
Definition: subscription.ifc:1052
- Upon successfully getting the list of readers with data, process the data readers to either:
If the intent is to access the data coherently or in order, the list of data readers must be processed in the order returned:
for(int i = 0; i < reader_seq.length(); ++i) {
TDataReader* reader = reader_seq[i];
}
- Alternatively, call DDSSubscriber::notify_datareaders to invoke the DDSDataReaderListener for each of the data readers.
}
virtual DDS_ReturnCode_t notify_datareaders()=0
Invokes the operation DDSDataReaderListener::on_data_available() on the DDSDataReaderListener objects...
Access received data coherently and/or in order
To access the received data coherently and/or in an ordered manner, according to the settings of the DDS_PresentationQosPolicy attached to a DDSSubscriber:
Tearing down a subscriber
- Delete DDSSubscriber:
retcode = participant->delete_subscriber(subscriber);
}