ADTF  3.18.4
type_reflection.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #ifdef USE_ADTF_MEDIA_DESCRIPTION_LEGACY
10  #ifndef NO_ADTF_MEDIA_DESCRIPTION_LEGACY
12  #endif
13 #endif
14 
15 //the typereflection is move to the DDL Library ... for structure<> use ddl::DDLStructure for structure<T> use DDLStructureT<T>
16 #include "ddl_usage.h"
18 
19 namespace adtf
20 {
21 namespace mediadescription
22 {
23 namespace osborn
24 {
25 
48 template<typename Type>
49 class enumeration : public ddl::DDEnumGenerator<Type>
50 {
51 public:
57  enumeration(const std::string& strName):
58  base_type(strName)
59  {
60  }
61 
66  size_t GetSize() const
67  {
68  return base_type::getEnumType().template getInfo<ddl::dd::TypeInfo>()->getTypeByteSize();
69  }
70 
75  size_t GetAlignment() const
76  {
77  return base_type::getEnumType().template getInfo<ddl::dd::TypeInfo>()->getTypeAlignment();
78  }
79 
86  enumeration& Add(const std::string& strName, Type eValue)
87  {
88  addElement(strName, eValue);
89  return *this;
90  }
91 };
92 
93 
123 template<typename T = void>
124 class structure : public ddl::DDStructureGenerator<T, true>
125 {
126  static_assert(std::is_trivially_copyable<T>::value,
127  "You can only use structs without pointers or complex members.");
128 
129 public:
139  structure(const std::string& strName, uint32_t ui32StructVersion = 1):
140  base_type(strName, ui32StructVersion)
141  {
142  }
143 
144 
149  size_t GetSize() const
150  {
152  }
153 
158  size_t GetAlignment() const
159  {
161  }
162 
169  template<typename MemberType>
170  structure& Add(const std::string& strName,
171  MemberType T::*pMemberOffset)
172  {
173  base_type::addElement(strName, pMemberOffset);
174  return *this;
175  }
176 
184  template<typename MemberType>
185  structure& Add(const std::string& strName, MemberType T::*pMemberOffset, const ddl::DDEnum& oTypeDefinition)
186  {
187  base_type::addElement(strName, pMemberOffset, oTypeDefinition);
188  return *this;
189  }
190 
198  template<typename MemberType>
199  structure& Add(const std::string& strName, MemberType T::*pMemberOffset, const ddl::DDStructure& oTypeDefinition)
200  {
201  base_type::addElement(strName, pMemberOffset, oTypeDefinition);
202  return *this;
203  }
204 
213  {
214  return base_type::getStructure();
215  }
216 
224  operator const ddl::DDStructure&() const
225  {
226  return GetStructure();
227  }
228 };
229 
244 template<>
245 class structure<void> : public ddl::DDStructure
246 {
247 public:
252  structure(const std::string& strName);
253 
259  structure(const std::string& strName, size_t nAlignment);
260 
265  size_t GetSize() const;
266 
271  size_t GetAlignment() const;
272 
283  structure& Add(const std::string& strName,
284  const ddl::dd::DataType& oTypeDefinition,
285  size_t nArrayCount = 1,
286  size_t nAlignment = 0,
287  int32_t nBytePosition = -1,
288  bool bLittleEndian = true);
289 
299  template<typename ArithmeticType>
300  structure& Add(const std::string& strName,
301  size_t nArrayCount = 1,
302  size_t nAlignment = 0,
303  int32_t nBytePosition = -1,
304  bool bLittleEndian = true)
305  {
306  return Add(strName,
308  nArrayCount,
309  nAlignment,
310  nBytePosition,
311  bLittleEndian);
312  }
313 
324  structure& Add(const std::string& strName,
325  const ddl::DDEnum& oTypeDefinition,
326  size_t nArrayCount = 1,
327  size_t nAlignment = 0,
328  int32_t nBytePosition = -1,
329  bool bLittleEndian = true);
330 
341  structure& Add(const std::string& strName,
342  const ddl::DDStructure& oTypeDefinition,
343  size_t nArrayCount = 1,
344  size_t nAlignment = 0,
345  int32_t nBytePosition = -1,
346  bool bLittleEndian = true);
347 
356  {
357  return *this;
358  }
359 
360 };
361 
362 } //namespace osborn
363 
364 using osborn::enumeration;
365 using osborn::structure;
366 
367 }
368 }
This is used to create an enumeration ytpe from an existing c++ enum.
size_t GetSize() const
Returns the size of the enumeration and underlying data type.
enumeration & Add(const std::string &strName, Type eValue)
Adds a new mapped value to the enumeration.
enumeration(const std::string &strName)
size_t GetAlignment() const
Returns the alignment of the enumeration and underlying data type.
size_t GetSize() const
Returns the current size of the structure.
structure & Add(const std::string &strName, const ddl::dd::DataType &oTypeDefinition, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
Adds a new member of an enumeration type.
structure & Add(const std::string &strName, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
Adds a new member of arithmetic type (POD)
const ddl::DDStructure & GetStructure() const
Get the current valid DDStructure object.
structure & Add(const std::string &strName, const ddl::DDStructure &oTypeDefinition, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
Adds a new member of a structure type.
structure(const std::string &strName)
Initializes the structure.
structure(const std::string &strName, size_t nAlignment)
Initializes the structure.
size_t GetAlignment() const
Returns the current calculated or set alignment of the structure.
structure & Add(const std::string &strName, const ddl::DDEnum &oTypeDefinition, size_t nArrayCount=1, size_t nAlignment=0, int32_t nBytePosition=-1, bool bLittleEndian=true)
Adds a new member of an enumeration type.
This is used to create a structure type from an existing c++ struct definition.
size_t GetSize() const
Returns the current size of the structure.
structure & Add(const std::string &strName, MemberType T::*pMemberOffset)
Adds a new member of arithmetic type (POD).
const ddl::DDStructure & GetStructure() const
Get the current valid DDStructure object.
structure(const std::string &strName, uint32_t ui32StructVersion=1)
Initializes the structure type.
size_t GetAlignment() const
Returns the alignment of the structure.
structure & Add(const std::string &strName, MemberType T::*pMemberOffset, const ddl::DDEnum &oTypeDefinition)
Adds a new member of an enumeration type.
structure & Add(const std::string &strName, MemberType T::*pMemberOffset, const ddl::DDStructure &oTypeDefinition)
Adds a new member of a structure type.
This is used to create the DD representation of an enumeration type.
Definition: ddenum.h:148
DDEnumGenerator & addElement(const std::string &name, Type value)
Adds a element for the enumeration with name and value.
Definition: ddenum.h:176
Utility class for a complete valid data definition of one EnumType and its dependencies.
Definition: ddenum.h:29
const dd::EnumType & getEnumType() const
Get the Enum Type object.
Creating a valid Structure Data Definition by a existing type and its member types.
Definition: ddstructure.h:644
std::string getStructName() const
Gets the Struct Name.
Definition: ddstructure.h:740
const dd::DataDefinition & getDD() const
returns a valid DDL.
Definition: ddstructure.h:752
DDStructureGenerator & addElement(const std::string &name, MemberType T::*member_offset)
Adds a new member of data type (POD) by member reference pointer.
Definition: ddstructure.h:667
const dd::StructType & getStructType() const
Get the Struct Type object.
Definition: ddstructure.h:765
const DDStructure & getStructure() const
Get the current valid DDStructure object.
Definition: ddstructure.h:777
Utility class for a complete valid data definition of one StructType and its dependencies.
Definition: ddstructure.h:55
Generator template to create DataType for the plain c-types.
StructTypeAccess getStructTypeAccess(const std::string &type_name) const
Get the Struct Type Access, where to enter the type and calculated element position information.
size_t getStaticStructSize() const
Get the known Static Struct Size of this instance.
observable DataDefinition object class to describe (POD) DataType.
OptionalSize getAlignment() const
Get the Alignment (if set)
Copyright © Audi Electronics Venture GmbH.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.