ADTF  3.14.3
cSampleCodec

Codec for samples with static and/or dynamic data. More...

Inheritance diagram for cSampleCodec:
[legend]

Public Types

typedef ddl::codec::CodecElement< sample_codec_access< cSampleCodec > > tElement
 Iterator value element type for the codec to get value, set value and get element information. More...
 
typedef ddl::codec::ChildElements< sample_codec_access< cSampleCodec > > tElements
 Iterator container to iterate all elements of the codec. More...
 
- Public Types inherited from cSampleDecoderBase
typedef ddl::codec::DecoderElement< sample_decoder_access< const cSampleDecoderBase > > tElement
 Iterator value element type for the codec to get value, set value and get element information. More...
 
typedef ddl::codec::ChildElements< sample_decoder_access< const cSampleDecoderBase > > tElements
 Iterator container to iterate all elements of the decoder. More...
 
- Public Types inherited from cDecoderLegacy
typedef ddl::StructElement DefinedStructElementType
 type definition for the old access_element API.
 

Public Member Functions

 cSampleCodec ()
 Default constructor.
 
 cSampleCodec (cSampleCodec &&)
 Move constructor.
 
cSampleCodecoperator= (cSampleCodec &&)
 Move assignment operator.
 
template<typename T >
void SetElementValue (const tCodecIndex &oCodecIndex, const T &oValue)
 Sets the elements value from the given oValue. More...
 
void SetElementVariantValue (const tCodecIndex &oCodecIndex, const a_util::variant::Variant &oValue)
 Sets the current value of the given element from the given variant. More...
 
void SetElementStringValue (const tCodecIndex &oCodecIndex, const std::string &strValue)
 Sets the current value of the given element from the given string. More...
 
void SetElementRawValue (const tCodecIndex &oCodecIndex, const void *pValue, size_t szValueSize)
 Sets the elements value by copy the memory from pValue. More...
 
void * GetElementAddress (const tCodecIndex &oCodecIndex)
 Gets the elements value memory pointer into the given data for writig access. More...
 
tElement GetElement (const tCodecIndex &oCodecIndex)
 Retrieves an element for the codec index. More...
 
tElement GetElement (const std::string &strElementFullName)
 Retrieves an element for the given name. More...
 
tElementsGetElements ()
 Retrieves the elements of the codec to get element information, to get and set the values. More...
 
void * GetElementAddress (const std::string &strElementFullName)
 Gets the elements value memory pointer into the given data for writing access. More...
 
tElement GetElement (const tCodecIndex &oCodecIndex) const
 Retrieves an element for the codec index. More...
 
tElement GetElement (const std::string &strElementFullName) const
 Retrieves an element for the given name. More...
 
const tElementsGetElements () const
 Retrieves the elements of the decoder to get element information and the values. More...
 
const void * GetElementAddress (const tCodecIndex &oCodecIndex) const
 Gets the elements value memory pointer into the given data. More...
 
- Public Member Functions inherited from cSampleDecoderBase
 cSampleDecoderBase (cSampleDecoderBase &&)
 
cSampleDecoderBaseoperator= (cSampleDecoderBase &&)
 
tResult IsValid () const
 Returns the validation state of the coder. More...
 
tElement GetElement (const tCodecIndex &oCodecIndex) const
 Retrieves an element for the codec index. More...
 
tElement GetElement (const std::string &strElementFullName) const
 Retrieves an element for the given name. More...
 
const tElementsGetElements () const
 Retrieves the elements of the decoder to get element information and the values. More...
 
size_t GetElementChildCount (const tCodecIndex &oCodecIndex) const
 Retrieves the amount of child elements for the given codec index. More...
 
std::string GetElementFullName (const tCodecIndex &oCodecIndex) const
 Retrieves the full name of the element within its main structure. More...
 
std::string GetElementName (const tCodecIndex &oCodecIndex) const
 Retrieves the name of the element within its structured element. More...
 
const std::string & GetElementBaseName (const tCodecIndex &oCodecIndex) const
 Retrieves the base name of the element within its structured element. More...
 
size_t GetStaticBufferSize () const
 Gets the static buffer size in bytes for the main structure. More...
 
size_t GetStaticBufferSize (ddl::tDataRepresentation oRep) const
 Gets the static buffer size in bytes for the main structure. More...
 
ddl::tDataRepresentation GetRepresentation () const
 Returns the current data representation the decoder decodes from. More...
 
template<typename T >
GetElementValue (const tCodecIndex &oCodecIndex) const
 Gets the elements value as value of type T. More...
 
a_util::variant::Variant GetElementVariantValue (const tCodecIndex &oCodecIndex) const
 Returns the current value of the given element as a variant. More...
 
void GetElementVariantValue (const tCodecIndex &oCodecIndex, a_util::variant::Variant &oValue) const
 Returns the current value of the given element as a variant. More...
 
std::string GetElementStringValue (const tCodecIndex &oCodecIndex) const
 Returns the current value of the given element as a string. More...
 
void GetElementRawValue (const tCodecIndex &oCodecIndex, void *pValue, size_t szValueSize) const
 Copies the elements value to the given memory pointer in @pValue. More...
 
const void * GetElementAddress (const tCodecIndex &oCodecIndex) const
 Gets the elements value memory pointer into the given data. More...
 
void Resolve (tCodecIndex &oCodecIndex) const
 retrieves the lyoutinformation for the given codec index. More...
 
- Public Member Functions inherited from cDecoderLegacy
tCodecIndex Resolve (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Retrieves a codec index with element information for the given leaf index. More...
 
adtf_util::cVariant GetElementValue (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element Value. More...
 
tResult GetElementValue (tCodecLeafIndex nElementLeafIndex, adtf_util::cVariant &oValue) const
 Legacy: Get the Element Value. More...
 
tResult GetElementValue (const char *strElementName, adtf_util::cVariant &oValue) const
 Legacy: Get the Element Value. More...
 
tResult GetElementValue (tCodecLeafIndex nElementLeafIndex, void *pValue) const
 Legacy: Copies the Element Value memory into the memory pointer. More...
 
tResult GetElementValue (const char *strElementName, void *pValue) const
 Legacy: Get the Element Value pointer. More...
 
adtf_util::cString GetElementValueString (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element Value as string (resolved to the enum element name if is enum type) More...
 
tResult GetElement (tCodecLeafIndex nElementLeafIndex, const ddl::StructElement *&pElement) const
 Get the Element StructElement information. More...
 
const void * GetElementAddress (tCodecLeafIndex nElementIndex) const
 Legacy: Get the Element StructElement information. More...
 
size_t GetElementCount () const
 Legacy: Get the Element Leaf count. More...
 
- Public Member Functions inherited from cCodecLegacy< ddl::codec::Codec >
tResult SetElementValue (tCodecLeafIndex nElementLeafIndex, const adtf_util::cVariant &oValue)
 Legacy: Set the Element Value. More...
 
tResult SetElementValue (const char *strElementName, const adtf_util::cVariant &oValue)
 Legacy: Set the Element Value. More...
 
void * GetElementAddress (tCodecLeafIndex nElementLeafIndex)
 Legacy:Get the Element Address object. More...
 

Private Member Functions

 cSampleCodec (ddl::codec::Codec &&oDecoder, adtf::ucom::object_ptr_locked< adtf::streaming::ISampleBuffer > &&pBuffer)
 For internal use only.
 
const ddl::codec::StaticDecodergetDecoder () const override
 For internal use only.
 
ddl::codec::CodecgetCodec () override
 Get the Codec. More...
 

Private Attributes

ddl::codec::Codec m_oCodec
 For internal use only.
 
adtf::ucom::object_ptr_locked< adtf::streaming::ISampleBufferm_pBuffer
 For internal use only.
 
tElement m_oFirstElement
 

Additional Inherited Members

- Static Public Member Functions inherited from cDecoderLegacy
static const char * GetStructElementName (const ddl::StructElement *pElement)
 Legacy: Get the Struct Element Name for access_element legacy support. More...
 
- Protected Member Functions inherited from cSampleDecoderBase
void ResetFirst ()
 

Detailed Description

Codec for samples with static and/or dynamic data.

Definition at line 538 of file sample_codec.h.

Member Typedef Documentation

◆ tElement

Iterator value element type for the codec to get value, set value and get element information.

See also
for_each_leaf_element, for_each_element
ddl::codec::CodecElement

Definition at line 656 of file sample_codec.h.

◆ tElements

Iterator container to iterate all elements of the codec.

See also
for_each_leaf_element, for_each_element
ddl::codec::ChildElements, cSampleCodec::tElement

Definition at line 691 of file sample_codec.h.

Member Function Documentation

◆ getCodec()

ddl::codec::Codec* getCodec ( )
overrideprivatevirtual

Get the Codec.

Returns
CodecType*

Implements cCodecLegacy< ddl::codec::Codec >.

Referenced by cSampleCodec::SetElementValue().

◆ GetElement() [1/4]

tElement GetElement ( const std::string &  strElementFullName)

Retrieves an element for the given name.

Parameters
[in]strElementFullNameThe full name of the element in point notation (i.e. "element1.child_element[4].element_value").
Returns
tElement the element
Remarks
The element is only valid as long as the codec exists.
Exceptions
throwstResult if not found.

◆ GetElement() [2/4]

tElement GetElement

Retrieves an element for the given name.

Parameters
[in]strElementFullNameThe full name of the element in point notation (i.e. "element1.child_element[4].element_value").
Returns
tElement the element
Remarks
The element is only valid as long as the decoder exists.
Exceptions
throwstResult if not found.

◆ GetElement() [3/4]

tElement GetElement ( const tCodecIndex oCodecIndex)

Retrieves an element for the codec index.

You may use a valid codec index retrieved by the cSampleCodecFactory, but no other! This is to prepare for decoding in advance:

//use a sample factory to retrieve all codec indices
cSampleCodecFactory oMyFactory("mystruct", oMyDescription);
auto oCodecIndexOfInterest = oMyFactory.GetElement("my_element_to_decode").getIndex();
//...
auto oDecoder = oMyFactory.MakeDecoderFor(pMySample);
auto oElementOfInterest = oDecoder.GetElement(oCodecIndexOfInterest);
Parameters
[in]oCodecIndexThe codec index retrieved by the used cSampleCodecFactory for this decoder.
Returns
tElement the element
Remarks
The element is only valid as long as the decoder exists.
Exceptions
throwstResult if not found.

◆ GetElement() [4/4]

tElement GetElement

Retrieves an element for the codec index.

You may use a valid codec index retrieved by the cSampleCodecFactory, but no other! This is to prepare for decoding in advance:

//use a sample factory to retrieve all codec indices
cSampleCodecFactory oMyFactory("mystruct", oMyDescription);
auto oCodecIndexOfInterest = oMyFactory.GetElement("my_element_to_decode").getIndex();
//...
auto oDecoder = oMyFactory.MakeStaticDecoderFor(pMySample);
auto oElementOfInterest = oDecoder.GetElement(oCodecIndexOfInterest);
Parameters
[in]oCodecIndexThe codec index retrieved by the used cSampleCodecFactory for this decoder.
Returns
tElement the element
Remarks
The element is only valid as long as the decoder exists.
Exceptions
throwstResult if not found.

◆ GetElementAddress() [1/3]

void* GetElementAddress ( const std::string &  strElementFullName)

Gets the elements value memory pointer into the given data for writing access.

Parameters
[in]strElementFullNameThe full name of the element in point notation (i.e. "element1.child_element[4].element_value").
Returns
The elements value memory pointer into the given data.
Exceptions
throwstResult if not found.

◆ GetElementAddress() [2/3]

void* GetElementAddress ( const tCodecIndex oCodecIndex)

Gets the elements value memory pointer into the given data for writig access.

Parameters
[in]oCodecIndexThe codec index of the element.
Returns
The elements value memory pointer into the given data.
Exceptions
throwstResult if not found.

◆ GetElementAddress() [3/3]

const void* GetElementAddress

Gets the elements value memory pointer into the given data.

Parameters
[in]oCodecIndexThe codec index of the element.
Returns
The elements value memory pointer into the given data.
Exceptions
throwstResult if not found.

◆ GetElements() [1/2]

tElements& GetElements ( )

Retrieves the elements of the codec to get element information, to get and set the values.

Returns
tElements The elements iterator container.
See also
for_each_leaf_element, for_each_element
cSampleCodec::tElement, The Codec Index and the Element Iterator

◆ GetElements() [2/2]

const tElements& GetElements

Retrieves the elements of the decoder to get element information and the values.

Returns
tElements The elements iterator container.
See also
for_each_leaf_element, for_each_element
cSampleDecoderBase::tElement, The Codec Index and the Element Iterator

◆ SetElementRawValue()

void SetElementRawValue ( const tCodecIndex oCodecIndex,
const void *  pValue,
size_t  szValueSize 
)

Sets the elements value by copy the memory from pValue.

You may use a valid codec index retrieved by the cSampleCodecFactory, but no other! This is to prepare for codec processing in advance:

//use a sample factory to retrieve all codec indices
cSampleCodecFactory oMyFactory("mystruct", oMyDescription);
auto oCodecIndexOfInterest = oMyFactory.GetElement("my_element_to_decode").getIndex();
//...
auto oCodec = oMyFactory.MakeCodecFor(pMySample);
uint32_t nValue = 123;
oCodec.SetElementValue(oCodecIndexOfInterest, &nValue, sizeof(nValue));
Parameters
[in]oCodecIndexThe codec index of the element.
[in]pValueThe value memory to copy.
[in]szValueSizeThe size of memory in pValue.
Exceptions
throwstResult if not found.

◆ SetElementStringValue()

void SetElementStringValue ( const tCodecIndex oCodecIndex,
const std::string &  strValue 
)

Sets the current value of the given element from the given string.

If this element is a enum type the enum types element name can be used in oValue. Otherwise the string value is automatically converted to the elments data type, if possible.

Parameters
[in]oCodecIndexThe index of the element.
[in]strValueThe value to set.
Exceptions
throwsstd::runtime_error if not found.

◆ SetElementValue()

void SetElementValue ( const tCodecIndex oCodecIndex,
const T &  oValue 
)
inline

Sets the elements value from the given oValue.

If this element is a enum type the enum types element name can be used in oValue if T = std::string. Otherwise the string value is automatically converted to the elments data type.

You may use a valid codec index retrieved by the cSampleCodecFactory, but no other! This is to prepare for codec processing in advance:

//use a sample factory to retrieve all codec indices
cSampleCodecFactory oMyFactory("mystruct", oMyDescription);
auto oCodecIndexOfInterest = oMyFactory.GetElement("my_element_to_decode").getIndex();
//...
auto oCodec = oMyFactory.MakeCodecFor(pMySample);
oCodec.SetElementValue(oCodecIndexOfInterest, 123);
Parameters
[in]oCodecIndexThe codec index of the element.
[in]oValueThe value of type T (supported types: all int types, bool, float, double, std::string)
Template Parameters
TThe type of oValue to set.
Exceptions
throwstResult if not found.

Definition at line 593 of file sample_codec.h.

References cSampleCodec::getCodec(), and Codec::setElementValue().

◆ SetElementVariantValue()

void SetElementVariantValue ( const tCodecIndex oCodecIndex,
const a_util::variant::Variant oValue 
)

Sets the current value of the given element from the given variant.

This will convert the given value to the elements data type!

Parameters
[in]codec_indexThe index of the element.
[in]oValueThe value to set.
Exceptions
throwsstd::runtime_error if not found.

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)