ADTF  3.18.2
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/extern/pkg_ddl/include/adtfddl/codec/codec.h
Go to the documentation of this file.
1 
7 #ifndef _DDL_CODEC_CLASS_HEADER_
8 #define _DDL_CODEC_CLASS_HEADER_
9 
10 namespace adtf_ddl
11 {
12 
13 class cCodec;
14 
18 class cDecoder: public cStaticDecoder
19 {
20  public:
25  cDecoder() = default;
26 
30  cDecoder(cDecoder&&) = default;
31 
35  cDecoder& operator=(cDecoder&&) = default;
36 
40  virtual tResult IsValid() const override;
41 
45  virtual size_t GetElementCount() const override;
46 
52 
60  cCodec MakeCodecFor(void* pData, size_t nDataSize, tDataRepresentation eRep) const;
61 
62  protected:
63  friend class cCodecFactory;
65  cDecoder(std::shared_ptr<const cStructLayout> pLayout, const void* pData, size_t nDataSize,
66  tDataRepresentation eRep);
68  cDecoder(const cDecoder& oDecoder, const void* pData, size_t nDataSize,
69  tDataRepresentation eRep);
71  virtual const tStructLayoutElement* GetLayoutElement(size_t nIndex) const override;
72 
73  private:
77  tResult AddDynamicElements(const tDynamicStructLayoutElement& sDynamicElement,
78  tOffsets& sOverallOffsets,
79  const A_UTILS_NS::cString& strPrefix);
81  tResult AddDynamicElement(const tDynamicStructLayoutElement& sDynamicElement,
82  const A_UTILS_NS::cString& strArrayIndex,
83  tOffsets& sOverallOffsets,
84  const A_UTILS_NS::cString& strPrefix);
86  tResult AddStaticStructElements(const tDynamicStructLayoutElement& sDynamicElement,
87  const A_UTILS_NS::cString& strArrayIndex,
88  tOffsets& sOverallOffsets,
89  const A_UTILS_NS::cString& strPrefix);
91  tResult AddDynamicStructElements(const tDynamicStructLayoutElement& sDynamicElement,
92  const A_UTILS_NS::cString& strArrayIndex,
93  tOffsets& sOverallOffsets,
94  const A_UTILS_NS::cString& strPrefix);
96  tResult AddDynamicStructElement(const tStructLayoutElement& sElement);
98  void MoveToAlignment(size_t& nBitOffset, size_t nAlignment);
99 
100  protected:
102  std::shared_ptr<std::vector<tStructLayoutElement>> m_pDynamicElements;
104  tOffsets m_sBufferSizes;
105 };
106 
112 class cCodec: public cDecoder
113 {
114  public:
119  cCodec() = default;
120 
124  cCodec(cCodec&&) = default;
125 
129  cCodec& operator=(cCodec&&) = default;
130 
138  tResult SetElementValue(size_t nIndex, const void* pValue);
139 
146  tResult SetElementValue(size_t nIndex, const A_UTILS_NS::cVariant& oValue);
147 
152  void* GetElementAddress(size_t nIndex);
154 
160 
161  protected:
162  friend class cCodecFactory;
163  friend class cDecoder;
165  cCodec(std::shared_ptr<const cStructLayout> pLayout, void* pData, size_t nDataSize,
166  tDataRepresentation eRep);
168  cCodec(const cDecoder& oDecoder, void* pData, size_t nDataSize,
169  tDataRepresentation eRep);
170 };
171 
172 
173 }
174 
175 #endif
cCodec()=default
Default constructor.
cCodec & operator=(cCodec &&)=default
Move assignment operator.
cCodec(std::shared_ptr< const cStructLayout > pLayout, void *pData, size_t nDataSize, tDataRepresentation eRep)
For internal use only.
void * GetElementAddress(size_t nIndex)
tResult SetConstants()
Sets all elements to their constant values defined in the DDL.
tResult SetElementValue(size_t nIndex, const void *pValue)
Sets the current value of the given element by copying its data from the passed-in location.
cCodec(cCodec &&)=default
Move constructor.
tResult SetElementValue(size_t nIndex, const A_UTILS_NS::cVariant &oValue)
Sets the current value of the given element to the given value.
cCodec(const cDecoder &oDecoder, void *pData, size_t nDataSize, tDataRepresentation eRep)
For internal use only.
tResult CalculateDynamicElements()
For internal use only.
tResult AddStaticStructElements(const tDynamicStructLayoutElement &sDynamicElement, const A_UTILS_NS::cString &strArrayIndex, tOffsets &sOverallOffsets, const A_UTILS_NS::cString &strPrefix)
For internal use only.
virtual const tStructLayoutElement * GetLayoutElement(size_t nIndex) const override
For internal use only.
virtual size_t GetElementCount() const override
cCodec MakeCodecFor(void *pData, size_t nDataSize, tDataRepresentation eRep) const
Create a new codec with the current dynamic structure layout for a new data buffer.
size_t GetBufferSize(tDataRepresentation eRep=tDataRepresentation::Deserialized) const
tResult AddDynamicElements(const tDynamicStructLayoutElement &sDynamicElement, tOffsets &sOverallOffsets, const A_UTILS_NS::cString &strPrefix)
For internal use only.
cDecoder(cDecoder &&)=default
Move constructor.
cDecoder(std::shared_ptr< const cStructLayout > pLayout, const void *pData, size_t nDataSize, tDataRepresentation eRep)
For internal use only.
tResult AddDynamicStructElements(const tDynamicStructLayoutElement &sDynamicElement, const A_UTILS_NS::cString &strArrayIndex, tOffsets &sOverallOffsets, const A_UTILS_NS::cString &strPrefix)
For internal use only.
cDecoder & operator=(cDecoder &&)=default
Move assignment operator.
cDecoder()=default
Default constructor.
tResult AddDynamicStructElement(const tStructLayoutElement &sElement)
For internal use only.
cDecoder(const cDecoder &oDecoder, const void *pData, size_t nDataSize, tDataRepresentation eRep)
For internal use only.
tResult AddDynamicElement(const tDynamicStructLayoutElement &sDynamicElement, const A_UTILS_NS::cString &strArrayIndex, tOffsets &sOverallOffsets, const A_UTILS_NS::cString &strPrefix)
For internal use only.
void MoveToAlignment(size_t &nBitOffset, size_t nAlignment)
For internal use only.
std::shared_ptr< std::vector< tStructLayoutElement > > m_pDynamicElements
For internal use only.
virtual tResult IsValid() const override
const void * GetElementAddress(size_t nIndex) const
Namespace for the mainpage_pkg_ddl.