ADTF  3.18.2
CodecFactory

Factory class for ddl codecs. More...

Public Types

typedef FactoryElement< FactoryElementAccess< const CodecFactory > > Element
 Type of a single factory element.
 
typedef ChildElements< FactoryElementAccess< const CodecFactory > > Elements
 Iterator container to iterate all elements of the factory. More...
 

Public Member Functions

 CodecFactory ()
 Empty constructor. More...
 
 CodecFactory (const CodecFactory &)
 copy CTOR
 
CodecFactoryoperator= (const CodecFactory &)
 copy assignment operator More...
 
 CodecFactory (CodecFactory &&)
 move CTOR
 
CodecFactoryoperator= (CodecFactory &&)
 move assignment operator More...
 
 ~CodecFactory ()=default
 Default dtor.
 
 CodecFactory (const std::string &struct_name, const std::string &dd_string)
 Constructor that take a DataDefinition string for initialization. More...
 
 CodecFactory (const ddl::dd::StructType &struct_type, const dd::DataDefinition &dd)
 Constructor that uses an OO-DataDefinition struct for initialization. More...
 
 CodecFactory (const DDStructure &dd_struct)
 Constructor that uses an OO-DataDefinition struct for initialization. More...
 
 CodecFactory (const ddl::dd::StructTypeAccess &struct_type_access)
 Constructor that uses an StructTypeAccess for initialization. More...
 
a_util::result::Result isValid () const
 Check if the factory is in a valid state. More...
 
StaticDecoder makeStaticDecoderFor (const void *data, size_t data_size, DataRepresentation rep=deserialized) const
 Creates a static decoder for the given data. More...
 
StaticCodec makeStaticCodecFor (void *data, size_t data_size, DataRepresentation rep=deserialized) const
 Creates a static codec for the given data. More...
 
Decoder makeDecoderFor (const void *data, size_t data_size, DataRepresentation rep=deserialized) const
 Creates a decoder for the given data. More...
 
Codec makeCodecFor (void *data, size_t data_size, DataRepresentation rep=deserialized) const
 Creates a codec for the given 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...
 
const ElementsgetElements () const
 Retrieves the elements of the factory 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...
 
size_t getStaticBufferSize (DataRepresentation rep=deserialized) const
 Gets the static buffer size in bytes for the structure. More...
 
void resolve (CodecIndex &codec_index) const
 The codec index will be resolved for fast access. More...
 
CodecIndex resolve (size_t leaf_index) const
 Legacy: Resolves given the leaf index to a codec index. More...
 
size_t getStaticElementCount () const
 Legacy: Returns the amount of static (leaf) elements. More...
 
a_util::result::Result getStaticElement (size_t leaf_index, const ddl::StructElement *&legacy_struct_element) const
 Legacy: Returns the StructElement of the element with given leaf index. More...
 

Private Attributes

std::shared_ptr< const StructAccess > _codec_access
 For internal use only.
 
a_util::result::Result _constructor_result
 For internal use only.
 
Element _first_element
 For internal use only.
 
ddl::access_element::StructElementLegacy< const CodecFactory_legacy_element
 For internal use only.
 

Detailed Description

Member Typedef Documentation

◆ Elements

Constructor & Destructor Documentation

◆ CodecFactory() [1/5]

Empty constructor.

This exists to enable uninitialized member variables of this type that are move-assigned later on.

◆ CodecFactory() [2/5]

CodecFactory ( const std::string &  struct_name,
const std::string &  dd_string 
)

Constructor that take a DataDefinition string for initialization.

Parameters
[in]struct_nameThe name of the struct for which codecs should be generated.
[in]dd_stringThe DataDefinition description within a (xml)string.

◆ CodecFactory() [3/5]

CodecFactory ( const ddl::dd::StructType struct_type,
const dd::DataDefinition dd 
)

Constructor that uses an OO-DataDefinition struct for initialization.

Parameters
[in]struct_typeThe struct definition.
[in]ddThe DD

◆ CodecFactory() [4/5]

CodecFactory ( const DDStructure dd_struct)

Constructor that uses an OO-DataDefinition struct for initialization.

Parameters
[in]dd_structThe struct definition.

◆ CodecFactory() [5/5]

CodecFactory ( const ddl::dd::StructTypeAccess struct_type_access)

Constructor that uses an StructTypeAccess for initialization.

Parameters
[in]struct_type_accessThe struct type access.

Member Function Documentation

◆ getElement() [1/2]

Element getElement ( const CodecIndex codec_index) const

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

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

◆ getElement() [2/2]

Element getElement ( const std::string &  full_element_name) const

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 FactoryElement.
Remarks
The element is only valid as long as the factory exists.
Exceptions
throwsstd::runtime_error if not found.

◆ getElementBaseName()

const std::string& getElementBaseName ( const CodecIndex codec_index) const

Retrieves the base name of the element within its structured 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".

Parameters
[in]codec_indexThe codec index of the element.
Returns
The base name of the element.
Exceptions
throwsstd::runtime_error if not found.

◆ getElementChildCount()

size_t getElementChildCount ( const CodecIndex codec_index = CodecIndex()) const

Retrieves the amount of child elements for the given codec index.

Parameters
[in]codec_indexThe codec index of the element.
Return values
0has no children. May be a leaf element.
>0has children. May be a structured element.
Exceptions
throwsstd::runtime_error if not found.

◆ getElementFullName()

std::string getElementFullName ( const CodecIndex codec_index) const

Retrieves the full name of the element within its main structure.

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".

Parameters
[in]codec_indexThe codec index of the element.
Returns
The full name of the element in array representation depending on array size.
Exceptions
throwsstd::runtime_error if not found.

◆ getElementName()

std::string getElementName ( const CodecIndex codec_index) const

Retrieves the name of the element within its structured 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".

Parameters
[in]codec_indexThe codec index of the element.
Returns
The name of the element in array representation depending on array size.
Exceptions
throwsstd::runtime_error if not found.

◆ getElements()

const Elements& getElements ( ) const

Retrieves the elements of the factory to get element information.

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

◆ getStaticBufferSize()

size_t getStaticBufferSize ( DataRepresentation  rep = deserialized) const

Gets the static buffer size in bytes for the structure.

Parameters
repoption to retrieve size in bytes for the deserialized or serialized representation.
Return values
size_tsize in bytes of the structure depending on the given representation rep

◆ getStaticElement()

a_util::result::Result getStaticElement ( size_t  leaf_index,
const ddl::StructElement *&  legacy_struct_element 
) const

Legacy: 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!

◆ getStaticElementCount()

size_t getStaticElementCount ( ) const

Legacy: Returns the amount of static (leaf) elements.

Returns
The amount of static elements contained in the handled structure.
Remarks
This is for legacy access only! This amount is the fully resolved amount of ALL reachable (POD) leafs.

◆ isValid()

a_util::result::Result isValid ( ) const

Check if the factory is in a valid state.

Returns
Any errors during construction.

◆ makeCodecFor()

Codec makeCodecFor ( void *  data,
size_t  data_size,
DataRepresentation  rep = deserialized 
) const

Creates a codec for the given data.

Parameters
[in]dataThe pointer to the raw data.
[in]data_sizeThe size of the raw data.
[in]repThe representation that the data is encoded in.
Returns
a codec.

◆ makeDecoderFor()

Decoder makeDecoderFor ( const void *  data,
size_t  data_size,
DataRepresentation  rep = deserialized 
) const

Creates a decoder for the given data.

Parameters
[in]dataThe pointer to the raw data.
[in]data_sizeThe size of the raw data.
[in]repThe representation that the data is encoded in.
Returns
a decoder.

◆ makeStaticCodecFor()

StaticCodec makeStaticCodecFor ( void *  data,
size_t  data_size,
DataRepresentation  rep = deserialized 
) const
inline

Creates a static codec for the given data.

Parameters
[in]dataThe pointer to the raw data.
[in]data_sizeThe size of the raw data.
[in]repThe representation that the data is encoded in.
Returns
a static codec.

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

References CodecFactory::_codec_access.

◆ makeStaticDecoderFor()

StaticDecoder makeStaticDecoderFor ( const void *  data,
size_t  data_size,
DataRepresentation  rep = deserialized 
) const
inline

Creates a static decoder for the given data.

Parameters
[in]dataThe pointer to the raw data.
[in]data_sizeThe size of the raw data.
[in]repThe representation that the data is encoded in.
Returns
a static decoder.

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

References CodecFactory::_codec_access.

◆ operator=() [1/2]

CodecFactory& operator= ( CodecFactory &&  )

move assignment operator

Returns
CodecFactory&

◆ operator=() [2/2]

CodecFactory& operator= ( const CodecFactory )

copy assignment operator

Returns
CodecFactory&

◆ resolve() [1/2]

void resolve ( CodecIndex codec_index) const

The codec index will be resolved for fast access.

Parameters
[in]codec_indexThe codec index to resolve.
Exceptions
throwsstd::runtime_error if not found.

◆ resolve() [2/2]

CodecIndex resolve ( size_t  leaf_index) const

Legacy: Resolves given the leaf index to a codec index.

Parameters
[in]leaf_indexThe leaf index of the element.
Returns
the codec index with information about the element if found.
Exceptions
std::runtime_errorif index not found.
Remarks
This is for legacy access only!