ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
output_sample_data< T >

Wrapper class that facilitates the handling of output samples. More...

#include <sample.h>

Public Member Functions

 output_sample_data (base::flash::tNanoSeconds tmSampleTime)
 Initializes the data timestamp.
 
 output_sample_data (tTimeStamp tmSampleTime)
 Initializes the data timestamp.
 
 output_sample_data (base::flash::tNanoSeconds tmSampleTime, const T &oValue)
 Initializes the data timestamp and value.
 
 output_sample_data (base::flash::tNanoSeconds tmSampleTime, const T &oValue, uint32_t nSubStreamId)
 
 output_sample_data (tTimeStamp tmSampleTime, const T &oValue)
 Initializes the data timestamp and value.
 
 output_sample_data (const ant::ISample &oSampleToCopy)
 Initializes the data from an existing sample.
 
 output_sample_data (const ucom::ant::iobject_ptr< const ant::ISample > &pSampleToCopy)
 Initializes the data from an existing sample.
 
 output_sample_data (output_sample_data &&)=default
 
output_sample_dataoperator= (output_sample_data &&)=default
 
void SetSubStreamId (uint32_t nSubStreamId)
 Sets the Substream id of the generated sample.
 
T * GetDataPtr ()
 
const T * GetDataPtr () const
 
T * operator-> ()
 
const T * operator-> () const
 
T & GetData ()
 
const T & GetData () const
 
T & operator* ()
 
const T & operator* () const
 
output_sample_dataoperator= (const T &oValue)
 Assigns a new value to the data.
 
 operator T& ()
 
 operator const T & () const
 
ucom::ant::object_ptr< ant::ISampleRelease ()
 Returns a sample that contains the data and resets all internal data.
 
tResult SetSampleInfo (const ISampleInfo::tHashKey &oHash, const adtf::util::cVariant oValue)
 Sets a variant value for the hash key oHash into the current samples sample information.
 

Protected Attributes

ucom::ant::object_ptr< ant::ISamplem_pSample
 
ucom::ant::object_ptr_locked< ant::ISampleBufferm_pBuffer
 

Private Member Functions

void AssignValue (const T &oValue)
 
 output_sample_data (const output_sample_data &)=delete
 
output_sample_dataoperator= (const output_sample_data &)=delete
 

Detailed Description

template<typename T>
class adtf::streaming::flash::output_sample_data< T >

Wrapper class that facilitates the handling of output samples.

Use one of its constructors to initialize the data, then update it and finally call Release() to retrieve a sample that you can write via ISampleWriter::Write().

See also
sample_data

Definition at line 352 of file sample.h.

Constructor & Destructor Documentation

◆ output_sample_data() [1/7]

template<typename T>
output_sample_data ( base::flash::tNanoSeconds tmSampleTime)
inlineexplicit

Initializes the data timestamp.

Example Usage

void generate_data(adtf::streaming::ISampleWriter* pWriter)
{
oOutputData = 54321;
pWriter->Write(oOutputData.Release());
}
Copyright © Audi Electronics Venture GmbH.
Interface for sample writers that write to sample streams via output pins.
virtual tResult Write(const ucom::ant::iobject_ptr< const ant::ISample > &pSample)=0
Writes a sample to the connected sample stream.
Wrapper class that facilitates the handling of output samples.
Definition sample.h:353
ucom::ant::object_ptr< ant::ISample > Release()
Returns a sample that contains the data and resets all internal data.
Definition sample.h:588

or

struct tMyData
{
uint32_t nValue1;
uint32_t nValue2;
uint32_t nValue3;
};
void generate_data(adtf::streaming::ISampleWriter* pWriter)
{
oOutputData = {1, 2};
oOutputData->nValue3 = 3;
pWriter->Write(oOutputData.Release());
}
Parameters
[in]tmSampleTimeThe timestamp.
Exceptions
tResultIn case of an error.

Definition at line 369 of file sample.h.

References adtf::streaming::flash::alloc_sample(), and THROW_IF_FAILED.

Referenced by output_sample_data(), output_sample_data(), output_sample_data(), GetDataPtr(), and operator=().

◆ output_sample_data() [2/7]

template<typename T>
output_sample_data ( tTimeStamp tmSampleTime)
inlineexplicit

Initializes the data timestamp.

Parameters
[in]tmSampleTimeThe timestamp.
Exceptions
tResultIn case of an error.

Definition at line 380 of file sample.h.

References adtf::streaming::flash::alloc_sample(), and THROW_IF_FAILED.

◆ output_sample_data() [3/7]

template<typename T>
output_sample_data ( base::flash::tNanoSeconds tmSampleTime,
const T & oValue )
inline

Initializes the data timestamp and value.

Example Usage

void generate_data(adtf::streaming::ISampleWriter* pWriter)
{
pWriter->Write(oOutputData.Release());
}
Parameters
[in]tmSampleTimeThe timestamp.
[in]oValueThe value of the sample data
Exceptions
tResultIn case of an error.

Definition at line 396 of file sample.h.

References output_sample_data().

◆ output_sample_data() [4/7]

template<typename T>
output_sample_data ( base::flash::tNanoSeconds tmSampleTime,
const T & oValue,
uint32_t nSubStreamId )
inline

Definition at line 403 of file sample.h.

◆ output_sample_data() [5/7]

template<typename T>
output_sample_data ( tTimeStamp tmSampleTime,
const T & oValue )
inline

Initializes the data timestamp and value.

Parameters
[in]tmSampleTimeThe timestamp.
[in]oValueThe value of the sample data
Exceptions
tResultIn case of an error.

Definition at line 423 of file sample.h.

References output_sample_data().

◆ output_sample_data() [6/7]

template<typename T>
output_sample_data ( const ant::ISample & oSampleToCopy)
inlineexplicit

Initializes the data from an existing sample.

Example Usage

void generate_data(adtf::streaming::ISampleWriter* pWriter,
const adtf::streaming::ISample& oInputSample)
{
oOutputData += 1234;
pWriter->Write(oOutputData.Release());
}
The ISample interface sets and retrieves properties on samples .
Definition sample_intf.h:36
Parameters
[in]oSampleToCopyThe sample to copy.
Exceptions
tResultIn case of an error.

Definition at line 439 of file sample.h.

References adtf::streaming::flash::alloc_sample(), THROW_ERROR_DESC, and THROW_IF_FAILED.

◆ output_sample_data() [7/7]

template<typename T>
output_sample_data ( const ucom::ant::iobject_ptr< const ant::ISample > & pSampleToCopy)
inlineexplicit

Initializes the data from an existing sample.

Parameters
[in]pSampleToCopyThe sample to copy.
Exceptions
tResultIn case of an error.

Definition at line 457 of file sample.h.

References output_sample_data().

Member Function Documentation

◆ AssignValue()

template<typename T>
void AssignValue ( const T & oValue)
inlineprivate

Definition at line 619 of file sample.h.

◆ GetData() [1/2]

template<typename T>
T & GetData ( )
inline
Returns
A reference to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 520 of file sample.h.

References GetDataPtr().

Referenced by operator const T &(), operator T&(), operator*(), and operator*().

◆ GetData() [2/2]

template<typename T>
const T & GetData ( ) const
inline
Returns
A reference to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 529 of file sample.h.

References GetDataPtr().

◆ GetDataPtr() [1/2]

template<typename T>
T * GetDataPtr ( )
inline
Returns
A pointer to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 480 of file sample.h.

References output_sample_data().

Referenced by GetData(), GetData(), operator->(), and operator->().

◆ GetDataPtr() [2/2]

template<typename T>
const T * GetDataPtr ( ) const
inline
Returns
A pointer to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 489 of file sample.h.

References THROW_ERROR_DESC.

◆ operator const T &()

template<typename T>
operator const T & ( ) const
inline
Returns
A reference to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 573 of file sample.h.

References GetData().

◆ operator T&()

template<typename T>
operator T& ( )
inline
Returns
A reference to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 564 of file sample.h.

References GetData().

◆ operator*() [1/2]

template<typename T>
T & operator* ( )
inline

Returns
A reference to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 537 of file sample.h.

References GetData().

◆ operator*() [2/2]

template<typename T>
const T & operator* ( ) const
inline

Returns
A reference to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 545 of file sample.h.

References GetData().

◆ operator->() [1/2]

template<typename T>
T * operator-> ( )
inline

Returns
A pointer to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 503 of file sample.h.

References GetDataPtr().

◆ operator->() [2/2]

template<typename T>
const T * operator-> ( ) const
inline

Returns
A pointer to the data cast to the requested type.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 511 of file sample.h.

References GetDataPtr().

◆ operator=()

template<typename T>
output_sample_data & operator= ( const T & oValue)
inline

Assigns a new value to the data.

Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 554 of file sample.h.

References output_sample_data().

◆ Release()

template<typename T>
ucom::ant::object_ptr< ant::ISample > Release ( )
inline

Returns a sample that contains the data and resets all internal data.

Do not call any other methods after you called this method.

Example Usage

void generate_data(adtf::streaming::ISampleWriter* pWriter)
{
oOutputData = 54321;
pWriter->Write(oOutputData.Release());
}
Returns
A pointer to a sample containing the output data.
Exceptions
ERR_INVALID_STATEIf Release() has been called.

Definition at line 588 of file sample.h.

References THROW_ERROR_DESC.

◆ SetSampleInfo()

template<typename T>
tResult SetSampleInfo ( const ISampleInfo::tHashKey & oHash,
const adtf::util::cVariant oValue )
inline

Sets a variant value for the hash key oHash into the current samples sample information.

Parameters
[in]oHashThe hash key of the value.
[in]oValuevalue to set.
Returns
standard error code
Return values
ERR_NOERRORvalue is set
ERR_INVALID_TYPEType is not supported. See base::ant::IHashValueMapValue::tType

Definition at line 609 of file sample.h.

References adtf::streaming::ant::set_sample_info().

◆ SetSubStreamId()

template<typename T>
void SetSubStreamId ( uint32_t nSubStreamId)
inline

Sets the Substream id of the generated sample.

Parameters
[in]nSubStreamIdThe substream id.

Definition at line 471 of file sample.h.

References adtf::streaming::hollow::set_sample_substream_id().

Member Data Documentation

◆ m_pBuffer

template<typename T>
ucom::ant::object_ptr_locked<ant::ISampleBuffer> m_pBuffer
protected

Definition at line 616 of file sample.h.

◆ m_pSample

template<typename T>
ucom::ant::object_ptr<ant::ISample> m_pSample
protected

Definition at line 615 of file sample.h.