ADTF  3.18.2
dd_typeinfomodel.h
Go to the documentation of this file.
1 
15 #ifndef DD_TYPEINFOMODEL_H_INCLUDED
16 #define DD_TYPEINFOMODEL_H_INCLUDED
17 
18 #include <a_util/preprocessor/deprecated.h> // DEV_ESSENTIAL_DEPRECATED()
21 
22 #include <string>
23 
25 #define DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API \
26  DEV_ESSENTIAL_DEPRECATED( \
27  "Use the ddl::dd::StructTypeAccess and ddl::dd::StructElementAccess instead.")
29 
30 namespace ddl {
31 
32 namespace dd {
33 
44 class TypeInfo : public datamodel::Info<TypeInfo> {
45 public:
47  static constexpr const uint8_t INFO_TYPE_ID = dd::InfoType::type_info;
52  DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API
53  TypeInfo() = default;
60  DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API
68  DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API
70 
76  size_t getTypeBitSize() const;
82  size_t getTypeAlignment() const;
88  size_t getTypeByteSize() const;
89 
95  size_t getTypeAlignedByteSize() const;
96 
102  size_t getTypeUnalignedByteSize() const;
103 
111  bool isValid() const;
118  bool isDynamic() const;
119 
134 
138  enum class UpdateType {
139  only_changed = 0,
140  force_all = 1,
141  only_last = 2,
142  only_reference = 3
143  };
154  datamodel::DataDefinition& parent_dd,
155  UpdateType update_type = UpdateType::only_changed);
156 
157 private:
158  size_t _type_bit_size = 0;
159  size_t _type_alignment = 0;
160  size_t _type_byte_size = 0;
161  size_t _type_aligned_byte_size = 0;
162  size_t _type_unaligned_byte_size = 0;
163  bool _is_dynamic = false;
164  bool _is_valid = false;
165 
166  bool _already_discovering = false;
167 };
168 
175 class ElementTypeInfo : public datamodel::Info<ElementTypeInfo> {
176 public:
181  static constexpr const uint8_t INFO_TYPE_ID = dd::InfoType::element_type_info;
182 
186  DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API
187  ElementTypeInfo() = default;
188 
197  OptionalSize getDeserializedBytePos(size_t array_pos = 0) const;
224 
232  OptionalSize getSerializedBytePos(size_t array_pos = 0) const;
240  OptionalSize getSerializedBitOffset(size_t array_pos = 0) const;
246  size_t getSerializedBitSize() const;
252  size_t getSerializedTypeBitSize() const;
253 
262  bool isDynamic() const;
270  bool isAfterDynamic() const;
279  bool isValid() const;
280 
294  std::shared_ptr<const datamodel::StructType> getStructType() const;
301  std::shared_ptr<const datamodel::EnumType> getEnumType() const;
309  std::shared_ptr<const datamodel::DataType> getDataType() const;
310 
322  const std::shared_ptr<datamodel::StructType::Element>& previous_element,
323  const Version& struct_ddl_version,
324  datamodel::DataDefinition& parent_dd);
325 
334  datamodel::DataDefinition& parent_dd);
335 
336 private:
337  OptionalSize _deserialized_byte_pos = {};
338  OptionalSize _deserialized_byte_size = {};
339  size_t _deserialized_type_byte_size = 0;
340  size_t _deserialized_type_aligned_byte_size = 0;
341 
342  OptionalSize _serialized_byte_pos = {};
343  OptionalSize _serialized_absolute_bit_offset = {};
344  OptionalSize _serialized_bit_size = {};
345  size_t _serialized_type_bit_size = 0;
346 
347  bool _is_dynamic = false;
348  bool _is_after_dynamic = false;
349  bool _is_valid = false;
350 
351  datamodel::ElementType _element_type;
352 };
353 
354 } // namespace dd
355 } // namespace ddl
356 
357 #endif // DD_TYPEINFOMODEL_H_INCLUDED
Element Size Info is important to get the calculate the TypeInfo for StructType.
bool isAfterDynamic() const
The element is after a dynamic content.
OptionalSize getDeserializedBytePos(size_t array_pos=0) const
Get the Deserialized Byte Pos This position is always invalid for positions after a dynamic content (...
bool updateReference(const datamodel::StructType::Element &element, datamodel::DataDefinition &parent_dd)
Updates the current type reference to the new model.
DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API ElementTypeInfo()=default
default CTOR
size_t getSerializedBitSize() const
Get the Serialized Bit Size.
std::shared_ptr< const datamodel::StructType > getStructType() const
Get the Struct Type Object.
void update(datamodel::StructType::Element &element, const std::shared_ptr< datamodel::StructType::Element > &previous_element, const Version &struct_ddl_version, datamodel::DataDefinition &parent_dd)
Updates all information of the element.
bool isValid() const
Determines if all size can be calculated, all references are known and the dependencies are well defi...
static constexpr const uint8_t INFO_TYPE_ID
definiton of info type to use the datamodel::Info template.
OptionalSize getDeserializedByteSize() const
Get the Deserialized Byte Size always aligned, depending on the struct_ddl_version.
bool isDynamic() const
Determines if the element itself or if it is element of a struct_type defines a dynamic array.
size_t getDeserializedTypeAlignedByteSize() const
Get the Deserialized Type Byte Size usually this is the same like getDeserializedByteSize,...
TypeOfType getTypeOfType() const
Get the Type Of Type object Fast access to the type information.
size_t getSerializedTypeBitSize() const
Get the Serialized Type Bit Size.
OptionalSize getSerializedBytePos(size_t array_pos=0) const
Get the Serialized Byte Pos This position is always invalid for positions after a dynamic content (is...
OptionalSize getSerializedBitOffset(size_t array_pos=0) const
Get the Serialized Bit Pos of the element as bit offset to the beginning of the struct This position ...
size_t getDeserializedTypeByteSize() const
Get the Deserialized Type Byte Size usually this is the same like getDeserializedByteSize,...
std::shared_ptr< const datamodel::EnumType > getEnumType() const
Get the Enum Type object.
std::shared_ptr< const datamodel::DataType > getDataType() const
Get the Data Type object.
TypeInfo model will check for type.
UpdateType
Update type for the struct update.
@ force_all
force recaculation of all elements
@ only_changed
update only changed elements
@ only_last
update the last element only
@ only_reference
update the references only
DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API TypeInfo()=default
default CTOR
DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API TypeInfo(const datamodel::DataType &data_type, datamodel::DataDefinition &parent_dd)
CTOR to create a Type Info that is initial updated with data_type information.
bool isValid() const
the content is valid, all references to other DD Objects (for calculation) are valid.
static constexpr const uint8_t INFO_TYPE_ID
type info ID to use it in datamodel::Info.
void update(datamodel::StructType &struct_type, datamodel::DataDefinition &parent_dd, UpdateType update_type=UpdateType::only_changed)
Updates the content for a struct_type.
bool isDynamic() const
contains dynamic content (usually this is only possible for struct_type)
DEV_ESSENTIAL_DEPRECATED_TYPEINFO_API TypeInfo(const datamodel::EnumType &enum_type, datamodel::DataDefinition &parent_dd)
CTOR to create a Type Info that is initial updated with enum_type information.
size_t getTypeAlignedByteSize() const
Get the Type Aligned Byte Size.
size_t getTypeUnalignedByteSize() const
Get the Type Unaligned Byte Size.
size_t getTypeAlignment() const
Get the Type Alignment.
void update(const datamodel::DataType &data_type, datamodel::DataDefinition &parent_dd)
Updates the content for a data_type.
void update(const datamodel::EnumType &enum_type, datamodel::DataDefinition &parent_dd)
Updates the content for a enum_type.
size_t getTypeByteSize() const
Get the Type Byte Size (depending on ddl version in structs this is aligned or not)
size_t getTypeBitSize() const
Get the Type Bit Size.
DataDefinition Datamodel This datamodel is observable for any change of:
observable DataDefinition object class to describe (POD) DataType.
observable DataDefinition object class to describe EnumType.
Helper template class to create valid IInfo objects.
observable DataDefinition object class for a Element of a StructType.
observable DataDefinition object class to describe StructType.
OO DataDefinition Redesign.
OO DataDefinition info model types.
Definition of preprocessor macro DEV_ESSENTIAL_DEPRECATED.
ElementType
The element type of the value.
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)
utility::Optional< size_t > OptionalSize
Optional Size Type.
@ element_type_info
Element Type Info.
@ type_info
Type Info.