Dev Essential
Loading...
Searching...
No Matches
ddl::codec::CodecFactory Class Reference

#include <codec_factory.h>

Public Types

typedef FactoryElement< FactoryElementAccess< const CodecFactory > > Element
 
typedef ChildElements< FactoryElementAccess< const CodecFactory > > Elements
 

Public Member Functions

 CodecFactory ()
 
 CodecFactory (const CodecFactory &)
 copy CTOR
 
CodecFactoryoperator= (const CodecFactory &)
 copy assignment operator
 
 CodecFactory (CodecFactory &&)
 move CTOR
 
CodecFactoryoperator= (CodecFactory &&)
 move assignment operator
 
 ~CodecFactory ()=default
 Default dtor.
 
 CodecFactory (const std::string &struct_name, const std::string &dd_string)
 
 CodecFactory (const ddl::dd::StructType &struct_type, const dd::DataDefinition &dd)
 
 CodecFactory (const DDStructure &dd_struct)
 
 CodecFactory (const ddl::dd::StructTypeAccess &struct_type_access)
 
a_util::result::Result isValid () const
 
StaticDecoder makeStaticDecoderFor (const void *data, size_t data_size, DataRepresentation rep=deserialized) const
 
StaticCodec makeStaticCodecFor (void *data, size_t data_size, DataRepresentation rep=deserialized) const
 
Decoder makeDecoderFor (const void *data, size_t data_size, DataRepresentation rep=deserialized) const
 
Codec makeCodecFor (void *data, size_t data_size, DataRepresentation rep=deserialized) const
 
Element getElement (const CodecIndex &codec_index) const
 
Element getElement (std::string_view full_path) const
 
Element getChildElement (const CodecIndex &parent_codec_index, std::string_view relative_path) const
 
const ElementsgetElements () const
 
size_t getElementChildCount (const CodecIndex &codec_index=CodecIndex()) const
 
std::string getElementFullName (const CodecIndex &codec_index) const
 Retrieves the full name of the element within its main structure.
 
std::string getElementName (const CodecIndex &codec_index) const
 Retrieves the name of the element within its structured element.
 
const std::string & getElementBaseName (const CodecIndex &codec_index) const
 Retrieves the base name of the element within its structured element.
 
size_t getStaticBufferSize (DataRepresentation rep=deserialized) const
 Gets the static buffer size in bytes for the structure.
 
void resolve (CodecIndex &codec_index) const
 
CodecIndex resolve (size_t leaf_index) const
 
CodecIndex resolve (size_t leaf_index, std::string &full_element_name) const
 
size_t getStaticElementCount () const
 
a_util::result::Result getStaticElement (size_t leaf_index, const ddl::StructElement *&legacy_struct_element) const
 

Detailed Description

Factory class for ddl codecs.

Member Typedef Documentation

◆ Element

Type of a single factory element.

◆ Elements

Constructor & Destructor Documentation

◆ CodecFactory() [1/5]

ddl::codec::CodecFactory::CodecFactory ( )

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

◆ CodecFactory() [2/5]

ddl::codec::CodecFactory::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]

ddl::codec::CodecFactory::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]

ddl::codec::CodecFactory::CodecFactory ( const DDStructure & dd_struct)

Constructor that uses an OO-DataDefinition struct for initialization.

Parameters
[in]dd_structThe struct definition.

◆ CodecFactory() [5/5]

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

◆ getChildElement()

Element ddl::codec::CodecFactory::getChildElement ( const CodecIndex & parent_codec_index,
std::string_view relative_path ) const

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

Parameters
[in]parent_codec_indexThe parent codec index.
[in]relative_pathThe child name of the element in point notation (i.e. "child_element[4].element_value").

By using an empty string the deserialized decoding information within CodecIndex will retrieve the same codec index as it is before.

Returns
The child 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() [1/2]

Element ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::getElement ( std::string_view full_path) const

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

Parameters
[in]full_pathThe 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 & ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 & ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::isValid ( ) const

Check if the factory is in a valid state.

Returns
Any errors during construction.

◆ makeCodecFor()

Codec ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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 ddl::codec::CodecFactory::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.

◆ makeStaticDecoderFor()

StaticDecoder ddl::codec::CodecFactory::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.

◆ operator=() [1/2]

CodecFactory & ddl::codec::CodecFactory::operator= ( CodecFactory && )

move assignment operator

Returns
CodecFactory&

◆ operator=() [2/2]

CodecFactory & ddl::codec::CodecFactory::operator= ( const CodecFactory & )

copy assignment operator

Returns
CodecFactory&

◆ resolve() [1/3]

void ddl::codec::CodecFactory::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/3]

CodecIndex ddl::codec::CodecFactory::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!

◆ resolve() [3/3]

CodecIndex ddl::codec::CodecFactory::resolve ( size_t leaf_index,
std::string & full_element_name ) const

Legacy: Resolves the given leaf index to a codec index and the full element name.

Parameters
[in]leaf_indexThe leaf index of the element.
[in,out]full_element_nameelement name to retrieve.
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!

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