ADTF  3.18.2
structure< T >

This is used to create a structure type from an existing c++ struct definition. More...

Inheritance diagram for structure< T >:
[legend]

Public Types

typedef ddl::DDStructureGenerator< T, true > base_type
 

Public Member Functions

 structure (const std::string &strName, uint32_t ui32StructVersion=1)
 Initializes the structure type. More...
 
size_t GetSize () const
 Returns the current size of the structure. More...
 
size_t GetAlignment () const
 Returns the alignment of the structure. More...
 
template<typename MemberType >
structureAdd (const std::string &strName, MemberType T::*pMemberOffset)
 Adds a new member of arithmetic type (POD). More...
 
template<typename MemberType >
structureAdd (const std::string &strName, MemberType T::*pMemberOffset, const ddl::DDEnum &oTypeDefinition)
 Adds a new member of an enumeration type. More...
 
template<typename MemberType >
structureAdd (const std::string &strName, MemberType T::*pMemberOffset, const ddl::DDStructure &oTypeDefinition)
 Adds a new member of a structure type. More...
 
const ddl::DDStructureGetStructure () const
 Get the current valid DDStructure object. More...
 
 operator const ddl::DDStructure & () const
 Get the current valid DDStructure object. More...
 
- Public Member Functions inherited from DDStructureGenerator< void, true >
 DDStructureGenerator (const std::string &name, uint32_t struct_version=1)
 CTOR to create a structure type based on a type. More...
 
DDStructureGeneratoraddElement (const std::string &name, MemberType T::*member_offset)
 Adds a new member of data type (POD) by member reference pointer. More...
 
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...
 
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...
 
void setStructInfo (const std::string &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={})
 
void setElementUnit (const std::string &element_name, const DDUnit &unit)
 Sets additional element unit information to the given element_name. More...
 
void setElementUnit (const std::string &element_name, const dd::BaseUnit &base_unit)
 Sets additional element base unit information to the given element_name. More...
 

Detailed Description

template<typename T = void>
class adtf::mediadescription::osborn::structure< T >

This is used to create a structure type from an existing c++ struct definition.

Example Usage

struct tSub
{
uint8_t nValue1;
uint8_t nValue2;
};
struct tParent
{
uint32_t nSomething;
tSub sSub;
};
auto oSubType = structure<tSub>("tSub")
.Add("nValue1", &tSub::nValue1)
.Add("nValue2", &tSub::nValue2);
auto oParentType = structure<tParent>("tParent")
.Add("nSomething", &tParent::nSomething)
.Add("sSub", &tParent::sSub, oSubType);

Also have a look at Demo Time Trigger Plugin.

Definition at line 124 of file type_reflection.h.

Constructor & Destructor Documentation

◆ structure()

structure ( const std::string &  strName,
uint32_t  ui32StructVersion = 1 
)
inline

Initializes the structure type.

Parameters
[in]strNameThe name.
[in]ui32StructVersionThe structure version.
Remarks
This implementation uses padding ddl elements to find the right position of eleemnts. Use ddl::DDStructureGenerator<T, false> to switch it off. For that you need to completely describe the whole structure and each element must be added in the right order.

Definition at line 139 of file type_reflection.h.

Member Function Documentation

◆ Add() [1/3]

structure& Add ( const std::string &  strName,
MemberType T::*  pMemberOffset 
)
inline

Adds a new member of arithmetic type (POD).

Parameters
[in]strNameThe name of the member.
[in]pMemberOffsetThe pointer to the member.
Returns
A reference to the structure.

Definition at line 170 of file type_reflection.h.

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

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

◆ Add() [2/3]

structure& Add ( const std::string &  strName,
MemberType T::*  pMemberOffset,
const ddl::DDEnum oTypeDefinition 
)
inline

Adds a new member of an enumeration type.

Parameters
[in]strNameThe name of the member.
[in]pMemberOffsetThe pointer to the member.
[in]oTypeDefinitionThe enumeration type.
Returns
A reference to the structure.

Definition at line 185 of file type_reflection.h.

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

◆ Add() [3/3]

structure& Add ( const std::string &  strName,
MemberType T::*  pMemberOffset,
const ddl::DDStructure oTypeDefinition 
)
inline

Adds a new member of a structure type.

Parameters
[in]strNameThe name of the member.
[in]pMemberOffsetThe pointer to the member.
[in]oTypeDefinitionThe structure type.
Returns
A reference to the structure.

Definition at line 199 of file type_reflection.h.

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

◆ GetAlignment()

size_t GetAlignment ( ) const
inline

Returns the alignment of the structure.

Returns
size_t The alignment

Definition at line 158 of file type_reflection.h.

References StructType::getAlignment(), and DDStructureGenerator< T, align_with_padding >::getStructType().

◆ GetSize()

size_t GetSize ( ) const
inline

◆ GetStructure()

const ddl::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 212 of file type_reflection.h.

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

Referenced by structure< T >::operator const ddl::DDStructure &().

◆ operator const ddl::DDStructure &()

operator const ddl::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 224 of file type_reflection.h.

References structure< T >::GetStructure().