|
Dev Essential
|
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>
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. | |
| DDStructure & | operator= (DDStructure &&other) |
| move assignment operator | |
| DDStructure & | operator= (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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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> | |
| DDStructure & | addElement (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> | |
| DDStructure & | addElement (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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| DDStructure & | addElement (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. | |
| DDStructure & | addElements (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::DataDefinition & | getDD () const |
| returns a valid DDL. | |
| const dd::StructType & | getStructType () 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 |
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:
| ddl::DDStructure::DDStructure | ( | DDStructure && | other | ) |
Construct a new DDStructure object.
| other | the structure to move. |
| ddl::DDStructure::DDStructure | ( | const DDStructure & | other | ) |
Construct a new DDStructure object.
| other | the structure to copy. |
|
explicit |
Construct a new DDStructure object.
| name | typename of the new StructType |
| struct_version | version of the struct |
| alignment | optional alignment (if not set the alignment will be calculated automatically) |
| comment | optional comment |
| ddl_version | optional DDL language version of this struct (defines the size of the struct by alignment or not!) |
|
explicit |
Construct a new DDStructure object.
| name | typename of the new StructType |
| xml_string | the xml string to read |
| ddl_xml_file_version_to_parse | optional DDL language version of the string. |
| ddl::dd::Error | if the xml string is not valid against the xsd definition! (depending on the DDL Version). |
| ddl::dd::Error | if the validation level of the created DataDefinition is not at least "good_enough"! |
| ddl::dd::Error | if the given name is not part of this description. |
| DDStructure & ddl::DDStructure::addElement | ( | const DDElement & | element | ) |
Adds one element to the struct using the convenience class DDElement.
Usage:
| element | the DDElement |
| ddl::dd::Error | if the name of the given element already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| alignment | alignment of the element |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| alignment | alignment of the element |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| enum_type | the enum type |
| constant_value | the constant value name, defined within enum_type |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| enum_type | the enum type |
| array_size | the arrysize of the element (by default 1) |
| constant_value | the constant value name, defined within enum_type |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| enum_type | the enum type |
| array_size | the arrysize of the element (by default 1) |
| alignment | alignment of the element |
| constant_value | the constant value name, defined within enum_type |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| struct_type | the struct type |
| array_size | the arraysize of the element (by default 1) |
| alignment | the alignment for the element |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| struct_type | the struct type |
| array_size | the arrysize of the element (by default 1) |
| ddl::dd::Error | if the given element_name already exists. |
|
inline |
Adds one element to the struct using a (POD) DataType.
Usage:
| PREDEF_DATA_TYPE | The POD type (float, int32_t ... etc. ) |
| element_name | the name of the element |
| array_size | the arrysize of the element (by default 1) |
| special_type_name | this typename is used instead of the typename predefined in DataType |
| alignment | alignment of the element |
| ddl::dd::Error | if the given element_name already exists. |
|
inline |
Adds one element to the struct using a (POD) DataType.
Usage:
| PREDEF_DATA_TYPE | The POD type (float, int32_t ... etc. ) |
| element_name | the name of the element |
| array_size | the arrysize of the element (by default 1) |
| special_type_name | this typename is used instead of the typename predefined in DataType |
| ddl::dd::Error | if the given element_name already exists. |
| DDStructure & ddl::DDStructure::addElements | ( | const std::vector< DDElement > & | elements | ) |
Adds a list of element to the struct using the convenience class DDElement.
Usage:
| elements | the list of DDElement |
| ddl::dd::Error | if a name of the given elements already exists. |
|
inline |
returns the first elenents iterator for range based iterations.
|
inline |
returns the first elements iterator.
|
inline |
returns the end elements iterator.
| DDElementRef ddl::DDStructure::createElement | ( | const DDElement & | element | ) |
Creates one element to the struct using the convenience class DDElement.
Usage:
| element | the DDElement |
| ddl::dd::Error | if the name of the given element already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| alignment | alignment of the element |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arraysize of the element (by default 1) |
| alignment | alignment of the element |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| data_type | the data type |
| array_size | the arrysize of the element (by default 1) |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| enum_type | the enum type |
| constant_value | the constant value name, defined within enum_type |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| enum_type | the enum type |
| array_size | the arrysize of the element (by default 1) |
| constant_value | the constant value name, defined within enum_type |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| enum_type | the enum type |
| array_size | the arrysize of the element (by default 1) |
| alignment | alignment of the element |
| constant_value | the constant value name, defined within enum_type |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| struct_type | the struct type |
| array_size | the arraysize of the element (by default 1) |
| alignment | the alignment for the element |
| ddl::dd::Error | if the given element_name already exists. |
| 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:
| element_name | the name of the element |
| struct_type | the struct type |
| array_size | the arrysize of the element (by default 1) |
| ddl::dd::Error | if the given element_name already exists. |
|
inline |
Creates one element to the struct using a (POD) DataType.
Usage:
| PREDEF_DATA_TYPE | The POD type (float, int32_t ... etc. ) |
| element_name | the name of the element |
| array_size | the arrysize of the element (by default 1) |
| special_type_name | this typename is used instead of the typename predefined in DataType |
| alignment | alignment of the element |
| ddl::dd::Error | if the given element_name already exists. |
|
inline |
Create one element to the struct using a (POD) DataType.
Usage:
| PREDEF_DATA_TYPE | The POD type (float, int32_t ... etc. ) |
| element_name | the name of the element |
| array_size | the arrysize of the element (by default 1) |
| special_type_name | this typename is used instead of the typename predefined in DataType |
| ddl::dd::Error | if the given element_name already exists. |
|
inline |
returns the end elements iterator.
| size_t ddl::DDStructure::getAlignment | ( | ) | const |
Retrieves the current evaluated alignment of the structure.
| const dd::DataDefinition & ddl::DDStructure::getDD | ( | ) | const |
returns a valid DDL.
| DDElementRef ddl::DDStructure::getElement | ( | const std::string & | element_name | ) |
Gets a element reference to the element with name element_name owned by the DDStructure.
| element_name | the elements name |
| dd::Error | if element was not found |
| size_t ddl::DDStructure::getSize | ( | ) | const |
Retrieves the current evaluated deserialized size (in bytes) of the structure.
| std::string ddl::DDStructure::getStructDescription | ( | ) | const |
Gets the Struct Data Description as XML String.
| std::string ddl::DDStructure::getStructName | ( | ) | const |
Gets the Struct Name.
| const dd::StructType & ddl::DDStructure::getStructType | ( | ) | const |
Get the Struct Type object.
| bool ddl::DDStructure::isCompatible | ( | const DDStructure & | other | ) | const |
binary compares the structs
| other | the other struct to binary compare to |
| bool ddl::DDStructure::isEqual | ( | const DDStructure & | other | ) | const |
equal in names and descriptions
| other | the other struct |
| DDStructure & ddl::DDStructure::operator= | ( | const DDStructure & | other | ) |
| DDStructure & ddl::DDStructure::operator= | ( | DDStructure && | other | ) |
| 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.
element_name must have been added before! The info will only be set if the string of the parameter is not empty!| element_name | The element name to set the additional info to |
| description | The description |
| comment | The comment |
| value | The value |
| minimum_value | The minimum value |
| maximum_value | The maximum value |
| default_value | The default value |
| scale | The scale |
| offset | The offset |
| dd::Error | if element with element_name does not exist. |
| 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.
element_name must have been added before!| element_name | The element name |
| base_unit | The baseunit to set |
| dd::Error | if element with element_name does not exist. |
| void ddl::DDStructure::setElementUnit | ( | const std::string & | element_name, |
| const DDUnit & | unit ) |
Sets additional element unit information to the given element_name.
element_name must have been added before!| element_name | The element name |
| unit | The unit to set |
| dd::Error | if element with element_name does not exist. |
| 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.
| comment | The comment of the struct type. |