ADTF
Loading...
Searching...
No Matches
ddl::DDStructure Class Reference

Utility class for a complete valid data definition of one StructType and its dependencies. This class is for convenience to use create a StructType data defintion in code.
The class is to use as follows: More...

#include <ddstructure.h>

Inherited by adtf::mediadescription::osborn::structure< void >.

Public Types

typedef dd::datamodel::StructType::Elements::const_iterator const_iterator
 iterator to iterate the elements of the struct
 

Public Member Functions

 DDStructure ()=delete
 Construct a new DDStructure object.
 
 DDStructure (DDStructure &&other)
 Construct a new DDStructure object.
 
 DDStructure (const DDStructure &other)
 Construct a new DDStructure object.
 
DDStructureoperator= (DDStructure &&other)
 move assignment operator
 
DDStructureoperator= (const DDStructure &other)
 copy assignment operator
 
 ~DDStructure ()=default
 Destroy the DDStructure object.
 
 DDStructure (const std::string &name, const uint32_t struct_version=1, dd::OptionalSize alignment={}, const std::string &comment={}, const dd::Version &ddl_version={})
 Construct a new DDStructure object.
 
 DDStructure (const std::string &name, const std::string &xml_string, const dd::Version &ddl_xml_file_version_to_parse=dd::Version(0, 0))
 Construct a new DDStructure object.
 
DDStructureaddElement (const std::string &element_name, const dd::DataType &data_type, size_t array_size=1)
 Adds one element to the struct using a (POD) DataType.
 
DDElementRef createElement (const std::string &element_name, const dd::DataType &data_type, size_t array_size=1)
 Creates one element to the struct using a (POD) DataType.
 
DDStructureaddElement (const std::string &element_name, const dd::DataType &data_type, size_t array_size, size_t alignment)
 Adds one element to the struct using a (POD) DataType.
 
DDElementRef createElement (const std::string &element_name, const dd::DataType &data_type, size_t array_size, size_t alignment)
 Creates one element to the struct using a (POD) DataType.
 
DDStructureaddElement (const std::string &element_name, const DDDataType &data_type, size_t array_size=1)
 Adds one element to the struct using a (POD) DataType.
 
DDElementRef createElement (const std::string &element_name, const DDDataType &data_type, size_t array_size=1)
 Creates one element to the struct using a (POD) DataType.
 
DDStructureaddElement (const std::string &element_name, const DDDataType &data_type, size_t array_size, size_t alignment)
 Adds one element to the struct using a (POD) DataType.
 
DDElementRef createElement (const std::string &element_name, const DDDataType &data_type, size_t array_size, size_t alignment)
 Creates one element to the struct using a (POD) DataType.
 
template<typename PREDEF_DATA_TYPE>
DDStructureaddElement (const std::string &element_name, size_t array_size=1, const std::string &special_type_name={})
 Adds one element to the struct using a (POD) DataType.
 
template<typename PREDEF_DATA_TYPE>
DDElementRef createElement (const std::string &element_name, size_t array_size=1, const std::string &special_type_name={})
 Create one element to the struct using a (POD) DataType.
 
template<typename PREDEF_DATA_TYPE>
DDStructureaddElement (const std::string &element_name, size_t array_size, size_t alignment, const std::string &special_type_name={})
 Adds one element to the struct using a (POD) DataType.
 
template<typename PREDEF_DATA_TYPE>
DDElementRef createElement (const std::string &element_name, size_t array_size, size_t alignment, const std::string &special_type_name={})
 Creates one element to the struct using a (POD) DataType.
 
DDStructureaddElement (const std::string &element_name, const DDEnum &enum_type, size_t array_size, const std::string &constant_value={})
 Adds one element to the struct using the convenience class DDEnum.
 
DDElementRef createElement (const std::string &element_name, const DDEnum &enum_type, size_t array_size, const std::string &constant_value={})
 Creates one element to the struct using the convenience class DDEnum.
 
DDStructureaddElement (const std::string &element_name, const DDEnum &enum_type, size_t array_size, size_t alignment, const std::string &constant_value={})
 Adds one element to the struct using the convenience class DDEnum.
 
DDElementRef createElement (const std::string &element_name, const DDEnum &enum_type, size_t array_size, size_t alignment, const std::string &constant_value={})
 Creates one element to the struct using the convenience class DDEnum.
 
DDStructureaddElement (const std::string &element_name, const DDEnum &enum_type, const std::string &constant_value={})
 Adds one element to the struct using the convenience class DDEnum.
 
DDElementRef createElement (const std::string &element_name, const DDEnum &enum_type, const std::string &constant_value={})
 Creates one element to the struct using the convenience class DDEnum.
 
DDStructureaddElement (const std::string &element_name, const DDStructure &struct_type, size_t array_size=1)
 Adds one element to the struct using the convenience class DDStructure.
 
DDElementRef createElement (const std::string &element_name, const DDStructure &struct_type, size_t array_size=1)
 Creates one element to the struct using the convenience class DDStructure.
 
DDStructureaddElement (const std::string &element_name, const DDStructure &struct_type, size_t array_size, size_t alignment)
 Adds one element to the struct using the convenience class DDStructure.
 
DDElementRef createElement (const std::string &element_name, const DDStructure &struct_type, size_t array_size, size_t alignment)
 Creates one element to the struct using the convenience class DDStructure.
 
DDStructureaddElement (const DDElement &element)
 Adds one element to the struct using the convenience class DDElement.
 
DDElementRef createElement (const DDElement &element)
 Creates one element to the struct using the convenience class DDElement.
 
DDStructureaddElements (const std::vector< DDElement > &elements)
 Adds a list of element to the struct using the convenience class DDElement.
 
const_iterator cbegin () const
 returns the first elements iterator.
 
const_iterator cend () const
 returns the end elements iterator.
 
const_iterator begin () const
 returns the first elenents iterator for range based iterations.
 
const_iterator end () const
 returns the end elements iterator.
 
const dd::DataDefinitiongetDD () const
 returns a valid DDL.
 
const dd::StructTypegetStructType () const
 Get the Struct Type object.
 
std::string getStructDescription () const
 Gets the Struct Data Description as XML String.
 
std::string getStructName () const
 Gets the Struct Name.
 
bool isCompatible (const DDStructure &other) const
 binary compares the structs
 
bool isEqual (const DDStructure &other) const
 equal in names and descriptions
 
size_t getSize () const
 Retrieves the current evaluated deserialized size (in bytes) of the structure.
 
size_t getAlignment () const
 Retrieves the current evaluated alignment of the structure.
 
void setStructInfo (const std::string &comment)
 Set additional struct information like comment. This is important to create additional info in type reflection for DDStructureGenerator.
 
void setElementInfo (const std::string &element_name, const std::string &description={}, const std::string &comment={}, const std::string &value={}, const std::string &minimum_value={}, const std::string &maximum_value={}, const std::string &default_value={}, const std::string &scale={}, const std::string &offset={})
 Set additional element information to the given element_name.
 
void setElementUnit (const std::string &element_name, const DDUnit &unit)
 Sets additional element unit information to the given element_name.
 
void setElementUnit (const std::string &element_name, const dd::BaseUnit &base_unit)
 Sets additional element base unit information to the given element_name. Any other unit information will be overwritten.
 
DDElementRef getElement (const std::string &element_name)
 Gets a element reference to the element with name element_name owned by the DDStructure.
 

Friends

template<typename T, bool align_with_padding>
class DDStructureGenerator
 

Detailed Description

Utility class for a complete valid data definition of one StructType and its dependencies. This class is for convenience to use create a StructType data defintion in code.
The class is to use as follows:

DDEnum e1("e1", DataType<int8_t>(), {{"val11", "1"}, {"val12", "2"}, {"val13", "3"}});
DDStructure a("A");
a.addElement<int32_t>("elem1");
a.addElement("elem2", DataType<uint16_t>());
a.addElement("elem3", e1, "val13");
DDStructure b("B");
b.addElement("nestedA1", a);
b.addElement("nestedA2", a);
//now you can do something with the created DD
b.getDD().isValid();
std::string dd_struct = b.getStructName();
std::string dd_description = b.getStructDescription();
Utility class for a complete valid data definition of one EnumType and its dependencies....
Definition ddenum.h:29
DDStructure()=delete
Construct a new DDStructure object.
Generator template to create DataType for the plain c-types.
Definition dd_predefined_datatypes.h:38
See also
ddl::DDEnum, ddl::DataType

Constructor & Destructor Documentation

◆ DDStructure() [1/4]

ddl::DDStructure::DDStructure ( DDStructure && other)

Construct a new DDStructure object.

Parameters
otherthe structure to move.

◆ DDStructure() [2/4]

ddl::DDStructure::DDStructure ( const DDStructure & other)

Construct a new DDStructure object.

Parameters
otherthe structure to copy.

◆ DDStructure() [3/4]

ddl::DDStructure::DDStructure ( const std::string & name,
const uint32_t struct_version = 1,
dd::OptionalSize alignment = {},
const std::string & comment = {},
const dd::Version & ddl_version = {} )
explicit

Construct a new DDStructure object.

Parameters
nametypename of the new StructType
struct_versionversion of the struct
alignmentoptional alignment (if not set the alignment will be calculated automatically)
commentoptional comment
ddl_versionoptional DDL language version of this struct (defines the size of the struct by alignment or not!)

◆ DDStructure() [4/4]

ddl::DDStructure::DDStructure ( const std::string & name,
const std::string & xml_string,
const dd::Version & ddl_xml_file_version_to_parse = dd::Version(0, 0) )
explicit

Construct a new DDStructure object.

Parameters
nametypename of the new StructType
xml_stringthe xml string to read
ddl_xml_file_version_to_parseoptional DDL language version of the string.
Exceptions
ddl::dd::Errorif the xml string is not valid against the xsd definition! (depending on the DDL Version).
ddl::dd::Errorif the validation level of the created DataDefinition is not at least "good_enough"!
ddl::dd::Errorif the given name is not part of this description.

Member Function Documentation

◆ addElement() [1/12]

DDStructure & ddl::DDStructure::addElement ( const DDElement & element)

Adds one element to the struct using the convenience class DDElement.

Usage:

DDStructure a("A");
a.addElement(ddl::DDElement("elem1", ddl::DataType<uint32_t>()));
Utility class for a complete valid data definition of one StructType::Element and its dependencies....
Definition ddelement.h:36
Parameters
elementthe DDElement
Returns
*this
Exceptions
ddl::dd::Errorif the name of the given element already exists.

◆ addElement() [2/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const dd::DataType & data_type,
size_t array_size,
size_t alignment )

Adds one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.addElement("elem1", DataType<uint16_t>(), 1, 2);
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
alignmentalignment of the element
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [3/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const dd::DataType & data_type,
size_t array_size = 1 )

Adds one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.addElement("elem1", DataType<uint16_t>());
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [4/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDDataType & data_type,
size_t array_size,
size_t alignment )

Adds one element to the struct using a (POD) DataType.

Usage:

DDDataType custom_type("custom", 1);
DDStructure a("A");
a.addElement("elem1", custom_type);
A DataType class holding the DD for a Datatype with dependencies. (i.e. Units!)
Definition dddatatype.h:30
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
alignmentalignment of the element
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [5/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDDataType & data_type,
size_t array_size = 1 )

Adds one element to the struct using a (POD) DataType.

Usage:

DDDataType custom_type("custom", 1);
DDStructure a("A");
a.addElement("elem1", custom_type);
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [6/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDEnum & enum_type,
const std::string & constant_value = {} )

Adds one element to the struct using the convenience class DDEnum.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.addElement("elem1", e1);
Parameters
element_namethe name of the element
enum_typethe enum type
constant_valuethe constant value name, defined within enum_type
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [7/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDEnum & enum_type,
size_t array_size,
const std::string & constant_value = {} )

Adds one element to the struct using the convenience class DDEnum.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.addElement("elem1", e1);
Parameters
element_namethe name of the element
enum_typethe enum type
array_sizethe arrysize of the element (by default 1)
constant_valuethe constant value name, defined within enum_type
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [8/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDEnum & enum_type,
size_t array_size,
size_t alignment,
const std::string & constant_value = {} )

Adds one element to the struct using the convenience class DDEnum.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.addElement("elem1", e1);
Parameters
element_namethe name of the element
enum_typethe enum type
array_sizethe arrysize of the element (by default 1)
alignmentalignment of the element
constant_valuethe constant value name, defined within enum_type
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [9/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDStructure & struct_type,
size_t array_size,
size_t alignment )

Adds one element to the struct using the convenience class DDStructure.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.addElement("elem1", e1);
a.addElement<uint16_t>("elem2");
DDStructure b("B");
b.addElement("nested1", a);
b.addElement("nested2", a);
Parameters
element_namethe name of the element
struct_typethe struct type
array_sizethe arraysize of the element (by default 1)
alignmentthe alignment for the element
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [10/12]

DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
const DDStructure & struct_type,
size_t array_size = 1 )

Adds one element to the struct using the convenience class DDStructure.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.addElement("elem1", e1);
a.addElement<uint16_t>("elem2");
DDStructure b("B");
b.addElement("nested1", a);
b.addElement("nested2", a);
Parameters
element_namethe name of the element
struct_typethe struct type
array_sizethe arrysize of the element (by default 1)
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [11/12]

template<typename PREDEF_DATA_TYPE>
DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
size_t array_size,
size_t alignment,
const std::string & special_type_name = {} )
inline

Adds one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.addElement<uint16_t>("elem1", 1, 2);
a.addElement<uint16_t>("elem2", 1, 4, "tUInt16");
Template Parameters
PREDEF_DATA_TYPEThe POD type (float, int32_t ... etc. )
Parameters
element_namethe name of the element
array_sizethe arrysize of the element (by default 1)
special_type_namethis typename is used instead of the typename predefined in DataType
alignmentalignment of the element
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElement() [12/12]

template<typename PREDEF_DATA_TYPE>
DDStructure & ddl::DDStructure::addElement ( const std::string & element_name,
size_t array_size = 1,
const std::string & special_type_name = {} )
inline

Adds one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.addElement<uint16_t>("elem1");
a.addElement<uint16_t>("elem2", "tUInt16");
Template Parameters
PREDEF_DATA_TYPEThe POD type (float, int32_t ... etc. )
Parameters
element_namethe name of the element
array_sizethe arrysize of the element (by default 1)
special_type_namethis typename is used instead of the typename predefined in DataType
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ addElements()

DDStructure & ddl::DDStructure::addElements ( const std::vector< DDElement > & elements)

Adds a list of element to the struct using the convenience class DDElement.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} }
DDStructure a("A");
a.addElements({ DDElement("elem1", DataType<uint64_t>()),
DDElement("elem2", DataType<float>()) } );
a.addElements({ {"elem3", DataType<double>() },
{"elem4", DataType<bool>() },
{"elem5", e1 } });
@ e1
Definition dd_common_types.h:100
Parameters
elementsthe list of DDElement
Returns
*this
Exceptions
ddl::dd::Errorif a name of the given elements already exists.

◆ begin()

const_iterator ddl::DDStructure::begin ( ) const
inline

returns the first elenents iterator for range based iterations.

Returns
const_iterator

◆ cbegin()

const_iterator ddl::DDStructure::cbegin ( ) const
inline

returns the first elements iterator.

Returns
const_iterator

◆ cend()

const_iterator ddl::DDStructure::cend ( ) const
inline

returns the end elements iterator.

Returns
const_iterator

◆ createElement() [1/12]

DDElementRef ddl::DDStructure::createElement ( const DDElement & element)

Creates one element to the struct using the convenience class DDElement.

Usage:

DDStructure a("A");
a.createElement(ddl::DDElement("elem1", ddl::DataType<uint32_t>()));
Parameters
elementthe DDElement
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the name of the given element already exists.

◆ createElement() [2/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const dd::DataType & data_type,
size_t array_size,
size_t alignment )

Creates one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.createElement("elem1", DataType<uint16_t>(), 1, 2);
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
alignmentalignment of the element
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [3/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const dd::DataType & data_type,
size_t array_size = 1 )

Creates one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.createElement("elem1", DataType<uint16_t>());
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
DDElement the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [4/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDDataType & data_type,
size_t array_size,
size_t alignment )

Creates one element to the struct using a (POD) DataType.

Usage:

DDDataType custom_type("custom", 1);
DDStructure a("A");
a.createElement("elem1", custom_type);
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arraysize of the element (by default 1)
alignmentalignment of the element
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [5/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDDataType & data_type,
size_t array_size = 1 )

Creates one element to the struct using a (POD) DataType.

Usage:

DDDataType custom_type("custom", 1);
DDStructure a("A");
a.createElement("elem1", custom_type);
Parameters
element_namethe name of the element
data_typethe data type
array_sizethe arrysize of the element (by default 1)
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [6/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDEnum & enum_type,
const std::string & constant_value = {} )

Creates one element to the struct using the convenience class DDEnum.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.createElement("elem1", e1);
Parameters
element_namethe name of the element
enum_typethe enum type
constant_valuethe constant value name, defined within enum_type
Returns
DDElement the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [7/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDEnum & enum_type,
size_t array_size,
const std::string & constant_value = {} )

Creates one element to the struct using the convenience class DDEnum.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.createElement("elem1", e1);
Parameters
element_namethe name of the element
enum_typethe enum type
array_sizethe arrysize of the element (by default 1)
constant_valuethe constant value name, defined within enum_type
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [8/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDEnum & enum_type,
size_t array_size,
size_t alignment,
const std::string & constant_value = {} )

Creates one element to the struct using the convenience class DDEnum.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.createElement("elem1", e1);
Parameters
element_namethe name of the element
enum_typethe enum type
array_sizethe arrysize of the element (by default 1)
alignmentalignment of the element
constant_valuethe constant value name, defined within enum_type
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [9/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDStructure & struct_type,
size_t array_size,
size_t alignment )

Creates one element to the struct using the convenience class DDStructure.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.createElement("elem1", e1);
a.createElement<uint16_t>("elem2");
DDStructure b("B");
b.createElement("nested1", a);
b.createElement("nested2", a);
Parameters
element_namethe name of the element
struct_typethe struct type
array_sizethe arraysize of the element (by default 1)
alignmentthe alignment for the element
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [10/12]

DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
const DDStructure & struct_type,
size_t array_size = 1 )

Creates one element to the struct using the convenience class DDStructure.

Usage:

DDEnum e1("e1", DataType<int8_t>(), { {"val11", "1"}, {"val12", "2"}, {"val13", "3"} });
DDStructure a("A");
a.createElement("elem1", e1);
a.createElement<uint16_t>("elem2");
DDStructure b("B");
b.createElement("nested1", a);
b.createElement("nested2", a);
Parameters
element_namethe name of the element
struct_typethe struct type
array_sizethe arrysize of the element (by default 1)
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [11/12]

template<typename PREDEF_DATA_TYPE>
DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
size_t array_size,
size_t alignment,
const std::string & special_type_name = {} )
inline

Creates one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.createElement<uint16_t>("elem1", 1, 2);
a.createElement<uint16_t>("elem2", 1, 4, "tUInt16");
Template Parameters
PREDEF_DATA_TYPEThe POD type (float, int32_t ... etc. )
Parameters
element_namethe name of the element
array_sizethe arrysize of the element (by default 1)
special_type_namethis typename is used instead of the typename predefined in DataType
alignmentalignment of the element
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [12/12]

template<typename PREDEF_DATA_TYPE>
DDElementRef ddl::DDStructure::createElement ( const std::string & element_name,
size_t array_size = 1,
const std::string & special_type_name = {} )
inline

Create one element to the struct using a (POD) DataType.

Usage:

DDStructure a("A");
a.createElement<uint16_t>("elem1");
a.createElement<uint16_t>("elem2", "tUInt16");
Template Parameters
PREDEF_DATA_TYPEThe POD type (float, int32_t ... etc. )
Parameters
element_namethe name of the element
array_sizethe arrysize of the element (by default 1)
special_type_namethis typename is used instead of the typename predefined in DataType
Remarks
all default DataTypes are always part of the DataDefinition if needed. See ddl::PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ end()

const_iterator ddl::DDStructure::end ( ) const
inline

returns the end elements iterator.

Returns
const_iterator

◆ getAlignment()

size_t ddl::DDStructure::getAlignment ( ) const

Retrieves the current evaluated alignment of the structure.

Returns
the alignment

◆ getDD()

const dd::DataDefinition & ddl::DDStructure::getDD ( ) const

returns a valid DDL.

Returns
const dd::DataDefinition&

◆ getElement()

DDElementRef ddl::DDStructure::getElement ( const std::string & element_name)

Gets a element reference to the element with name element_name owned by the DDStructure.

Parameters
element_namethe elements name
Returns
the element reference
Exceptions
dd::Errorif element was not found

◆ getSize()

size_t ddl::DDStructure::getSize ( ) const

Retrieves the current evaluated deserialized size (in bytes) of the structure.

Returns
the size (in bytes)

◆ getStructDescription()

std::string ddl::DDStructure::getStructDescription ( ) const

Gets the Struct Data Description as XML String.

Returns
std::string

◆ getStructName()

std::string ddl::DDStructure::getStructName ( ) const

Gets the Struct Name.

Returns
std::string

◆ getStructType()

const dd::StructType & ddl::DDStructure::getStructType ( ) const

Get the Struct Type object.

Returns
const dd::StructType&

◆ isCompatible()

bool ddl::DDStructure::isCompatible ( const DDStructure & other) const

binary compares the structs

Parameters
otherthe other struct to binary compare to
Returns
true The structs are binary comaptible in memory
false the struct are not binary compatible

◆ isEqual()

bool ddl::DDStructure::isEqual ( const DDStructure & other) const

equal in names and descriptions

Parameters
otherthe other struct
Returns
true the structs are identically
false the structs are different

◆ operator=() [1/2]

DDStructure & ddl::DDStructure::operator= ( const DDStructure & other)

copy assignment operator

Parameters
otherthe structure to copy.
Returns
DDStructure&

◆ operator=() [2/2]

DDStructure & ddl::DDStructure::operator= ( DDStructure && other)

move assignment operator

Parameters
otherthe structure to move.
Returns
DDStructure&

◆ setElementInfo()

void ddl::DDStructure::setElementInfo ( const std::string & element_name,
const std::string & description = {},
const std::string & comment = {},
const std::string & value = {},
const std::string & minimum_value = {},
const std::string & maximum_value = {},
const std::string & default_value = {},
const std::string & scale = {},
const std::string & offset = {} )

Set additional element information to the given element_name.

Remarks
The element with the name element_name must have been added before! The info will only be set if the string of the parameter is not empty!
Parameters
element_nameThe element name to set the additional info to
descriptionThe description
commentThe comment
valueThe value
minimum_valueThe minimum value
maximum_valueThe maximum value
default_valueThe default value
scaleThe scale
offsetThe offset
Exceptions
dd::Errorif element with element_name does not exist.

◆ setElementUnit() [1/2]

void ddl::DDStructure::setElementUnit ( const std::string & element_name,
const dd::BaseUnit & base_unit )

Sets additional element base unit information to the given element_name. Any other unit information will be overwritten.

Remarks
The element with the name element_name must have been added before!
Parameters
element_nameThe element name
base_unitThe baseunit to set
Exceptions
dd::Errorif element with element_name does not exist.

◆ setElementUnit() [2/2]

void ddl::DDStructure::setElementUnit ( const std::string & element_name,
const DDUnit & unit )

Sets additional element unit information to the given element_name.

  • Any other unit information will be overwritten.
    Remarks
    The element with the name element_name must have been added before!
    Parameters
    element_nameThe element name
    unitThe unit to set
    Exceptions
    dd::Errorif element with element_name does not exist.

◆ setStructInfo()

void ddl::DDStructure::setStructInfo ( const std::string & comment)

Set additional struct information like comment. This is important to create additional info in type reflection for DDStructureGenerator.

Parameters
commentThe comment of the struct type.

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