RTI Routing Service
Version 7.0.0
|
Provides temporary access to a collection of samples (data and info) from a TypedInput. More...
#include <LoanedSamples.hpp>
Public Types | |
typedef SampleIterator< T, U > | iterator |
The iterator type. More... | |
Public Member Functions | |
LoanedSamples () | |
Creates an empty LoanedSamples object. More... | |
~LoanedSamples () throw () | |
Automatically returns the loan to the TypedInput used to obtained these samples. More... | |
LoanedSample< T, U > | operator[] (size_t index) |
Provides access to the underlying LoanedSample object in array-like syntax. More... | |
int32_t | length () const |
Gets the number of samples in this collection. More... | |
void | return_loan () |
Returns the samples to the TypedInput used to get these samples. More... | |
bool | has_infos () |
Returns whether the Info part is available for each Data item of this set of loaned samples. More... | |
iterator | begin () |
Gets an iterator to the first sample. More... | |
iterator | end () |
Gets an iterator to one past the last sample. More... | |
const_iterator | begin () const |
Gets an iterator to the first sample. More... | |
const_iterator | end () const |
Gets an iterator to one past the last sample. More... | |
void | swap (LoanedSamples &other) throw () |
Swaps two LoanedSamples containers. More... | |
Provides temporary access to a collection of samples (data and info) from a TypedInput.
T | The sample data type representation. It has to match the type of the underlying rti::routing::adapter::StreamReader of the TypedInput. |
U | The sample info type representation. It has to match the type of the underlying rti::routing::adapter::StreamReader of the TypedInput. |
This STL-like container encapsulates a collection of loaned, read-only data samples rti::sub::LoanedSample::data() and rti::sub::LoanedSample::info() from a TypedInput.
To obtain a LoanedSamples, you need to call one of the read/take operations from a TypedInput. The samples have to be eventually returned to the TypedInput by calling rti::routing::adapter::StreamReader::return_loan on the underlying rti::routing::adapter::StreamReader of the TypedInput. The destructor takes care of that, and the return_loan() function lets you do it explicitly if needed.
As a move-only type, copying a LoanedSamples is not allowed. If you need to return a LoanedSamples from a function or assign it to another variable, use dds::core::move()
(or std::move()
for C++11).
Iterators and overloaded subscript operators let you access the samples in this container, which are of the type rti::routing::processor::LoanedSample.
This code demonstrates how to access the info and data of each sample in a DataReader:
typedef SampleIterator<T, U> rti::routing::processor::LoanedSamples< T, U >::iterator |
The iterator type.
|
inline |
Creates an empty LoanedSamples object.
Referenced by rti::routing::processor::LoanedSamples< T, U >::swap().
|
inline |
Automatically returns the loan to the TypedInput used to obtained these samples.
References rti::routing::processor::LoanedSamples< T, U >::return_loan().
|
inline |
Provides access to the underlying LoanedSample object in array-like syntax.
[in] | index | The index of the Sample. Allowed values are from 0 to length()-1. |
index
.
|
inline |
Gets the number of samples in this collection.
|
inline |
Returns the samples to the TypedInput used to get these samples.
Thes operation returns the samples by calling the return_loan operation on the underlying rti::routing::stream::StreamReader of the TypedInput.
This operation tells the TypedInput that the application is done accessing the collection of samples.
It is not necessary for an application to return the loans immediately after the call to read or take. However, as these buffers correspond to internal resources, the application should not retain them indefinitely.
std::exception | If there was an error returning the loan to the TypedInput. |
Referenced by rti::routing::processor::LoanedSamples< T, U >::~LoanedSamples().
|
inline |
Returns whether the Info part is available for each Data item of this set of loaned samples.
|
inline |
Gets an iterator to the first sample.
|
inline |
Gets an iterator to one past the last sample.
|
inline |
Gets an iterator to the first sample.
|
inline |
Gets an iterator to one past the last sample.
|
inline |
Swaps two LoanedSamples containers.
References rti::routing::processor::LoanedSamples< T, U >::LoanedSamples(), and rti::routing::processor::LoanedSamples< T, U >::swap().
Referenced by rti::routing::processor::LoanedSamples< T, U >::swap().