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

#include <sample_data.h>

Inherited by adtf::streaming::penguin::sample_data< T, typename std::enable_if_t< std::is_trivially_copyable< T >::value > >.

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 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
 
const T & operator* () const
 
bool IsValid () const
 
 operator const T & () const
 
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>
class adtf::streaming::flash::sample_data< T >

Easy data access for input samples

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>
adtf::streaming::flash::sample_data< T >::sample_data ( sample_data< T > && oSampleData)
inline

move CTOR

Parameters
oSampleDataData to move from

◆ sample_data() [2/2]

template<typename T>
adtf::streaming::flash::sample_data< T >::sample_data ( const ucom::iobject_ptr< const ant::ISample > & pSample)
inline

copy CTOR

Parameters
pSampleSample to get the data from

Member Function Documentation

◆ GetData()

template<typename T>
const T & adtf::streaming::flash::sample_data< T >::GetData ( ) const
inline

Retrieves a reference to the data.

Internally it gets the buffer pointer of the sample.

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

◆ GetDataPtr()

template<typename T>
const T * adtf::streaming::flash::sample_data< T >::GetDataPtr ( ) const
inline

Retrieves the pointer to the datas memory.

Internally it gets the buffer pointer of the sample.

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

◆ GetDataSize()

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

◆ GetSampleInfo()

template<typename T>
adtf_util::cVariant adtf::streaming::flash::sample_data< T >::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>
tTimeStamp adtf::streaming::flash::sample_data< T >::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>
adtf::base::flash::tNanoSeconds adtf::streaming::flash::sample_data< T >::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>
bool adtf::streaming::flash::sample_data< T >::IsValid ( ) const
inline

Validate if sample and sample buffer is set.

Return values
trueis valid
falseis invalid

◆ operator const T &()

template<typename T>
adtf::streaming::flash::sample_data< T >::operator const T & ( ) const
inline

Return the content of sample buffer as a reference.

Returns
the value of the sample buffer as T
Return values
T()if no sample buffer set
See also
IsValid

◆ operator*()

template<typename T>
const T & adtf::streaming::flash::sample_data< T >::operator* ( ) const
inline

Retrieves a reference to the data.

Internally it gets the buffer pointer of the sample.

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

◆ operator->() [1/2]

template<typename T>
const T * adtf::streaming::flash::sample_data< T >::operator-> ( )
inline

Retrieves the pointer to the datas memory.

Internally it gets the buffer pointer of the sample.

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

◆ operator->() [2/2]

template<typename T>
const T * adtf::streaming::flash::sample_data< T >::operator-> ( ) const
inline

Retrieves the pointer to the datas memory.

Internally it gets the buffer pointer of the sample.

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

◆ Reset() [1/2]

template<typename T>
tResult adtf::streaming::flash::sample_data< T >::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>
tResult adtf::streaming::flash::sample_data< T >::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: