ADTF
Loading...
Searching...
No Matches
ddl::codec::CodecElement< ElementAccessType, ChildElementsType > Class Template Reference

A CodecElement to get and set values. More...

#include <codec_iterator.h>

Inherits ddl::codec::DecoderElement< ElementAccessType, ChildElementsType >.

Public Types

using factory_base_type = FactoryElement<ElementAccessType, ChildElementsType>
 factory base type
 
using base_type = DecoderElement<ElementAccessType, ChildElementsType>
 base type
 
using self_type = CodecElement<ElementAccessType, ChildElementsType>
 self type
 
using access_type = typename ElementAccessType::access_type
 
using child_elements_type = typename factory_base_type::child_elements_type
 allowed container type
 
using iterator_type = typename child_elements_type::iterator
 
using const_iterator_type = typename child_elements_type::const_iterator
 allowed const iterator type
 
- Public Types inherited from ddl::codec::DecoderElement< ElementAccessType, ChildElementsType >
using base_type = FactoryElement<ElementAccessType, ChildElementsType>
 base type
 
using self_type = DecoderElement<ElementAccessType, ChildElementsType>
 
using access_type = typename ElementAccessType::access_type
 access type from concept template
 
using child_elements_type = typename base_type::child_elements_type
 allowed container type
 
using iterator_type = typename child_elements_type::iterator
 
using const_iterator_type = typename child_elements_type::const_iterator
 allowed const iterator type
 
- Public Types inherited from ddl::codec::FactoryElement< ElementAccessType, ChildElementsType >
using self_type = FactoryElement<ElementAccessType, ChildElementsType>
 self type
 
using access_type = typename ElementAccessType::access_type
 access type
 
using child_elements_type = ChildElementsType
 allowed container type
 
using iterator_type = typename child_elements_type::iterator
 
using const_iterator_type = typename child_elements_type::const_iterator
 allowed const iterator type
 

Public Member Functions

 CodecElement ()=delete
 CTOR.
 
template<typename T>
void setValue (const T &value)
 Sets the value from value of type T.
 
void setVariantValue (const a_util::variant::Variant &value)
 Sets the value from value as variant.
 
void setStringValue (const std::string &value)
 Sets the value from value as string.
 
void setRawValue (const void *value, size_t value_size)
 Set the value by copying from a value buffer.
 
void reset (bool zero_value_of_known_type=false)
 Reset the elements value to their default values, constant values defined in the data definition or zero if zero_value is set.
 
void * getAddress ()
 Get the address (with writing access)
 
child_elements_typegetChildElements ()
 Gets an reference to the child elements.
 
self_type getChildElement (std::string_view path) const
 Get a dedicated ChildElement by name.
 
self_type getChildElement (std::string_view name)
 Get a dedicated ChildElement by name.
 
self_type getArrayElement (size_t array_pos=0) const
 Get the array element of the given array_pos.
 
self_type getArrayElement (size_t array_pos=0)
 Get the array element of the given array_pos.
 
const void * getAddress () const
 Get the address of the element.
 
const child_elements_typegetChildElements () const
 Get the ChildElements.
 
- Public Member Functions inherited from ddl::codec::DecoderElement< ElementAccessType, ChildElementsType >
 DecoderElement ()=delete
 CTOR.
 
template<typename T>
getValue () const
 Get the value as type T.
 
a_util::variant::Variant getVariantValue () const
 Get the value as variant.
 
std::string getStringValue () const
 Get the value as string.
 
void getRawValue (void *value, size_t value_size) const
 Get the as copy to the value buffer.
 
const void * getAddress () const
 Get the address of the element.
 
self_type getChildElement (std::string_view path) const
 Get the child element with the given name.
 
self_type getArrayElement (size_t array_pos=0) const
 Get the array element of the given array_pos.
 
- Public Member Functions inherited from ddl::codec::FactoryElement< ElementAccessType, ChildElementsType >
 FactoryElement ()=delete
 no CTOR
 
 FactoryElement (FactoryElement &&other)
 move CTOR
 
FactoryElementoperator= (FactoryElement &&other)
 copy assignment operator
 
 FactoryElement (const FactoryElement &other)
 copy CTOR
 
FactoryElementoperator= (const FactoryElement &other)
 move assignment operator
 
 ~FactoryElement ()=default
 DTOR.
 
const CodecIndexgetIndex () const
 Get the codec index of the element.
 
size_t getArraySize () const
 Get the array size.
 
ddl::codec::ElementType getType () const
 Get the type of the element.
 
std::string getFullName () const
 Get the full name of the element. If the element is an array you get the elements array name representation: "main_element.element_name[0]" or main_element.element_name[1] ... etc. If the element is not an array you get the elements name representation: "main_element.element_name".
 
std::string getName () const
 Get the name of the element If the element is an array you get the elements array name representation: "element_name[0]" or element_name[1] ... etc. If the element is not an array you get the elements name representation: "element_name".
 
std::string getBaseName () const
 Get the base name of the element. If the element is an array you get the elements base name representation : "element_name" for each array element. If the element is not an array you get the elements name representation is also the base name representation: "element_name" .
 
bool isArray () const
 Get array information.
 
bool hasChildren () const
 Get children information.
 
const child_elements_typegetChildElements () const
 Get the ChildElements.
 
self_type getChildElement (std::string_view path) const
 Get the child element with the given name.
 
self_type getArrayElement (size_t array_pos=0) const
 Get the array element of the given array_pos.
 
bool isValid () const
 Get validation indormation.
 

Public Attributes

friend child_elements_type
 friend declaration for child_elements_type
 
friend iterator_type
 friend declaration for iterator_type
 
friend const_iterator_type
 friend declaration for const_iterator_type
 
friend access_type
 friend declaration for access_type
 
friend base_type
 friend declaration for base_type
 
friend factory_base_type
 friend declaration for factory_base_type
 
- Public Attributes inherited from ddl::codec::DecoderElement< ElementAccessType, ChildElementsType >
friend child_elements_type
 friend declaration for child_elements_type
 
friend iterator_type
 friend declaration for iterator_type
 
friend const_iterator_type
 friend declaration for const_iterator_type
 
friend access_type
 friend declaration for access_type
 
friend base_type
 friend declaration for base_type
 
friend CodecElement< ElementAccessType, ChildElementsType >
 friend declaration for CodecElement
 
- Public Attributes inherited from ddl::codec::FactoryElement< ElementAccessType, ChildElementsType >
friend child_elements_type
 friend declaration for child_elements_type
 
friend iterator_type
 friend declaration for iterator_type
 
friend const_iterator_type
 friend declaration for child_elements_type
 
friend access_type
 friend declaration for access_type
 
friend DecoderElement< ElementAccessType, ChildElementsType >
 friend declaration for DecoderElement
 
friend CodecElement< ElementAccessType, ChildElementsType >
 friend declaration for CodecElement
 

Detailed Description

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
class ddl::codec::CodecElement< ElementAccessType, ChildElementsType >

A CodecElement to get and set values.

Template Parameters
ElementAccessTypeThe element access concept type. (see concept templates CodecElementAccess)

Member Typedef Documentation

◆ access_type

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
using ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::access_type = typename ElementAccessType::access_type

access type from the concept

◆ iterator_type

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
using ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::iterator_type = typename child_elements_type::iterator

allowed iterator type

Member Function Documentation

◆ getAddress() [1/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
void * ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::getAddress ( )
inline

Get the address (with writing access)

Returns
void*

◆ getAddress() [2/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
const void * ddl::codec::DecoderElement< ElementAccessType, ChildElementsType >::getAddress ( ) const
inline

Get the address of the element.

Returns
const void*

◆ getArrayElement() [1/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
self_type ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::getArrayElement ( size_t array_pos = 0)
inline

Get the array element of the given array_pos.

Parameters
array_posThe array pos of the element to retrieve
Returns
self_type

◆ getArrayElement() [2/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
self_type ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::getArrayElement ( size_t array_pos = 0) const
inline

Get the array element of the given array_pos.

Parameters
array_posThe array pos of the element to retrieve
Returns
self_type

◆ getChildElement() [1/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
self_type ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::getChildElement ( std::string_view name)
inline

Get a dedicated ChildElement by name.

Parameters
nameThe name if point notation.
Returns
self_type
Exceptions
std::runtime_errorif name is not valid or not found

◆ getChildElement() [2/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
self_type ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::getChildElement ( std::string_view path) const
inline

Get a dedicated ChildElement by name.

Parameters
pathThe name if point notation.
Returns
self_type
Exceptions
std::runtime_errorif name is not valid or not found

◆ getChildElements() [1/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
child_elements_type & ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::getChildElements ( )
inline

Gets an reference to the child elements.

Returns
child_elements_type&

◆ getChildElements() [2/2]

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
const child_elements_type & ddl::codec::FactoryElement< ElementAccessType, ChildElementsType >::getChildElements ( ) const
inline

Get the ChildElements.

Returns
child_elements_type
Exceptions
std::runtime_errorif index is invalid

◆ reset()

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
void ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::reset ( bool zero_value_of_known_type = false)
inline

Reset the elements value to their default values, constant values defined in the data definition or zero if zero_value is set.

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

◆ setRawValue()

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
void ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::setRawValue ( const void * value,
size_t value_size )
inline

Set the value by copying from a value buffer.

Parameters
[in]valueThe value buffer
[in]value_sizethe size of the value buffer in bytes.
See also
ddl::codec::StaticCodec::setElementRawValue

◆ setStringValue()

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
void ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::setStringValue ( const std::string & value)
inline

Sets the value from value as string.

Parameters
[in]valueThe value to set as string. string will be converted to the elements type.
See also
ddl::codec::StaticCodec::setElementStringValue

◆ setValue()

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
template<typename T>
void ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::setValue ( const T & value)
inline

Sets the value from value of type T.

Template Parameters
TType of the value
Parameters
[in]valueThe value in type T
Remarks
for T = std::string the value can be set as valid element name in case of enum type otherwise the string is converted
See also
StaticCodec::setElementValue

◆ setVariantValue()

template<typename ElementAccessType, typename ChildElementsType = ChildElements<ElementAccessType>>
void ddl::codec::CodecElement< ElementAccessType, ChildElementsType >::setVariantValue ( const a_util::variant::Variant & value)
inline

Sets the value from value as variant.

Parameters
[in]valueThe value to set as variant
See also
ddl::codec::StaticCodec::setElementVariantValue

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