ADTF  3.14.3
DDStructureGenerator< T, align_with_padding >

Creating a valid Structure Data Definition by a existing type and its member types. More...

Public Member Functions

 DDStructureGenerator (const std::string &name, uint32_t struct_version=1)
 CTOR to create a structure type based on a type. More...
 
template<typename MemberType >
DDStructureGeneratoraddElement (const std::string &name, MemberType T::*member_offset)
 Adds a new member of data type (POD) by member reference pointer. More...
 
template<typename MemberType >
DDStructureGeneratoraddElement (const std::string &name, MemberType T::*member_offset, const DDEnum &enum_type)
 Adds a new member of an enumeration type by member reference pointer. More...
 
template<typename MemberType >
DDStructureGeneratoraddElement (const std::string &name, MemberType T::*member_offset, const DDStructure &struct_type)
 Adds a new member of an structure type by member reference pointer. More...
 
std::string getStructDescription () const
 Gets the Struct Data Description as XML String. More...
 
std::string getStructName () const
 Gets the Struct Name. More...
 
const dd::DataDefinitiongetDD () const
 returns a valid DDL. More...
 
const dd::StructTypegetStructType () const
 Get the Struct Type object. More...
 
const DDStructuregetStructure () const
 Get the current valid DDStructure object. More...
 
size_t getSize () const
 Retrieves the current evaluated size of the structure. More...
 
size_t getAlignment () const
 Retrieves the current evaluated alignment of the structure. More...
 
 operator const DDStructure & () const
 Get the current valid DDStructure object. More...
 

Private Member Functions

void pushAlignment ()
 
void popAlignment ()
 
void validate () const
 
dd::OptionalSize evaluateAlignment (const std::string &element_name, size_t member_offset, size_t member_type_alignment)
 

Private Attributes

DDStructure _structure
 
bool _padded_final = false
 

Detailed Description

template<typename T, bool align_with_padding = true>
class ddl::DDStructureGenerator< T, align_with_padding >

Creating a valid Structure Data Definition by a existing type and its member types.

Template Parameters
TThe Struct type to use.
align_with_paddingSet to true to align the structure and structure members with padding bytes to reach expected size of T.
struct NestedStruct {
uint16_t value1;
uint32_t value2;
uint8_t value3;
};
//this creates a valid DDStructure to use
auto nested_definition = DDStructureGenerator<NestedStruct>("NestedStruct")
.addElement("value1", &NestedStruct::value1)
.addElement("value2", &NestedStruct::value2)
.addElement("value3", &NestedStruct::value3);
//this creates a valid enum type
enum MyEnum { a, b, c };
auto my_enum_type = DDEnumGenerator<MyEnum>("MyEnum", {{"a", a}, {"b", b}, {"c", c}});
//create a more complex structure
//static arrays are determined by type
struct MyStruct {
uint32_t value1;
NestedStruct nested;
MyEnum nested_enum[2];
};
auto my_struct = DDStructureGenerator<MyStruct>("MyStruct")
.addElement("value1", &MyStruct::value1)
.addElement("nested", &MyStruct::nested, nested_definition)
.addElement("nested_enum", &MyStruct::nested_enum, my_enum_type);

Definition at line 593 of file ddstructure.h.

Constructor & Destructor Documentation

◆ DDStructureGenerator()

DDStructureGenerator ( const std::string &  name,
uint32_t  struct_version = 1 
)
inlineexplicit

CTOR to create a structure type based on a type.

Parameters
nameThe name of the type.
struct_versionthe version of the type.

Definition at line 605 of file ddstructure.h.

Member Function Documentation

◆ addElement() [1/3]

DDStructureGenerator& addElement ( const std::string &  name,
MemberType T::*  member_offset 
)
inline

Adds a new member of data type (POD) by member reference pointer.

Parameters
[in]nameThe name of the member.
[in]member_offsetThe pointer to the member.
Returns
A reference to the structure.

Definition at line 616 of file ddstructure.h.

References DDStructure::addElement().

Referenced by structure< T >::Add().

◆ addElement() [2/3]

DDStructureGenerator& addElement ( const std::string &  name,
MemberType T::*  member_offset,
const DDEnum enum_type 
)
inline

Adds a new member of an enumeration type by member reference pointer.

Parameters
[in]nameThe name of the member.
[in]member_offsetThe pointer to the member.
[in]enum_typeThe enumeration type.
Returns
A reference to the structure.

Definition at line 637 of file ddstructure.h.

References DDStructure::addElement(), and enum_type.

◆ addElement() [3/3]

DDStructureGenerator& addElement ( const std::string &  name,
MemberType T::*  member_offset,
const DDStructure struct_type 
)
inline

Adds a new member of an structure type by member reference pointer.

Parameters
[in]nameThe name of the member.
[in]member_offsetThe pointer to the member.
[in]struct_typeThe structure type.
Returns
A reference to the structure.

Definition at line 659 of file ddstructure.h.

References DDStructure::addElement(), and struct_type.

◆ getAlignment()

size_t getAlignment ( ) const
inline

Retrieves the current evaluated alignment of the structure.

Returns
the alignment

Definition at line 745 of file ddstructure.h.

References DDStructure::getAlignment().

◆ getDD()

const dd::DataDefinition& getDD ( ) const
inline

returns a valid DDL.

Returns
const dd::DataDefinition&
Exceptions
ddl::dd::ErrorThrows if the evaluated size is not sizeof(T). Check if there may be missed elements.

Definition at line 701 of file ddstructure.h.

References DDStructure::getDD().

Referenced by structure< T >::GetSize().

◆ getSize()

size_t getSize ( ) const
inline

Retrieves the current evaluated size of the structure.

Returns
the size

Definition at line 736 of file ddstructure.h.

References DDStructure::getSize().

◆ getStructDescription()

std::string getStructDescription ( ) const
inline

Gets the Struct Data Description as XML String.

Returns
std::string

Definition at line 679 of file ddstructure.h.

References DDStructure::getStructDescription().

◆ getStructName()

std::string getStructName ( ) const
inline

Gets the Struct Name.

Returns
std::string

Definition at line 689 of file ddstructure.h.

References DDStructure::getStructName().

Referenced by structure< T >::GetSize().

◆ getStructType()

const dd::StructType& getStructType ( ) const
inline

Get the Struct Type object.

Returns
const dd::StructType&
Exceptions
ddl::dd::ErrorThrows if the evaluated size is not sizeof(T). Check if there may be missed elements.

Definition at line 714 of file ddstructure.h.

References DDStructure::getStructType().

Referenced by structure< T >::GetAlignment().

◆ getStructure()

const DDStructure& getStructure ( ) const
inline

Get the current valid DDStructure object.

Returns
const DDStructure&
Exceptions
ddl::dd::ErrorThrows if the evaluated size is not sizeof(T). Check if there may be missed elements.

Definition at line 726 of file ddstructure.h.

Referenced by structure< T >::GetStructure(), and DDStructureGenerator< T, align_with_padding >::operator const DDStructure &().

◆ operator const DDStructure &()

operator const DDStructure & ( ) const
inline

Get the current valid DDStructure object.

Returns
const DDStructure&
Exceptions
ddl::dd::ErrorThrows if the evaluated size is not sizeof(T). Check if there may be missed elements.

Definition at line 757 of file ddstructure.h.

References DDStructureGenerator< T, align_with_padding >::getStructure().


Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)