OpenSplice ISO C++ 2 DCPS  v6.x
ISO C++ 2 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
dds::sub::Sample< T > Class Template Reference

This class encapsulates the data and info meta-data associated with DDS samples. More...

#include "Sample.hpp"

Inheritance diagram for dds::sub::Sample< T >:
Inheritance graph

Public Types

typedef T DataType
 

Public Member Functions

 Sample ()
 
 Sample (const T &data, const SampleInfo &info)
 
 Sample (const Sample &other)
 
const DataTypedata () const
 
void data (const DataType &data)
 
const SampleInfoinfo () const
 
void info (const SampleInfo &info)
 
bool operator!= (const Value &other) const
 
D * operator-> ()
 
const D * operator-> () const
 
bool operator== (const Value &other) const
 

Detailed Description

template<typename T>
class dds::sub::Sample< T >

This class encapsulates the data and info meta-data associated with DDS samples.

It is normally used with dds::sub::LoanedSamples:

dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
for (it = samples.begin(); it != samples.end(); ++it) {
const dds::sub::Sample<Foo::Bar>& sample = *it;
const Foo::Bar& data = sample.data();
const dds::sub::SampleInfo& info = sample.info();
// Use sample data and meta information.
}

Or more implicitly:

dds::sub::LoanedSamples<Foo::Bar> samples = reader.read();
for (it = samples.begin(); it != samples.end(); ++it) {
const Foo::Bar& data = it->data();
const dds::sub::SampleInfo& info = it->info();
// Use sample data and meta information.
}
See also
DataSample for more information
SampleInfo for more information
Subscription for more information

Definition at line 30 of file Sample.hpp.

Member Typedef Documentation

◆ DataType

template<typename T>
typedef T dds::sub::Sample< T >::DataType

Convenience typedef for the type of the data sample.

Definition at line 72 of file Sample.hpp.

Constructor & Destructor Documentation

◆ Sample() [1/3]

template<typename T >
dds::sub::Sample< T >::Sample ( )

Create a sample with invalid data.

Definition at line 40 of file SampleImpl.hpp.

◆ Sample() [2/3]

template<typename T >
dds::sub::Sample< T >::Sample ( const T &  data,
const SampleInfo info 
)

Creates a Sample instance.

Parameters
datathe data
infothe sample info

Definition at line 43 of file SampleImpl.hpp.

◆ Sample() [3/3]

template<typename T >
dds::sub::Sample< T >::Sample ( const Sample< T > &  other)

Copies a sample instance.

Parameters
otherthe sample instance to copy

Definition at line 46 of file SampleImpl.hpp.

Member Function Documentation

◆ data() [1/2]

template<typename T >
const Sample< T >::DataType & dds::sub::Sample< T >::data ( ) const

Gets the data.

Returns
the data

Definition at line 49 of file SampleImpl.hpp.

◆ data() [2/2]

template<typename T >
void dds::sub::Sample< T >::data ( const DataType data)

Sets the data.

Parameters
datathe data

Definition at line 55 of file SampleImpl.hpp.

◆ info() [1/2]

template<typename T >
const SampleInfo & dds::sub::Sample< T >::info ( ) const

Gets the info.

Returns
the info

Definition at line 61 of file SampleImpl.hpp.

◆ info() [2/2]

template<typename T >
void dds::sub::Sample< T >::info ( const SampleInfo info)

Sets the info.

Parameters
infothe info

Definition at line 67 of file SampleImpl.hpp.

◆ operator!=()

template<typename D >
bool dds::core::Value< D >::operator!= ( const Value< D > &  other) const
inherited

Compare this Value with another Value

Parameters
otherValue
Returns
true if not equal

Definition at line 99 of file Value.hpp.

◆ operator->() [1/2]

template<typename D >
D * dds::core::Value< D >::operator-> ( )
inherited

The operator->() is provided to be able to directly invoke functions on the delegate.

The decision to provide direct access to the delegate was motivated by the need for providing a way that was not invasive with respect to the CXXDDS API and yet would allow for vendor-specific extension. Thus vendor-specific extensions can be invoked on the Value and on all its subclasses as follows:

my_dds_value.standard_function();
my_dds_value->vendor_specific_extension();
Returns
a reference to delegate.

Definition at line 111 of file Value.hpp.

◆ operator->() [2/2]

template<typename D >
const D * dds::core::Value< D >::operator-> ( ) const
inherited

The operator->() is provided to be able to directly invoke functions on the delegate.

The decision to provide direct access to the delegate was motivated by the need for providing a way that was not invasive with respect to the CXXDDS API and yet would allow for vendor-specific extension. Thus vendor-specific extensions can be invoked on the Value and on all its subclasses as follows:

my_dds_value.standard_function();
my_dds_value->vendor_specific_extension();
Returns
a reference to delegate.

Definition at line 105 of file Value.hpp.

◆ operator==()

template<typename D >
bool dds::core::Value< D >::operator== ( const Value< D > &  other) const
inherited

Compare this Value with another Value

Parameters
otherValue
Returns
true if equal

Definition at line 93 of file Value.hpp.


The documentation for this class was generated from the following files: