RTI Connext Modern C++ API
Version 5.2.0
|
<<move-only-type>> Provides temporary access to a collection of samples from a DataReader. More...
#include <LoanedSamplesImpl.hpp>
Public Types | |
typedef SampleIterator< T > | iterator |
The iterator type. | |
Public Member Functions | |
LoanedSamples () | |
Creates an empty LoanedSamples object. | |
~LoanedSamples () throw () | |
Automatically returns the loan to the DataReader. | |
value_type | operator[] (size_t index) |
Provides access to the underlying LoanedSample object in array-like syntax. | |
unsigned int | length () const |
Gets the number of samples in this collection. | |
void | return_loan () |
Returns the samples to the container // TODO. | |
iterator | begin () |
Gets an iterator to the first sample. | |
iterator | end () |
Gets an iterator to one past the last sample. | |
const_iterator | begin () const |
Gets an iterator to the first sample. | |
const_iterator | end () const |
Gets an iterator to one past the last sample. | |
void | swap (LoanedSamples &other) throw () |
Swap two LoanedSamples containers. | |
LoanedSamples (LoanedSamples &&other) | |
<<C++11>> Moves the loan from an existing LoanedSamples to a new one | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
LoanedSamples< T > | move (LoanedSamples< T > &ls) OMG_NOEXCEPT |
Creates a new LoanedSamples instance by moving the contents of an existing one. | |
template<typename T > | |
LoanedSamples< T >::iterator | begin (LoanedSamples< T > &ls) |
template<typename T > | |
LoanedSamples< T >::const_iterator | begin (const LoanedSamples< T > &ls) |
template<typename T > | |
LoanedSamples< T >::iterator | end (LoanedSamples< T > &ls) |
template<typename T > | |
LoanedSamples< T >::const_iterator | end (const LoanedSamples< T > &ls) |
template<typename T > | |
void | swap (LoanedSamples< T > &ls1, LoanedSamples< T > &ls2) throw() |
template<typename T > | |
ValidSampleIterator< T > | valid_samples (const SampleIterator< T > &sample_iterator) |
<<extension>> Returns an iterator that skips invalid samples | |
<<move-only-type>> Provides temporary access to a collection of samples from a DataReader.
T | The topic-type. It has to match the type of the DataReader. |
This STL-like container encapsulates a collection of loaned, read-only data samples from a DataReader.
To obtain a LoanedSamples you need to call one of the read/take operations from a DataReader. The samples have to be eventually returned to the DataReader. 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 want to have more than one reference to a collection of loaned sample, see SharedSamples. If you need to return a LoanedSamples from a function or assign it to another variable, use dds::core::move()
(or std::move()
<<C++11>>).
Iterators and overloaded subscript operators let you access the samples in this container, which are of the type rti::sub::LoanedSample.
typedef SampleIterator<T> dds::sub::LoanedSamples< T >::iterator |
The iterator type.
|
inline |
Creates an empty LoanedSamples object.
|
inline |
Automatically returns the loan to the DataReader.
|
inline |
<<C++11>> Moves the loan from an existing LoanedSamples to a new one
|
inline |
Provides access to the underlying LoanedSample object in array-like syntax.
index
.
|
inline |
Gets the number of samples in this collection.
|
inline |
Returns the samples to the container // TODO.
|
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 |
Swap two LoanedSamples containers.
|
related |
Creates a new LoanedSamples instance by moving the contents of an existing one.
Note: in <<C++11>> you can directly use std::move
.
The parameter object loses the ownership of the underlying samples and its state is reset as if it was default initialized. This function must be used to move any named LoanedSamples instance (lvalue) in and out of a function by-value. Using this function is not necessary if the original LoanedSamples is an rvalue. Moving is a very efficient operation and is guaranteed to not throw any exception.
ls | The LoanedSamples object that transfers its ownership of the contained samples into the returned object. After this call, ls is empty. |
ls
had.
|
related |
|
related |
|
related |
|
related |
|
related |
|
related |
<<extension>> Returns an iterator that skips invalid samples
Given a regular sample iterator, this functions creates another iterator it
that behaves exactly the same except that it++
moves to the next valid sample (or to the end of the collection). That is, if it
doesn't point to the end of the collection, it->info.valid()
is always true.
This is useful when your application doesn't need to deal with samples containing meta-information only.
For example, the following code copies all the data in a LoanedSamples collection skipping any invalid samples (otherwise, attempting to copy the data from an invalid sample would throw an exception, see rti::sub::LoanedSample::operator const DataType& ()).
Note that valid_samples
(samples.begin()) won't point to the first element if that element is not a valid sample.
A similar utility is the functor rti::sub::IsValidData.