ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DDStructure

Utility class for a complete valid data definition of one StructType and its dependencies. More...

#include <ddstructure.h>

Inheritance diagram for DDStructure:
[legend]

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.
 
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.
 
DDElementRef getElement (const std::string &element_name)
 Gets a element reference to the element with name element_name owned by the DDStructure.
 

Private Member Functions

void popLastElement ()
 

Private Attributes

dd::DataDefinition _dd
 
std::shared_ptr< dd::StructType_struct_type
 
dd::OptionalSize _initial_alignment = {}
 

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.
See also
DDEnum, DataType

Definition at line 57 of file ddstructure.h.

Member Typedef Documentation

◆ const_iterator

typedef dd::datamodel::StructType::Elements::const_iterator const_iterator

iterator to iterate the elements of the struct

Definition at line 730 of file ddstructure.h.

Constructor & Destructor Documentation

◆ DDStructure() [1/4]

DDStructure ( DDStructure && other)

Construct a new DDStructure object.

Parameters
otherthe structure to move.

References DDStructure().

◆ DDStructure() [2/4]

DDStructure ( const DDStructure & other)

Construct a new DDStructure object.

Parameters
otherthe structure to copy.

References DDStructure().

◆ DDStructure() [3/4]

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]

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

References DDStructure().

◆ addElement() [2/12]

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 PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

References DDStructure().

◆ addElement() [3/12]

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 PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

References DDStructure().

◆ addElement() [4/12]

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.
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 PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

References DDStructure().

◆ addElement() [5/12]

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 PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

References DDStructure().

◆ addElement() [6/12]

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.

References DDStructure().

◆ addElement() [7/12]

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.

References DDStructure().

◆ addElement() [8/12]

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.

References DDStructure().

◆ addElement() [9/12]

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.

References DDStructure().

◆ addElement() [10/12]

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.

References DDStructure().

◆ addElement() [11/12]

template<typename PREDEF_DATA_TYPE>
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 PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

Definition at line 395 of file ddstructure.h.

References DDStructure().

◆ addElement() [12/12]

template<typename PREDEF_DATA_TYPE>
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 PredefinedDataTypes.
Returns
*this
Exceptions
ddl::dd::Errorif the given element_name already exists.

Definition at line 326 of file ddstructure.h.

References DDStructure().

◆ addElements()

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
Default alignment.
Parameters
elementsthe list of DDElement
Returns
*this
Exceptions
ddl::dd::Errorif a name of the given elements already exists.

References DDStructure().

◆ begin()

const_iterator begin ( ) const
inline

returns the first elenents iterator for range based iterations.

Returns
const_iterator

Definition at line 755 of file ddstructure.h.

◆ cbegin()

const_iterator cbegin ( ) const
inline

returns the first elements iterator.

Returns
const_iterator

Definition at line 737 of file ddstructure.h.

◆ cend()

const_iterator cend ( ) const
inline

returns the end elements iterator.

Returns
const_iterator

Definition at line 746 of file ddstructure.h.

◆ createElement() [1/12]

DDElementRef 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 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 PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [3/12]

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.

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 PredefinedDataTypes.
Returns
DDElement the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [4/12]

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.

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 PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [5/12]

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.

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 PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

◆ createElement() [6/12]

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.

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

References DDStructure().

◆ createElement() [10/12]

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.

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.

References DDStructure().

◆ createElement() [11/12]

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 = {} )
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 PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

Definition at line 432 of file ddstructure.h.

◆ createElement() [12/12]

template<typename PREDEF_DATA_TYPE>
DDElementRef 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 PredefinedDataTypes.
Returns
DDElementRef the reference to the created element
Exceptions
ddl::dd::Errorif the given element_name already exists.

Definition at line 360 of file ddstructure.h.

◆ end()

const_iterator end ( ) const
inline

returns the end elements iterator.

Returns
const_iterator

Definition at line 764 of file ddstructure.h.

◆ getAlignment()

size_t getAlignment ( ) const

Retrieves the current evaluated alignment of the structure.

Returns
the alignment

◆ getDD()

const dd::DataDefinition & getDD ( ) const

returns a valid DDL.

Returns
const dd::DataDefinition&

◆ getElement()

DDElementRef 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 getSize ( ) const

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

Returns
the size (in bytes)

◆ getStructDescription()

std::string getStructDescription ( ) const

Gets the Struct Data Description as XML String.

Returns
std::string

◆ getStructName()

std::string getStructName ( ) const

Gets the Struct Name.

Returns
std::string

◆ getStructType()

const dd::StructType & getStructType ( ) const

Get the Struct Type object.

Returns
const dd::StructType&

◆ isCompatible()

bool 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

References DDStructure().

◆ isEqual()

bool 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

References DDStructure().

◆ operator=() [1/2]

DDStructure & operator= ( const DDStructure & other)

copy assignment operator

Parameters
otherthe structure to copy.
Returns
DDStructure&

References DDStructure().

◆ operator=() [2/2]

DDStructure & operator= ( DDStructure && other)

move assignment operator

Parameters
otherthe structure to move.
Returns
DDStructure&

References DDStructure().

◆ setElementInfo()

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.

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

Member Data Documentation

◆ _dd

dd::DataDefinition _dd
private

Definition at line 895 of file ddstructure.h.

◆ _initial_alignment

dd::OptionalSize _initial_alignment = {}
private

Definition at line 897 of file ddstructure.h.

◆ _struct_type

std::shared_ptr<dd::StructType> _struct_type
private

Definition at line 896 of file ddstructure.h.