ADTF  3.18.2
dd_common_types.h
Go to the documentation of this file.
1 
15 #ifndef DD_TYPES_H_INCLUDED
16 #define DD_TYPES_H_INCLUDED
17 
20 
21 #include <string>
22 #include <cstdint>
23 
25 #define DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(alternative) \
26  DEV_ESSENTIAL_DEPRECATED("Please use ddl::dd::" #alternative \
27  " directly, due to static intialization problem.")
29 
30 namespace ddl {
31 
32 namespace dd {
33 
39 
44 enum TypeOfType : uint8_t {
70 };
71 
76 enum TypeOfUnit : uint8_t {
91  base_unit
92 };
93 
98 enum Alignment : size_t {
99  e0 = 1,
100  e1 = 1,
101  e2 = 2,
102  e4 = 4,
103  e8 = 8,
104  e16 = 16,
105  e32 = 32,
106  e64 = 64,
107  e_invalid = 255
108 };
109 
115 public:
122  static std::string toString(Alignment alignment);
130  static Alignment fromString(const std::string& alignment,
131  const Alignment& default_val = Alignment::e_invalid);
132 };
133 
139 public:
146  static bool isValid(size_t alignment);
147 };
148 
152 enum ByteOrder {
153  platform_not_supported = 0x00,
154  plattform_little_endian_8 = 0x01,
155  platform_big_endian_8 = 0x02,
156  e_noe = platform_not_supported,
157  e_le = plattform_little_endian_8,
158  e_be = platform_big_endian_8
159 };
160 
166 public:
173  static std::string toString(ByteOrder byte_order);
181  static ByteOrder fromString(const std::string& byte_order,
182  const ByteOrder& default_val = ByteOrder::platform_not_supported);
183 };
184 
190 public:
197 };
198 
203 class Version {
204 public:
215  Version(const std::string& version);
216 
223  Version(uint32_t major, uint32_t minor);
224 
230  uint32_t getMajor() const;
236  uint32_t getMinor() const;
237 
243  std::string toString() const;
244 
251  bool isValidVersion() const;
252 
258  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version::getLatestVersion())
259  static const Version& getDefaultVersion()
260  {
261  return getLatestVersion();
262  }
263 
269  static const Version& getLatestVersion();
270 
271  /* ignore patch version for all comparisons */
273  bool operator==(const Version& other) const;
274  bool operator!=(const Version& other) const;
275  bool operator>(const Version& other) const;
276  bool operator<(const Version& other) const;
277  bool operator<=(const Version& other) const;
278  bool operator>=(const Version& other) const;
280 
285  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(0, 0))
291  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(0, 0))
297  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(1, 0))
298  static const Version ddl_version_10;
303  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(1, 1))
304  static const Version ddl_version_11;
309  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(1, 2))
310  static const Version ddl_version_12;
315  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(2, 0))
316  static const Version ddl_version_20;
321  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(3, 0))
322  static const Version ddl_version_30;
327  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(4, 0))
328  static const Version ddl_version_40;
333  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version(4, 1))
334  static const Version ddl_version_41;
339  DEV_ESSENTIAL_DEPRECATED_STATIC_VERSION(Version::getLatestVersion())
341 
342 private:
343  uint32_t _major = {};
344  uint32_t _minor = {};
345 };
346 
352 public:
359  static std::string toString(const Version& version);
367  static Version fromString(const std::string& version,
368  const Version& default_val = Version(0, 0));
369 };
370 
375 class ArraySize {
376 public:
380  ArraySize() = default;
385  ArraySize(size_t array_size);
391  ArraySize& operator=(size_t array_size);
396  ArraySize(const std::string& array_size_element_name);
402  ArraySize& operator=(const std::string& array_size_element_name);
407  void setArraySizeValue(size_t array_size);
411  size_t getArraySizeValue() const;
416  void setArraySizeElementName(const std::string& array_size_element_name);
421  const std::string& getArraySizeElementName() const;
425  bool isDynamicArraySize() const;
426 
433  bool operator==(const ArraySize& other) const;
440  bool operator!=(const ArraySize& other) const;
441 
442 private:
443  size_t _array_size = {1};
444  std::string _array_size_element_name = {};
445 };
446 
447 } // namespace dd
448 } // namespace ddl
449 
450 #endif // DD_TYPES_H_INCLUDED
tBool operator<(const tErrorCode &lhs, const tErrorCode &rhs)
Less-than operator for POD error type.
tBool operator<=(const tErrorCode &lhs, const tErrorCode &rhs)
Less-than-or-equal operator for POD error type.
tBool operator>(const tErrorCode &lhs, const tErrorCode &rhs)
Greater-than operator for POD error type.
tBool operator!=(const tErrorCode &lhs, const tErrorCode &rhs)
Compare two POD error code types for inequality.
tBool operator==(const tErrorCode &lhs, const tErrorCode &rhs)
Compare two POD error code types for equality.
tBool operator>=(const tErrorCode &lhs, const tErrorCode &rhs)
Greater-than-or-equal operator for POD error type.
Alignment Conversion utility.
static Alignment fromString(const std::string &alignment, const Alignment &default_val=Alignment::e_invalid)
convert a string to an alignment.
static std::string toString(Alignment alignment)
convert alignment to a string.
Alignment ConvValidation utility.
static bool isValid(size_t alignment)
check if the Alignment is a valid value
Sinc DDL 2.0 it is possible to define arraysize with a string that indicates a dynamic array.
bool operator!=(const ArraySize &other) const
compares the Array size with the other
ArraySize(const std::string &array_size_element_name)
CTOR.
ArraySize & operator=(size_t array_size)
assignment operator
void setArraySizeValue(size_t array_size)
set the array size
bool isDynamicArraySize() const
indicates if this is a dynamic erray size.
ArraySize(size_t array_size)
CTOR.
size_t getArraySizeValue() const
get the array size
ArraySize()=default
default CTOR.
ArraySize & operator=(const std::string &array_size_element_name)
assignment operator
void setArraySizeElementName(const std::string &array_size_element_name)
sets the dynamic array size
bool operator==(const ArraySize &other) const
compares the Array size with the other
const std::string & getArraySizeElementName() const
gets the dynamic array size
ByteOrder Conversion utility.
static std::string toString(ByteOrder byte_order)
convert byte_order to a string.
static ByteOrder fromString(const std::string &byte_order, const ByteOrder &default_val=ByteOrder::platform_not_supported)
convert a string to a byte_order.
Default ByteOrder Discovery utility class.
static ByteOrder getPlatformDefault()
Get the current Platform Byteorder.
Version conversion utility class.
static Version fromString(const std::string &version, const Version &default_val=Version(0, 0))
Creates the Version from a string.
static std::string toString(const Version &version)
Version to string conversion.
std::string toString() const
the vrsion as string
static const Version & getLatestVersion()
Get the latest DDL version.
static const Version ddl_version_current
the newest version (currently it is ddl_version_41).
static const Version ddl_version_invalid
invalid Version.
Version()
default CTOR
bool isValidVersion() const
is valid or not
static const Version ddl_version_12
Language Version 1.2.
static const Version ddl_version_10
Language Version 1.0.
static const Version & getDefaultVersion()
Get the Default Version.
static const Version ddl_version_11
Language Version 1.0+.
uint32_t getMajor() const
Get the Major value.
static const Version ddl_version_40
Language Version 4.0.
Version(uint32_t major, uint32_t minor)
CTOR.
static const Version ddl_version_41
Language Version 4.1.
static const Version ddl_version_30
Language Version 3.0.
static const Version ddl_version_notset
version not set Version.
Version(const std::string &version)
CTOR - Version from string.
uint32_t getMinor() const
Get the Minor value.
static const Version ddl_version_20
Language Version 2.0.
OO DataDefinition Optional Implementation.
Definition of preprocessor macro DEV_ESSENTIAL_DEPRECATED.
TypeOfType
Classification of a Type.
@ enum_type
the type is a enum type (EnumType)
@ data_type
the type is a data type (DataType)
@ struct_type
the type is a struct type (StructType)
@ invalid_type
the type is unknown
@ stream_meta_type
the type is an stream meta type (StreamMetaType)
TypeOfUnit
Classification of unit.
@ unit
the unit is a unit (Unit)
@ base_unit
the unit is a base unit (BaseUnit)
@ invalid_unit
the type of the unit is unknown
ByteOrder
Representation of the byteorder enumeration.
Alignment
Alignment defintion.
@ e0
for backward compatibility
@ e1
Default alignment.