RTI Connext Modern C++ API
Version 6.1.0
|
The following #includes are needed for the examples on this page
You can read data samples from a DataReader by receiving a loan, inspecting the samples and then returning the loan, or you can directly copy them.
To iterate through loaned data samples in your application you will use a LoanedSamples container. The following code shows different ways to use this container
Although the LoanedSamples is the most generic way to access data in a DataReader, for convinience other overloaded versions of read/take allow to directly copy the data
The functions read() and take() select all samples in the DataReader queue. The function select() allows specifying different criteria about the data to read. A equivalent API, using the streaming >> operator is available too.
select() example
Streaming example
If a Subscriber's PresentationQosPolicy access_scope is GROUP and ordered_access is true, the application can access the samples in order across DataWriters of the same group (Publisher with access_scope GROUP). The queue is ordered/sorted per topic across all instances belonging to DataWriters (or DataReaders) within the same Publisher (or Subscriber).
When you want to hold a reference to a DataReader and the type T doesn't matter, you can use the class dds::sub::AnyDataReader
, which provides type-independent methods.