ADTF
Loading...
Searching...
No Matches
adtf::streaming::sample_data< T, Enable > Class Template Reference

#include <sample_data.h>

Public Member Functions

 sample_data ()
 CTOR.
 
 sample_data (const sample_data &oSampleData)
 CTOR.
 
 sample_data (sample_data &&oSampleData)
 
 sample_data (const ucom::iobject_ptr< const ant::ISample > &pSample)
 
 sample_data (const ucom::iobject_ptr< const flash::ISample > &pSample)
 
tTimeStamp GetTime () const
 
adtf::base::flash::tNanoSeconds GetTimeNs () const
 
const T * GetDataPtr () const
 
size_t GetDataSize () const
 
const T * operator-> ()
 
const T * operator-> () const
 
const T & GetData () const &
 
T && GetData () &&
 
const T & operator* () const
 
bool IsValid () const
 
 operator const T & () const &
 
 operator T&& () &&
 
tResult Reset (const ucom::ant::iobject_ptr< const ant::ISample > &pSample)
 
tResult Reset ()
 
adtf_util::cVariant GetSampleInfo (const ISampleInfo::tHashKey &oHash, const adtf::util::cVariant oDefault=adtf::util::cVariant()) const
 

Detailed Description

template<typename T, typename Enable = void>
class adtf::streaming::sample_data< T, Enable >

Easy data access for input samples of non trivial type @T. This sample_data is for non-trivial types, where a specialization of adtf::base::adtf_memory for type T exists. In contrast to sample_data for trivially copyable types, T is only derrived from the sample data, not the sample buffer itself.

Example Usage

{
LOG_INFO("sample value = %u", *adtf::streaming::sample_data<uint32_t>(pSample));
}
void process_sample_array(const adtf::ucom::iobject_ptr<const adtf::streaming::ISample>& pSample)
{
LOG_INFO("sample value[4] = %u", adtf::streaming::sample_data<std::array<uint32_t, 5>>(pSample).GetData()[4]);
}
void process_sample_vector(const adtf::ucom::iobject_ptr<const adtf::streaming::ISample>& pSample)
{
if (sample_data_vector.GetData().size() > 4)
{
LOG_INFO("sample value[4] = %u", adtf::streaming::sample_data<std::vector<uint32_t>>(pSample).GetData()[4]);
}
}
#define LOG_INFO(...)
Logs an info message.
Definition log.h:388
Definition sample_data.h:429
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437

or

struct tMyData
{
uint32_t nValue1;
uint32_t nValue2;
uint32_t nValue3;
};
{
LOG_INFO("my data = {%u, %u, %u}",
oMyData->nValue1,
oMyData->nValue2,
oMyData->nValue3);
}
Template Parameters
Ttype of content of the samples sample buffer to get via GetData or sample_data::operator::T
Remarks
as long a sample data holds an reference to a sample the buffer is read locked !
See also
output_sample_data

Constructor & Destructor Documentation

◆ sample_data() [1/2]

template<typename T, typename Enable = void>
adtf::streaming::penguin::sample_data< T, Enable >::sample_data ( sample_data< T, Enable > && oSampleData)
inline

move CTOR

Parameters
oSampleDataData to move from

◆ sample_data() [2/2]

template<typename T, typename Enable = void>
adtf::streaming::penguin::sample_data< T, Enable >::sample_data ( const ucom::iobject_ptr< const ant::ISample > & pSample)
inline

copy CTOR

Parameters
pSampleSample to get the data from

Member Function Documentation

◆ GetData() [1/2]

template<typename T, typename Enable = void>
T && adtf::streaming::penguin::sample_data< T, Enable >::GetData ( ) &&
inline

Retrieves a reference to the data.

Returns
returns a reference to the copy of the sample data.
Exceptions
errorERR_INVALID_STATE if the sample is not valid.

◆ GetData() [2/2]

template<typename T, typename Enable = void>
const T & adtf::streaming::penguin::sample_data< T, Enable >::GetData ( ) const &
inline

Retrieves a reference to the data.

Returns
returns a reference to the copy of the sample data.
Exceptions
errorERR_INVALID_STATE if the sample is not valid.

◆ GetDataPtr()

template<typename T, typename Enable = void>
const T * adtf::streaming::penguin::sample_data< T, Enable >::GetDataPtr ( ) const
inline

Retrieves the pointer to the datas memory.

Returns
Returns the pointer to the copy of the sample data.
Return values
nullptrif no buffer set

◆ GetDataSize()

template<typename T, typename Enable = void>
size_t adtf::streaming::penguin::sample_data< T, Enable >::GetDataSize ( ) const
inline
Returns
The size of the buffer that the data resides in.

◆ GetSampleInfo()

template<typename T, typename Enable = void>
adtf_util::cVariant adtf::streaming::penguin::sample_data< T, Enable >::GetSampleInfo ( const ISampleInfo::tHashKey & oHash,
const adtf::util::cVariant oDefault = adtf::util::cVariant() ) const
inline

Retrieves a variant value for the hash key oHash out of the samples sample information . If the value does not exists the return value is the given default oDefault.

Parameters
[in]oHashThe hash key of the value.
[in]oDefaultdefault value if value does not exist.
Returns
retrieved value as variant.

◆ GetTime()

template<typename T, typename Enable = void>
tTimeStamp adtf::streaming::penguin::sample_data< T, Enable >::GetTime ( ) const
inline

retrieves the timestamp of the data.

Internally it gets the time of the sample.

Returns
Returns the sample time.
Return values
-1if not valid.

◆ GetTimeNs()

template<typename T, typename Enable = void>
adtf::base::flash::tNanoSeconds adtf::streaming::penguin::sample_data< T, Enable >::GetTimeNs ( ) const
inline

Retrieves the timestamp of the data.

Internally it gets the time of the sample.

Returns
Returns the sample time
Return values
-1if not valid.

◆ IsValid()

template<typename T, typename Enable = void>
bool adtf::streaming::penguin::sample_data< T, Enable >::IsValid ( ) const
inline

Validate if sample and sample buffer is set.

Return values
trueis valid
falseis invalid

◆ operator const T &()

template<typename T, typename Enable = void>
adtf::streaming::penguin::sample_data< T, Enable >::operator const T & ( ) const &
inline

Return the content of sample buffer as a reference to the extracted non trivial value. i.e. if using std::string the std::string content was extracted from sample buffer

Returns
the value of the sample buffer's copy as T
Exceptions
errorERR_INVALID_STATE if the sample buffer is not valid.
See also
IsValid

◆ operator T&&()

template<typename T, typename Enable = void>
adtf::streaming::penguin::sample_data< T, Enable >::operator T&& ( ) &&
inline

Return the content of sample buffer as a reference to the extracted non trivial value. i.e. if using std::string the std::string content was extracted from sample buffer

Returns
the value of the sample buffer as T
Exceptions
errorERR_INVALID_STATE if the sample buffer is not valid.
See also
IsValid

◆ operator*()

template<typename T, typename Enable = void>
const T & adtf::streaming::penguin::sample_data< T, Enable >::operator* ( ) const
inline

Retrieves a reference to the data.

Returns
returns a reference to the copy of the sample data.
Exceptions
errorERR_INVALID_STATE if the sample is not valid.

◆ operator->() [1/2]

template<typename T, typename Enable = void>
const T * adtf::streaming::penguin::sample_data< T, Enable >::operator-> ( )
inline

Retrieves the pointer to the datas memory.

Returns
Returns the pointer to the copy of the sample data.
Return values
nullptrif no buffer set

◆ operator->() [2/2]

template<typename T, typename Enable = void>
const T * adtf::streaming::penguin::sample_data< T, Enable >::operator-> ( ) const
inline

Retrieves the pointer to the datas memory.

Returns
Returns the pointer to the copy of the sample data.
Return values
nullptrif no buffer set

◆ Reset() [1/2]

template<typename T, typename Enable = void>
tResult adtf::streaming::penguin::sample_data< T, Enable >::Reset ( )
inline

Resets the sample the sample data reference to. The reference will be empty.

Returns
standard result
Return values
ERR_NOERRORsample is reset
See also
IsValid

◆ Reset() [2/2]

template<typename T, typename Enable = void>
tResult adtf::streaming::penguin::sample_data< T, Enable >::Reset ( const ucom::ant::iobject_ptr< const ant::ISample > & pSample)
inline

Resets the sample the sample data reference to with a new reference to a sample.

Parameters
pSample[in] Reference to the sampel the sample data will reference to
Returns
standard result
Return values
ERR_NOERRORsample is reset
See also
IsValid

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