ADTF  3.18.2
dd_struct_access.h
Go to the documentation of this file.
1 
15 #ifndef DD_DDL_STRUCT_ACCESS_H_INCLUDED
16 #define DD_DDL_STRUCT_ACCESS_H_INCLUDED
17 
19 
20 #include <string>
21 
22 namespace ddl {
23 namespace dd {
24 
25 class TypeInfo;
26 class ElementTypeInfo;
27 class StructTypeAccess;
28 
35 public:
36  friend class StructTypeAccess;
37  friend class StructElementAccessIterator;
38 
43  StructElementAccess() = delete;
50  StructElementAccess(std::nullptr_t);
71 
78  operator bool() const;
93  std::shared_ptr<const datamodel::StructType> getStructType() const;
102  std::shared_ptr<const datamodel::EnumType> getEnumType() const;
111  std::shared_ptr<const datamodel::DataType> getDataType() const;
112 
121  StructTypeAccess getStructTypeAccess(size_t array_pos = 0) const;
122 
135  bool isDynamic() const;
144  bool isAfterDynamic() const;
161  size_t getDeserializedBytePos(size_t array_size = 0) const;
168  size_t getDeserializedByteSize() const;
169 
184  size_t getSerializedBytePos(size_t array_size = 0) const;
192  size_t getSerializedBitOffset(size_t array_size = 0) const;
199  size_t getSerializedBitSize() const;
206  size_t getSerializedTypeBitSize() const;
207 
208 private:
217  StructElementAccess(const std::shared_ptr<const datamodel::StructType::Element>& elem,
218  OptionalSize serialized_element_bit_offset,
219  OptionalSize deserialized_element_byte_offset,
220  OptionalSize array_pos);
221 
222 private:
223  std::shared_ptr<const datamodel::StructType::Element> _element = {};
224  const ElementTypeInfo* _element_type_info = nullptr;
225  OptionalSize _deserialized_struct_byte_offset = {};
226  OptionalSize _serialized_struct_bit_offset = {};
227  OptionalSize _array_pos = {};
228 };
229 
236 public:
264  typedef int difference_type;
268  typedef std::forward_iterator_tag iterator_category;
279  OptionalSize struct_ser,
280  OptionalSize struct_deser);
313  bool operator==(const self_type& rhs) const;
321  bool operator!=(const self_type& rhs) const;
322 
323 private:
326  StructElementAccess _ref;
327  OptionalSize _struct_ser;
328  OptionalSize _struct_deser;
329 };
330 
337 public:
338  friend class DataDefinition;
339  friend class StructElementAccess;
343  StructTypeAccess() = delete;
362 
370  StructTypeAccess(const std::shared_ptr<const datamodel::StructType>& struct_type);
371 
375  StructTypeAccess(std::nullptr_t);
376 
377 private:
385  StructTypeAccess(const std::shared_ptr<const datamodel::StructType>& struct_type,
386  OptionalSize serialized_struct_offset,
387  OptionalSize deserialized_struct_offset);
388 
389 public:
407  StructElementAccess getElementByPath(const std::string name_path) const;
414  operator bool() const;
420  size_t getStaticStructSize() const;
421 
429 
437 
444  bool isDynamic() const;
445 
452 
482 
483 private:
484  std::shared_ptr<const datamodel::StructType> _struct_type;
485  OptionalSize _serialized_struct_as_element_offset =
486  {}; // these values are greater 0 if the struct is used within another struct and we
487  // calculate that element
488  OptionalSize _deserialized_struct_as_element_offset =
489  {}; // these values are greater 0 if the struct is used within another struct and we
490  // calculate that element
491  const TypeInfo* _type_info = nullptr;
492 };
493 
494 } // namespace dd
495 } // namespace ddl
496 
497 #endif // DD_DDL_STRUCT_ACCESS_H_INCLUDED
The Data Definiton class uses the validation model to keep a Data Definition datamodel (ddl::dd::data...
Definition: dd.h:87
Element Size Info is important to get the calculate the TypeInfo for StructType.
Class to access and obtain the byte position and other information of a instance of this element with...
size_t getDeserializedBytePos(size_t array_size=0) const
Get the Deserialized Byte Pos relative to the first byte position of the struct obtained by dd::DataD...
bool isAfterDynamic() const
The element is on a byte position after a dynamic element, the byte position can not be calculated un...
StructElementAccess(const std::shared_ptr< const datamodel::StructType::Element > &elem, OptionalSize serialized_element_bit_offset, OptionalSize deserialized_element_byte_offset, OptionalSize array_pos)
Construct a new Struct Element Access object.
StructTypeAccess getStructTypeAccess(size_t array_pos=0) const
Get the Struct Type Access if the element depends on a structtype.
size_t getSerializedBitSize() const
Get the serialized Bit size of the value.
std::shared_ptr< const datamodel::StructType > getStructType() const
Gets the Struct Type if the element is dependent on a structtype.
size_t getDeserializedByteSize() const
Get the Byte size (depends on alignments, ddlversion and arraysize)
const datamodel::StructType::Element & getElement() const
Get the Element Information which is also part of the data definition.
size_t getSerializedBitOffset(size_t array_size=0) const
Get SerializedBitOsset obtained by dd::DataDefinition::getStructTypeAccess.
bool isDynamic() const
Retieve information if this element is a dynamic array.
size_t getSerializedBytePos(size_t array_size=0) const
Get SerializedBytePos obtained by dd::DataDefinition::getStructTypeAccess.
StructElementAccess & operator=(StructElementAccess &&)=default
Default move assignment.
OptionalSize getArrayPos() const
Get the Array Pos, if this element was retrieved via StructTypeAccess::getElementByPath and the opera...
TypeOfType getTypeOfType() const
Get the Type Of the type.
size_t getSerializedTypeBitSize() const
Get the serialized bit size of one element.
StructElementAccess & operator=(const StructElementAccess &)=default
Default copy assignment.
StructElementAccess()=delete
deleted CTOR
StructElementAccess(const StructElementAccess &)=default
Default copy CTOR.
size_t getDeserializedTypeByteSize() const
Get the Serialized Type Byte size.
StructElementAccess(std::nullptr_t)
empty element access.
std::shared_ptr< const datamodel::EnumType > getEnumType() const
Gets the Enum Type if the element is dependent on a enumtype.
std::shared_ptr< const datamodel::DataType > getDataType() const
Gets the Data Type if the element is dependent on a datatype.
StructElementAccess(StructElementAccess &&)=default
Default move CTOR.
Iterator to iterate thru the StructTypeAccess.
const_pointer operator->() const
pointer access (check for end!)
self_type operator++()
increasing operator to the next position.
bool operator==(const self_type &rhs) const
checks for equality (refering the same element!)
std::forward_iterator_tag iterator_category
iterator type definition
bool operator!=(const self_type &rhs) const
checks for not equality (does not refer the same element!)
const StructElementAccess & const_reference
const reference value type definition
StructElementAccess * pointer
pointer value type definition
StructElementAccessIterator self_type
this iterator type definition
StructElementAccessIterator(datamodel::StructType::Elements::const_iterator other_it, datamodel::StructType::Elements::const_iterator end_it, OptionalSize struct_ser, OptionalSize struct_deser)
Construct a new Struct Element Access Iterator.
const StructElementAccess * const_pointer
pointer to const data value type definition
self_type operator++(int junk)
iterator increasing.
const_reference operator*() const
defering access (check for end!)
StructElementAccess value_type
iterator value type definition
int difference_type
difference value type definition
StructElementAccess & reference
reference value type definition
Accessing class for a instance of a struct.
StructTypeAccess(const std::shared_ptr< const datamodel::StructType > &struct_type)
Construct a new Struct Type Access object.
const datamodel::StructType & getStructType() const
Get the Struct Type it refers to (for data definition information)
const_iterator begin() const
constant range based iterator access
size_t getStaticSerializedBitSize() const
Get the known bitsize of this instance (this is usually the last position + sizeof last element)
const_iterator cbegin() const
constant iterator access
StructTypeAccess(std::nullptr_t)
Construct a empty Struct Type Access.
size_t getStaticUnalignedStructSize() const
Get the known unaligned Static Struct Size of this instance (this is usually the last position + size...
size_t getStaticStructSize() const
Get the known Static Struct Size of this instance.
StructElementAccess getElementByPath(const std::string name_path) const
Get the StructElementAccess information class by path.
StructTypeAccess & operator=(StructTypeAccess &&)=default
Move assignment operator.
bool isDynamic() const
retrieves information if it contains dynamic elements and so has dynamic size.
const_iterator cend() const
constant end iterator
StructTypeAccess & operator=(const StructTypeAccess &)=default
Copy CTOR.
const_iterator end() const
constant range based end iterator
StructTypeAccess()=delete
default CTOR is deleted
StructTypeAccess(const std::shared_ptr< const datamodel::StructType > &struct_type, OptionalSize serialized_struct_offset, OptionalSize deserialized_struct_offset)
Construct a new Struct Type Access object.
const StructElementAccessIterator const_iterator
iterator type of this struct
StructTypeAccess(const StructTypeAccess &)=default
copy assignment operator
StructTypeAccess(StructTypeAccess &&)=default
Move CTOR.
observable DataDefinition object class for a Element of a StructType.
observable DataDefinition object class to describe StructType.
container_type::const_iterator const_iterator
local definition of the container const_iterator
OO DataDefinition Redesign.
TypeOfType
Classification of a Type.
@ struct_type
the type is a struct type (StructType)
utility::Optional< size_t > OptionalSize
Optional Size Type.