ADTF  3.18.2
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/extern/pkg_ddl/include/adtfddl/codec/static_codec.h
Go to the documentation of this file.
1 
7 #ifndef _DDL_STATIC_CODEC_CLASS_HEADER_
8 #define _DDL_STATIC_CODEC_CLASS_HEADER_
9 
10 
11 namespace adtf_ddl
12 {
13 
14 class cStructLayout;
15 class cElementAccessor;
16 
21 {
22  public:
28 
33 
38 
43  virtual tResult IsValid() const;
44 
48  virtual size_t GetElementCount() const;
49 
56  tResult GetElement(size_t nIndex, const tStructElement*& pElement) const;
57 
65  tResult GetElementValue(size_t nIndex, void* pValue) const;
66 
73  tResult GetElementValue(size_t nIndex, A_UTILS_NS::cVariant& oValue) const;
74 
79  const void* GetElementAddress(size_t nIndex) const;
80 
86 
91 
98 
104  static const char* GetStructElementName(const tStructElement* pElement);
105 
106  protected:
107  friend class cCodecFactory;
108 
110  cStaticDecoder(std::shared_ptr<const cStructLayout> pLayout,
111  const void* pData, size_t nDataSize,
112  tDataRepresentation eRep);
114  virtual const tStructLayoutElement* GetLayoutElement(size_t nIndex) const;
115 
116  protected:
118  std::shared_ptr<const cStructLayout> m_pLayout;
120  const void* m_pData;
122  size_t m_nDataSize;
124  const cElementAccessor* m_pElementAccessor;
125 };
126 
131 {
132  public:
137  cStaticCodec() = default;
138 
143 
148 
156  tResult SetElementValue(size_t nIndex, const void* pValue);
157 
164  tResult SetElementValue(size_t nIndex, const A_UTILS_NS::cVariant& oValue);
165 
170  void* GetElementAddress(size_t nIndex);
172 
178 
179  private:
180  friend class cCodecFactory;
182  cStaticCodec(std::shared_ptr<const cStructLayout> pLayout, void* pData, size_t nDataSize,
183  tDataRepresentation eRep);
184 };
185 
186 }
187 
188 #endif
cStaticCodec & operator=(cStaticCodec &&)=default
Move assignment operator.
cStaticCodec(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.
cStaticCodec()=default
Default constructor.
tResult SetElementValue(size_t nIndex, const A_UTILS_NS::cVariant &oValue)
Sets the current value of the given element to the given value.
cStaticCodec(cStaticCodec &&)=default
Move constructor.
const void * GetElementAddress(size_t nIndex) const
cStaticDecoder(cStaticDecoder &&)=default
Move constructor.
cStaticDecoder & operator=(cStaticDecoder &&)=default
Move assignment operator.
size_t GetStaticBufferSize(tDataRepresentation eRep=tDataRepresentation::Deserialized) const
virtual tResult IsValid() const
tResult GetElementValue(size_t nIndex, A_UTILS_NS::cVariant &oValue) const
Returns the current value of the given element as a variant.
tDataRepresentation GetRepresentation() const
A_UTILS_NS::cString GetElementValueString(size_t nIndex) const
Returns the current value of the given element as a string.
tResult GetElement(size_t nIndex, const tStructElement *&pElement) const
Access information about an element.
cStaticDecoder(std::shared_ptr< const cStructLayout > pLayout, const void *pData, size_t nDataSize, tDataRepresentation eRep)
For internal use only.
virtual size_t GetElementCount() const
virtual const tStructLayoutElement * GetLayoutElement(size_t nIndex) const
For internal use only.
static const char * GetStructElementName(const tStructElement *pElement)
Access information about an element.
cStaticDecoder()
Default constructor.
tResult GetElementValue(size_t nIndex, void *pValue) const
Returns the current value of the given element by copying its data to the passed-in location.
Namespace for the mainpage_pkg_ddl.