Working with data readers.
More...
Working with data readers.
Setting up a data reader
- Create a data reader, FooDataReader, of user data type
Foo:
new MyReaderListener();
};
reader_qos,
reader_listener,
if (reader == NULL) {
};
Managing instances
- Getting an instance "key" value of user data type
Foo
Set up reader to access received data
- Set up to handle the DDS_DATA_AVAILABLE_STATUS status, in one or both of the following two ways.
Access received data via a reader
- Access the received data, by either:
Taking data
- Take samples of user data type
T
. The samples are removed from the Service. The caller is responsible for deallocating the buffers.
retcode = reader->
take(data_seq, info_seq,
max_samples,
sample_state_mask,
view_state_mask,
instance_state_mask);
return;
}
- Use the received data
for(
int i = 0; i < data_seq.
length(); ++i) {
}
- Return the data samples and the information buffers back to the middleware. IMPORTANT: Once this call returns, you must not retain any pointers to any part of any sample or sample info object.
Reading data
- Read samples of user data type
Foo
. The samples are not removed from the Service. It remains responsible for deallocating the buffers.
retcode = reader->
read(data_seq, info_seq,
max_samples,
sample_state_mask,
view_state_mask,
instance_state_mask);
return;
}
- Use the received data
for(
int i = 0; i < data_seq.
length(); ++i) {
}
- Return the data samples and the information buffers back to the middleware
Tearing down a data reader