RTI Connext Traditional C++ API Version 7.2.0
connext::Sample< T > Class Template Reference

A data sample and related info received from the middleware. More...

Inherits connext::details::SampleBase< T, I >.

Public Member Functions

 Sample ()
 Creates a sample with default data and info values. More...
 
 Sample (const Sample< T > &other)
 Creates a sample making a deep copy of another sample. More...
 
 Sample (SampleRef< T > sample_ref)
 Creates a sample as a deep copy of the contents referenced by a WriteSampleRef. More...
 
SampleIdentity_t identity () const
 Gets the identity of this sample. More...
 
SampleIdentity_t related_identity () const
 Gets the identity of a sample that is related to this one. More...
 
T & data ()
 Gets the data this sample contains. More...
 
SampleInfoinfo ()
 Gets the sample information. More...
 
const T & data ()
 Gets the data this sample contains. More...
 
const SampleInfoinfo ()
 Gets the sample information. More...
 

Detailed Description

template<typename T>
class connext::Sample< T >

A data sample and related info received from the middleware.

Samples contain data received from the middleware and information associated to the data.

Template Parameters
TThe data type that this sample contains
See also
connext::Requester::receive_reply(Sample<TRep>&, const Duration_t&)
connext::Requester::take_reply(Sample<TRep>&)
connext::Replier::receive_request(Sample<TReq>&, const Duration_t&)

Constructor & Destructor Documentation

◆ Sample() [1/3]

template<typename T >
connext::Sample< T >::Sample ( )
inline

Creates a sample with default data and info values.

The data is deeply initialized using the corresponding TypeSupport

See also
FooTypeSupport::initialize_data

◆ Sample() [2/3]

template<typename T >
connext::Sample< T >::Sample ( const Sample< T > &  other)
inline

Creates a sample making a deep copy of another sample.

◆ Sample() [3/3]

template<typename T >
connext::Sample< T >::Sample ( SampleRef< T >  sample_ref)

Creates a sample as a deep copy of the contents referenced by a WriteSampleRef.

Member Function Documentation

◆ identity()

template<typename T >
SampleIdentity_t connext::Sample< T >::identity ( ) const
inline

Gets the identity of this sample.

The identity is assigned by the middleware upon reception.

See also
Correlating requests and replies

References connext::Sample< T >::info().

◆ related_identity()

template<typename T >
SampleIdentity_t connext::Sample< T >::related_identity ( ) const
inline

Gets the identity of a sample that is related to this one.

When a connext::Requester receives a reply, the reply Sample contains the identity of the related request.

Returns
The identity of another sample that is related to this one, or DDS_UNKNOWN_SAMPLE_IDENTITY if there is not a related sample.
See also
connext::Requester::receive_reply(Sample<TRep>&, const Duration_t&)
Correlating requests and replies

References connext::Sample< T >::info().

◆ data() [1/2]

template<typename T >
T & connext::Sample< T >::data ( )

Gets the data this sample contains.

See also
Basic Requester example

◆ info() [1/2]

template<typename T >
SampleInfo & connext::Sample< T >::info ( )

◆ data() [2/2]

template<typename T >
const T & connext::Sample< T >::data ( )

Gets the data this sample contains.

See also
Basic Requester example

◆ info() [2/2]

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

Gets the sample information.

See also
DDS_SampleInfo
Basic Requester example