ADTF
Loading...
Searching...
No Matches
adtf::mediadescription::cStaticSampleCodec Class Reference

#include <sample_codec.h>

Inherits adtf::mediadescription::osborn::cSampleDecoderBase, and adtf::mediadescription::osborn::adtf_ddl_access::cCodecLegacy< ddl::codec::StaticCodec >.

Public Types

typedef ddl::codec::CodecElement< sample_codec_access< cStaticSampleCodec > > tElement
 
typedef ddl::codec::ChildElements< sample_codec_access< cStaticSampleCodec > > tElements
 
- Public Types inherited from adtf::mediadescription::osborn::cSampleDecoderBase
typedef ddl::codec::DecoderElement< sample_decoder_access< const cSampleDecoderBase > > tElement
 
typedef ddl::codec::ChildElements< sample_decoder_access< const cSampleDecoderBase > > tElements
 
- Public Types inherited from adtf::mediadescription::osborn::adtf_ddl_access::cDecoderLegacy
typedef ddl::StructElement DefinedStructElementType
 type definition for the old access_element API.
 

Public Member Functions

 cStaticSampleCodec ()
 
 cStaticSampleCodec (cStaticSampleCodec &&)
 
cStaticSampleCodecoperator= (cStaticSampleCodec &&)
 
tElement GetElement (const tCodecIndex &oCodecIndex)
 Get a single element of the codec. You may use a valid codec index retrieved by the cSampleCodecFactory for this codec, but no other! This is to prepare for decoding in advance:
 
tElement GetElement (std::string_view strElementFullName)
 
tElement GetElement (const tCodecIndex &oCodecIndex) const
 
tElement GetElement (std::string_view strElementFullName) const
 
tResult GetElement (tCodecLeafIndex nElementLeafIndex, const ddl::StructElement *&pElement) const
 Get the Element StructElement information.
 
tElement GetChildElement (const tCodecIndex &oCodecIndex, std::string_view strElementPath)
 
tElementsGetElements ()
 
const tElementsGetElements () const
 
template<typename T>
void SetElementValue (const tCodecIndex &oCodecIndex, const T &oValue)
 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:
 
template<typename T>
void SetElementValue (const tLeafCodecIndex &oLeafCodecIndex, const T &oValue)
 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:
 
void SetElementVariantValue (const tCodecIndex &oCodecIndex, const a_util::variant::Variant &oValue)
 
void SetElementStringValue (const tCodecIndex &oCodecIndex, const std::string &strValue)
 
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:
 
void * GetElementAddress (const tCodecIndex &oCodecIndex)
 Gets the elements value memory pointer into the given data for writing access.
 
void * GetElementAddress (std::string_view strElementFullName)
 Gets the elements value memory pointer into the given data for writing access.
 
const void * GetElementAddress (const tCodecIndex &oCodecIndex) const
 Gets the elements value memory pointer into the given data.
 
const void * GetElementAddress (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element StructElement information.
 
const void * GetData () const
 Get the current data pointer.
 
void * GetData ()
 Get the current data pointer for writing access.
 
size_t GetDataSize () const
 Get the current data size.
 
- Public Member Functions inherited from adtf::mediadescription::osborn::cSampleDecoderBase
 cSampleDecoderBase ()
 
 cSampleDecoderBase (cSampleDecoderBase &&)
 
cSampleDecoderBaseoperator= (cSampleDecoderBase &&)
 
tResult IsValid () const
 
tElement GetElement (const tCodecIndex &oCodecIndex) const
 
tElement GetElement (std::string_view strElementFullName) const
 
tElement GetChildElement (const tCodecIndex &oCodecIndex, std::string_view strElementPath) const
 
const tElementsGetElements () const
 
size_t GetElementChildCount (const tCodecIndex &oCodecIndex) const
 
std::string GetElementFullName (const tCodecIndex &oCodecIndex) const
 Retrieves the full name of the element within its main structure.
 
std::string GetElementName (const tCodecIndex &oCodecIndex) const
 Retrieves the name of the element within its structured element.
 
const std::string & GetElementBaseName (const tCodecIndex &oCodecIndex) const
 Retrieves the base name of the element within its structured element.
 
size_t GetStaticBufferSize () const
 Gets the static buffer size in bytes for the main structure.
 
size_t GetStaticBufferSize (ddl::tDataRepresentation eRep) const
 Gets the static buffer size in bytes for the main structure.
 
ddl::tDataRepresentation GetRepresentation () const
 
template<typename T>
GetElementValue (const tCodecIndex &oCodecIndex) const
 Gets the elements value as value of type T. You may use a valid codec index retrieved by the cSampleCodecFactory, but no other! This is to prepare for decoding in advance:
 
template<typename T>
GetElementValue (const penguin::tLeafCodecIndex &oLeafCodecIndex) const
 Gets the elements value as value of type T. You may use a valid codec index retrieved by the cSampleCodecFactory, but no other! This is to prepare for decoding in advance:
 
a_util::variant::Variant GetElementVariantValue (const tCodecIndex &oCodecIndex) const
 
void GetElementVariantValue (const tCodecIndex &oCodecIndex, a_util::variant::Variant &oValue) const
 
std::string GetElementStringValue (const tCodecIndex &oCodecIndex) const
 
void GetElementRawValue (const tCodecIndex &oCodecIndex, void *pValue, size_t szValueSize) const
 Copies the elements value to the given memory pointer in pValue.
 
const void * GetElementAddress (const tCodecIndex &oCodecIndex) const
 Gets the elements value memory pointer into the given data.
 
void Resolve (tCodecIndex &oCodecIndex) const
 
tResult GetElement (tCodecLeafIndex nElementLeafIndex, const ddl::StructElement *&pElement) const
 Get the Element StructElement information.
 
adtf_util::cVariant GetElementValue (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element Value.
 
tResult GetElementValue (tCodecLeafIndex nElementLeafIndex, adtf_util::cVariant &oValue) const
 Legacy: Get the Element Value.
 
tResult GetElementValue (const char *strElementName, adtf_util::cVariant &oValue) const
 Legacy: Get the Element Value.
 
tResult GetElementValue (tCodecLeafIndex nElementLeafIndex, void *pValue) const
 Legacy: Copies the Element Value memory into the memory pointer. Keep in MIND this function is UNSAFE in case of value memory is biger than the given one.
 
tResult GetElementValue (const char *strElementName, void *pValue) const
 Legacy: Get the Element Value pointer.
 
const void * GetElementAddress (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element StructElement information.
 
tCodecIndex Resolve (tCodecLeafIndex nElementLeafIndex) const
 
- Public Member Functions inherited from adtf::mediadescription::osborn::adtf_ddl_access::cDecoderLegacy
tCodecIndex Resolve (tCodecLeafIndex nElementLeafIndex) const
 
adtf_util::cVariant GetElementValue (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element Value.
 
tResult GetElementValue (tCodecLeafIndex nElementLeafIndex, adtf_util::cVariant &oValue) const
 Legacy: Get the Element Value.
 
tResult GetElementValue (const char *strElementName, adtf_util::cVariant &oValue) const
 Legacy: Get the Element Value.
 
tResult GetElementValue (tCodecLeafIndex nElementLeafIndex, void *pValue) const
 Legacy: Copies the Element Value memory into the memory pointer. Keep in MIND this function is UNSAFE in case of value memory is biger than the given one.
 
tResult GetElementValue (const char *strElementName, void *pValue) const
 Legacy: Get the Element Value pointer.
 
adtf_util::cString GetElementValueString (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element Value as string (resolved to the enum element name if is enum type)
 
tResult GetElement (tCodecLeafIndex nElementLeafIndex, const ddl::StructElement *&pElement) const
 Get the Element StructElement information.
 
const void * GetElementAddress (tCodecLeafIndex nElementLeafIndex) const
 Legacy: Get the Element StructElement information.
 
size_t GetElementCount () const
 Legacy: Get the Element Leaf count.
 
- Public Member Functions inherited from adtf::mediadescription::osborn::adtf_ddl_access::cCodecLegacy< ddl::codec::StaticCodec >
tResult SetElementValue (tCodecLeafIndex nElementLeafIndex, const adtf_util::cVariant &oValue)
 Legacy: Set the Element Value.
 
tResult SetElementValue (const char *strElementName, const adtf_util::cVariant &oValue)
 Legacy: Set the Element Value.
 
void * GetElementAddress (tCodecLeafIndex nElementLeafIndex)
 Legacy:Get the Element Address object.
 

Friends

class cSampleCodecFactory
 

Additional Inherited Members

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

Detailed Description

Codec for samples with static data content.

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
ddl::codec::CodecElement

◆ tElements

Constructor & Destructor Documentation

◆ cStaticSampleCodec() [1/2]

adtf::mediadescription::osborn::cStaticSampleCodec::cStaticSampleCodec ( )

Default constructor

◆ cStaticSampleCodec() [2/2]

adtf::mediadescription::osborn::cStaticSampleCodec::cStaticSampleCodec ( cStaticSampleCodec && )

Move constructor

Member Function Documentation

◆ GetChildElement()

tElement adtf::mediadescription::osborn::cStaticSampleCodec::GetChildElement ( const tCodecIndex & oCodecIndex,
std::string_view strElementPath )

Retrieves an element for the given name.

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

◆ GetData() [1/2]

void * adtf::mediadescription::osborn::cStaticSampleCodec::GetData ( )
inline

Get the current data pointer for writing access.

Returns
void*

◆ GetData() [2/2]

const void * adtf::mediadescription::osborn::cStaticSampleCodec::GetData ( ) const
inline

Get the current data pointer.

Returns
const void*

◆ GetDataSize()

size_t adtf::mediadescription::osborn::cStaticSampleCodec::GetDataSize ( ) const
inline

Get the current data size.

Returns
const void*

◆ GetElement() [1/5]

tElement adtf::mediadescription::osborn::cStaticSampleCodec::GetElement ( const tCodecIndex & oCodecIndex)

Get a single element of the codec. You may use a valid codec index retrieved by the cSampleCodecFactory for this codec, 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 oCodec = oMyFactory.MakeStaticCodecFor(pMySample);
auto oElementOfInterest = oCodec.GetElement(oCodecIndexOfInterest);
Parameters
[in]oCodecIndexThe codec index of the element.
Returns
tElement the element for the given codec index
Remarks
The element is only valid as long as the codec exists.
Exceptions
throwstResult if not found.

◆ GetElement() [2/5]

tElement adtf::mediadescription::osborn::cSampleDecoderBase::GetElement ( const tCodecIndex & oCodecIndex) const

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.

◆ GetElement() [3/5]

tElement adtf::mediadescription::osborn::cStaticSampleCodec::GetElement ( std::string_view 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() [4/5]

tElement adtf::mediadescription::osborn::cSampleDecoderBase::GetElement ( std::string_view strElementFullName) const

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() [5/5]

tResult adtf::mediadescription::osborn::adtf_ddl_access::cDecoderLegacy::GetElement ( tCodecLeafIndex nElementLeafIndex,
const ddl::StructElement *& pElement ) const

Get the Element StructElement information.

Parameters
nElementLeafIndexThe leaf index (between 0 and GetElementCount())
pElementThe legacy StructElement
Returns
tResult
Remarks
This function does not throw! DO NOT STORE and reuse after another GetElement call!
Deprecated
This is only provided for legacy reason. Use adtf::mediadescription::cSampleDecoder::GetElement instead

◆ GetElementAddress() [1/4]

void * adtf::mediadescription::osborn::cStaticSampleCodec::GetElementAddress ( const tCodecIndex & oCodecIndex)

Gets the elements value memory pointer into the given data for writing 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() [2/4]

const void * adtf::mediadescription::osborn::cSampleDecoderBase::GetElementAddress ( const tCodecIndex & oCodecIndex) const

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.

◆ GetElementAddress() [3/4]

void * adtf::mediadescription::osborn::cStaticSampleCodec::GetElementAddress ( std::string_view 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() [4/4]

const void * adtf::mediadescription::osborn::adtf_ddl_access::cDecoderLegacy::GetElementAddress ( tCodecLeafIndex nElementLeafIndex) const

Legacy: Get the Element StructElement information.

Parameters
nElementLeafIndexThe leaf index (between 0 and GetElementCount())
Returns
tResult
Remarks
This function does not throw! DO NOT STORE and reuse after another GetElement call!
Deprecated
This is only provided for legacy reason. Use adtf::mediadescription::cSampleDecoder::GetElement instead

◆ GetElements() [1/2]

tElements & adtf::mediadescription::osborn::cStaticSampleCodec::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
cStaticSampleCodec::tElement

◆ GetElements() [2/2]

const tElements & adtf::mediadescription::osborn::cSampleDecoderBase::GetElements ( ) const

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
cSampleDecoderBase::tElement

◆ operator=()

cStaticSampleCodec & adtf::mediadescription::osborn::cStaticSampleCodec::operator= ( cStaticSampleCodec && )

Move assignment operator

◆ SetElementRawValue()

void adtf::mediadescription::osborn::cStaticSampleCodec::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.MakeStaticCodecFor(pMySample);
uint32_t oValue = 123;
oCodec.SetElementRawValue(oCodecIndexOfInterest, &oValue, sizeof(oValue));
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 adtf::mediadescription::osborn::cStaticSampleCodec::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() [1/2]

template<typename T>
void adtf::mediadescription::osborn::cStaticSampleCodec::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.MakeStaticCodecFor(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.

◆ SetElementValue() [2/2]

template<typename T>
void adtf::mediadescription::osborn::cStaticSampleCodec::SetElementValue ( const tLeafCodecIndex & oLeafCodecIndex,
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 oLeafCodecIndexOfInterest = tLeafCodecIndex(oMyFactory.GetElement("my_element_to_decode").getIndex(),
tDataRepresentation::Deserialized);
//...
auto oCodec = oMyFactory.MakeStaticCodecFor(pMySample);
oCodec.SetElementValue(oLeafCodecIndexOfInterest, 123);
ddl::codec::LeafCodecIndex tLeafCodecIndex
redefitnion for a ddl::codec::LeafCodecIndex
Definition leaf_sample_codec_access.h:21
Parameters
[in]oLeafCodecIndexThe leaf codec index of the element.
[in]oValueThe value of type T (supported types: all int types, bool, float, double)
Template Parameters
TThe type of oValue to set.
Remarks
Strings are not supported!
Exceptions
throwstResult if not found.

◆ SetElementVariantValue()

void adtf::mediadescription::osborn::cStaticSampleCodec::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]oCodecIndexThe index of the element.
[in]oValueThe value to set.
Exceptions
throwsstd::runtime_error if not found.

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