RTI Connext Modern C++ API
Version 6.0.1
|
<<reference-type>> A sharable and container-safe version of LoanedSamples. More...
#include <dds/sub/SharedSamples.hpp>
Public Member Functions | |
SharedSamples (dds::sub::LoanedSamples< T > &ls) | |
Constructs and instance of SharedSamples removing the ownership of the loan from the LoanedSamples. | |
const_iterator | begin () const |
Same as LoanedSamples::begin() | |
const_iterator | end () const |
Same as LoanedSamples::end() | |
DELEGATE< T >::value_type | operator[] (size_t index) const |
Same as LoanedSamples::operator[](size_t) | |
uint32_t | length () const |
Returns the number of samples. | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T > | |
void | unpack (const dds::sub::SharedSamples< T > &samples, std::vector< std::shared_ptr< const T > > &sample_vector) |
<<extension>> <<C++11>> Unpacks a SharedSamples collection into individual shared_ptr's in a vector | |
template<typename T > | |
std::vector< std::shared_ptr < const T > > | unpack (const dds::sub::SharedSamples< T > &samples) |
<<extension>> <<C++11>> Unpacks a SharedSamples collection into individual shared_ptr's in a vector | |
template<typename T > | |
std::vector< std::shared_ptr < const T > > | unpack (dds::sub::LoanedSamples< T > &&samples) |
<<extension>> <<C++11>> Unpacks a LoanedSamples collection into individual shared_ptr's in a vector | |
<<reference-type>> A sharable and container-safe version of LoanedSamples.
A SharedSamples instance is constructed from a LoanedSamples instance, removing the ownership of the loan from the LoanedSamples.
The destruction of the LoanedSamples object or the explicit invocation of its method return_loan will have no effect on loaned data.
Constructing a SharedSamples from another SharedSamples, creates a new reference to the same loan. Loaned data will be returned automatically to the DataReader once the reference count reaches zero.
|
inline |
Constructs and instance of SharedSamples removing the ownership of the loan from the LoanedSamples.
The constructor is implicit to simplify statements like the following:
ls | the loaned samples. |
|
inline |
Same as LoanedSamples::begin()
|
inline |
Same as LoanedSamples::end()
|
inline |
|
inline |
Returns the number of samples.
|
related |
<<extension>> <<C++11>> Unpacks a SharedSamples collection into individual shared_ptr's in a vector
#include
<rti/sub/unpack.hpp>
This function creates a reference (not a copy) to each sample with valid data in a SharedSamples container and pushes it back into a vector.
Each individual sample in the vector retains a reference to the original SharedSamples that controls when the loan is returned. These references can be further shared. When all the references go out of scope, the loan is returned.
This can be also useful to insert samples from different calls to read()/take() into the same vector. It is however recommended to not hold these samples indefinitely, since they use internal resources.
Example:
T | The topic-type |
samples | The collection of samples obtained from the DataReader |
sample_vector | The destination where the samples are pushed back. |
|
related |
<<extension>> <<C++11>> Unpacks a SharedSamples collection into individual shared_ptr's in a vector
This overload returns a new vector instead of adding into an existing one.
|
related |
<<extension>> <<C++11>> Unpacks a LoanedSamples collection into individual shared_ptr's in a vector
This overload is a shortcut for unpack
(SharedSamples<T>(loaned_samples)) to simplify code like the following: