ADTF  3.18.2
StaticCodecfinal

Codec for static structures defined by a DataDefinition definition. More...

Inheritance diagram for StaticCodec:
[legend]

Public Types

typedef CodecElement< CodecElementAccess< StaticCodec > > Element
 Static codec element.
 
typedef ChildElements< CodecElementAccess< StaticCodec > > Elements
 Iterator container to iterate all elements of the static decoder. More...
 
- Public Types inherited from StaticDecoder
typedef DecoderElement< DecoderElementAccess< const StaticDecoder > > Element
 Static decoder element.
 
typedef ChildElements< DecoderElementAccess< const StaticDecoder > > Elements
 Iterator container to iterate all elements of the static decoder. More...
 

Public Member Functions

 StaticCodec ()
 Default constructor.
 
 StaticCodec (const StaticCodec &)=delete
 Noncopyable.
 
StaticCodecoperator= (const StaticCodec &)=delete
 Noncopyable.
 
 StaticCodec (StaticCodec &&)
 Move constructor.
 
StaticCodecoperator= (StaticCodec &&)
 Move assignment operator.
 
Element getElement (const CodecIndex &codec_index)
 Retrieves an element instance based on the codec index of that element. More...
 
Element getElement (const std::string &full_element_name)
 Retrieves an element instance based on the full name of the element. More...
 
ElementsgetElements ()
 Retrieves the elements of the static codec to get element information. More...
 
template<typename T >
void setElementValue (const CodecIndex &codec_index, const T &value)
 Sets the current value of the given element from given value in type T. More...
 
template<typename T >
void setElementValue (const LeafCodecIndex &leaf_codec_index, const T &value)
 Sets the current value of the given element from given value in type T. More...
 
void setElementVariantValue (const CodecIndex &codec_index, const a_util::variant::Variant &value)
 Sets the current value of the given element from the given variant. More...
 
void setElementStringValue (const CodecIndex &codec_index, const std::string &value)
 Sets the current value of the given element from the given string. More...
 
void setElementRawValue (const CodecIndex &codec_index, const void *value, size_t value_size)
 Sets the current value of the given element by copying its data from the passed-in location. More...
 
void * getElementAddress (const CodecIndex &codec_index)
 
void resetValues (bool zero_values=false)
 Sets all elements to their default values, constant values defined in the data definition or zero if zero_values is set. More...
 
void * getData () noexcept
 Get the current set data. More...
 
Element getElement (const CodecIndex &codec_index) const
 Retrieves an element instance based on the codec index of that element. More...
 
Element getElement (const std::string &full_element_name) const
 Retrieves an element instance based on the full name of the element. More...
 
a_util::result::Result getElement (size_t leaf_index, const ddl::StructElement *&legacy_struct_element) const
 Returns the StructElement of the element with given leaf index. More...
 
const void * getElementAddress (const CodecIndex &index) const
 
const ElementsgetElements () const
 Retrieves the elements of the static decoder to get element information. More...
 
const void * getData () const noexcept
 Get the current set data. More...
 
- Public Member Functions inherited from StaticDecoder
 ~StaticDecoder ()=default
 DTOR.
 
 StaticDecoder ()
 Default constructor.
 
 StaticDecoder (const StaticDecoder &)=delete
 Noncopyable.
 
StaticDecoderoperator= (const StaticDecoder &)=delete
 Noncopyable.
 
 StaticDecoder (StaticDecoder &&)
 Move constructor.
 
StaticDecoderoperator= (StaticDecoder &&)
 Move assignment operator.
 
virtual a_util::result::Result isValid () const
 
Element getElement (const CodecIndex &codec_index) const
 Retrieves an element instance based on the codec index of that element. More...
 
Element getElement (const std::string &full_element_name) const
 Retrieves an element instance based on the full name of the element. More...
 
const ElementsgetElements () const
 Retrieves the elements of the static decoder to get element information. More...
 
size_t getElementChildCount (const CodecIndex &codec_index=CodecIndex()) const
 Retrieves the amount of child elements for the given codec index. More...
 
std::string getElementFullName (const CodecIndex &codec_index) const
 Retrieves the full name of the element within its main structure. More...
 
std::string getElementName (const CodecIndex &codec_index) const
 Retrieves the name of the element within its structured element. More...
 
const std::string & getElementBaseName (const CodecIndex &codec_index) const
 Retrieves the base name of the element within its structured element. More...
 
template<typename T >
getElementValue (const CodecIndex &codec_index) const
 Returns the current value of the given element as a T if supported. More...
 
template<typename T >
getElementValue (const LeafCodecIndex &leaf_codec_index) const
 Returns the current value of the given element as a T if supported. More...
 
a_util::variant::Variant getElementVariantValue (const CodecIndex &codec_index) const
 Returns the current value of the given element as a variant. More...
 
void getElementVariantValue (const CodecIndex &codec_index, a_util::variant::Variant &value) const
 Returns the current value of the given element as a variant. More...
 
std::string getElementStringValue (const CodecIndex &codec_index) const
 Returns the current value of the given element as a string. More...
 
void getElementRawValue (const CodecIndex &index, void *value, size_t value_size) const
 Returns the current value of the given element as a variant. More...
 
const void * getElementAddress (const CodecIndex &index) const
 
size_t getStaticBufferSize () const
 Gets the static buffer size in bytes for the main structure. More...
 
size_t getStaticBufferSize (DataRepresentation rep) const
 Gets the static buffer size in bytes for the main structure. More...
 
DataRepresentation getRepresentation () const
 Returns the current data representation the decoder decodes from. More...
 
CodecIndex resolve (size_t leaf_index) const
 
size_t getElementCount () const
 is the leaf count More...
 
a_util::result::Result getElement (size_t leaf_index, const ddl::StructElement *&legacy_struct_element) const
 Returns the StructElement of the element with given leaf index. More...
 
void resolve (CodecIndex &codec_index) const
 The codec index will be resolved for fast access (layout will be set) More...
 
const void * getData () const noexcept
 Get the current set data. More...
 
size_t getDataSize () const noexcept
 Get the current size (in bytes) of the data. More...
 

Private Member Functions

 StaticCodec (std::shared_ptr< const StructAccess > codec_access, void *data, size_t data_size, DataRepresentation representation)
 For internal use only.
 

Private Attributes

Element _first_element
 

Additional Inherited Members

- Protected Member Functions inherited from StaticDecoder
 StaticDecoder (std::shared_ptr< const StructAccess > codec_access, const void *data, size_t data_size, DataRepresentation representation)
 For internal use only.
 
- Protected Attributes inherited from StaticDecoder
std::shared_ptr< const StructAccess > _codec_access
 For internal use only.
 
const void * _data = nullptr
 For internal use only.
 
size_t _data_size = 0
 For internal use only.
 
const ddl::codec::ElementAccessor * _element_accessor
 For internal use only.
 

Detailed Description

Codec for static structures defined by a DataDefinition definition.

Definition at line 304 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/ddl/codec/static_codec.h.

Member Typedef Documentation

◆ Elements

Member Function Documentation

◆ getData() [1/2]

const void* getData
noexcept

Get the current set data.

Remarks
For performance issues this will not check any validity!
Returns
const void* The data pointer

◆ getData() [2/2]

void* getData ( )
noexcept

Get the current set data.

Remarks
For performance issues this will not check any validity!
Returns
void* The data pointer

◆ getElement() [1/5]

Element getElement ( const CodecIndex codec_index)

Retrieves an element instance based on the codec index of that element.

Parameters
[in]codec_indexThe codec index.
Returns
The Codec Index of the CodecElement.
Remarks
The element is only valid as long as the static codec exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElement() [2/5]

Element getElement

Retrieves an element instance based on the codec index of that element.

Parameters
[in]codec_indexThe codec index.
Returns
The Codec Index of the DecoderElement.
Remarks
The element is only valid as long as the static decoder exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElement() [3/5]

Element getElement ( const std::string &  full_element_name)

Retrieves an element instance based on the full name of the element.

Parameters
[in]full_element_nameThe full name of the element in point notation (i.e. "element1.child_element[4].element_value").

By using an empty string the deserialized decoding information within CodecIndex will retrieve the buffers first address and whole buffersize. By refering an array without dedicated array index position the deserialized decoding information within CodecIndex will be set to the arrays first address and the whole array size. By refering an structured value (not a leaf value) the deserialized decoding information within CodecIndex will be set to the structs first address and the whole struct size.

Returns
The Codec Index of the CodecElement.
Remarks
The element is only valid as long as the static codec exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElement() [4/5]

Element getElement

Retrieves an element instance based on the full name of the element.

Parameters
[in]full_element_nameThe full name of the element in point notation (i.e. "element1.child_element[4].element_value").

By using an empty string the deserialized decoding information within CodecIndex will retrieve the buffers first address and whole buffersize. By refering an array without dedicated array index position the deserialized decoding information within CodecIndex will be set to the arrays first address and the whole array size. By refering an structured value (not a leaf value) the deserialized decoding information within CodecIndex will be set to the structs first address and the whole struct size.

Returns
The Codec Index of the DecoderElement.
Remarks
The element is only valid as long as the static decoder exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElement() [5/5]

Returns the StructElement of the element with given leaf index.

Parameters
[in]leaf_indexThe leaf index of the element.
[out]legacy_struct_elementthe struct element legacy description.
Returns
The amount of static elements contained in the handled structure.
Remarks
This is for legacy access only!

◆ getElementAddress() [1/2]

void* getElementAddress ( const CodecIndex codec_index)
Parameters
[in]codec_indexThe index of the element.
Returns
A pointer to the element
Exceptions
throwsstd::runtime_error if not found.

◆ getElementAddress() [2/2]

const void* getElementAddress
Parameters
[in]indexThe index of the element.
Returns
A pointer to the element or nullptr in case of an error.

◆ getElements() [1/2]

Elements& getElements ( )

Retrieves the elements of the static codec to get element information.

Returns
Elements The elements iterator container.
See also
forEachLeafElement, forEachElement, StaticCodec::Element, CodecIndex

◆ getElements() [2/2]

const Elements& getElements

Retrieves the elements of the static decoder to get element information.

Returns
Elements The elements iterator container.
See also
forEachLeafElement, forEachElement, StaticDecoder::Element, CodecIndex

◆ resetValues()

void resetValues ( bool  zero_values = false)

Sets all elements to their default values, constant values defined in the data definition or zero if zero_values is set.

Parameters
[in]zero_valuesset the value to 0 if no constant or default value set in data definition.

◆ setElementRawValue()

void setElementRawValue ( const CodecIndex codec_index,
const void *  value,
size_t  value_size 
)

Sets the current value of the given element by copying its data from the passed-in location.

Parameters
[in]codec_indexThe codec index of the element.
[in]valueThe location where the data should be copied from.
[in]value_sizeSize of the memory in value (if set to 0: unsafe usage of value without size check)
Exceptions
throwsstd::runtime_error if not found or value_size is lower then elements value memory to copy

◆ setElementStringValue()

void setElementStringValue ( const CodecIndex codec_index,
const std::string &  value 
)

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

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

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

◆ setElementValue() [1/2]

void setElementValue ( const CodecIndex codec_index,
const T &  value 
)
inline

Sets the current value of the given element from given value in type T.

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

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

Definition at line 385 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/ddl/codec/static_codec.h.

References ValueSetterSelect< CodecType, ValueType, is_supported_leaf_type >::setValue().

◆ setElementValue() [2/2]

void setElementValue ( const LeafCodecIndex leaf_codec_index,
const T &  value 
)
inline

Sets the current value of the given element from given value in type T.

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

Parameters
[in]leaf_codec_indexThe leaf codec index of the element.
[in]valueThe value to set.
Template Parameters
TType of the value to set
Exceptions
std::runtime_errorif there is no valid conversion or the given leaf_codec_index is invalid

Definition at line 399 of file workspace/conan/dev_essential/1.3.3/dw/stable/package/37682420cd166e229516a41c8d6a139a0b13e1e1/include/ddl/codec/static_codec.h.

References StaticDecoder::getData(), StaticDecoder::getDataSize(), LeafCodecIndex::getLayout(), and LeafValueSetter< ValueType >::setValue().

◆ setElementVariantValue()

void setElementVariantValue ( const CodecIndex codec_index,
const a_util::variant::Variant value 
)

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

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

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