ADTF  3.18.2
static_codec_legacy.h
Go to the documentation of this file.
1 
15 #ifndef DDL_STATIC_CODEC_LEGACY_CLASS_HEADER
16 #define DDL_STATIC_CODEC_LEGACY_CLASS_HEADER
17 
18 #include <a_util/preprocessor/deprecated.h> // DEV_ESSENTIAL_DEPRECATED()
19 #include <ddl/codec/static_codec.h>
20 
22 #define DEV_ESSENTIAL_DEPRECATED_STATIC_DECODER \
23  DEV_ESSENTIAL_DEPRECATED("Use the new ddl::codec::StaticDecoder() instead.")
24 
25 #define DEV_ESSENTIAL_DEPRECATED_STATIC_CODEC \
26  DEV_ESSENTIAL_DEPRECATED("Use the new ddl::codec::StaticCodec() instead.")
28 
29 namespace ddl {
30 
31 // forward declaration for legacy codec access
32 struct LegacyCodecAccess;
33 class StructLayout;
34 
40 public:
42  ~StaticDecoder() = default;
46  DEV_ESSENTIAL_DEPRECATED_STATIC_DECODER
51  StaticDecoder(const StaticDecoder&) = delete;
52 
57 
62 
66  DEV_ESSENTIAL_DEPRECATED_STATIC_DECODER
68 
74 
78  virtual size_t getElementCount() const;
79 
86  a_util::result::Result getElement(size_t index, const StructElement*& element) const;
87 
95  a_util::result::Result getElementValue(size_t index, void* value) const;
96 
104 
109  const void* getElementAddress(size_t index) const;
110 
116 
121 
122 protected:
123  friend class CodecFactory;
127  StaticDecoder(std::shared_ptr<const StructLayout> layout,
128  const void* data,
129  size_t data_size,
130  DataRepresentation rep);
131 
133  StaticDecoder(const std::shared_ptr<LegacyCodecAccess>& legacy_codec_access);
134 
135 protected:
137  std::shared_ptr<LegacyCodecAccess> _legacy_access;
140  const void* _compat_data;
147 };
148 
153 class StaticCodec : public StaticDecoder {
154 public:
158  DEV_ESSENTIAL_DEPRECATED_STATIC_CODEC
163  StaticCodec(const StaticCodec&) = delete;
164 
168  StaticCodec& operator=(const StaticCodec&) = delete;
169 
173  StaticCodec(StaticCodec&&) = default;
174 
178  DEV_ESSENTIAL_DEPRECATED_STATIC_CODEC
180 
188  a_util::result::Result setElementValue(size_t index, const void* value);
189 
197 
202  void* getElementAddress(size_t index);
204 
210 
211 protected:
212  friend class CodecFactory;
216  StaticCodec(std::shared_ptr<const StructLayout> layout,
217  void* data,
218  size_t data_size,
219  DataRepresentation rep);
220 };
221 
222 } // namespace ddl
223 
224 #endif // DDL_STATIC_CODEC_LEGACY_CLASS_HEADER
A common result class usable as return value throughout.
Factory class for ddl codecs.
Codec for static structures defined by a DataDefinition definition.
StaticCodec(const StaticCodec &)=delete
Noncopyable.
StaticCodec & operator=(const StaticCodec &)=delete
Noncopyable.
a_util::result::Result setConstants()
Sets all elements to their constant values defined in the DataDefinition.
a_util::result::Result setElementValue(size_t index, const void *value)
Sets the current value of the given element by copying its data from the passed-in location.
StaticCodec(std::shared_ptr< const StructLayout > layout, void *data, size_t data_size, DataRepresentation rep)
For internal use only.
StaticCodec(StaticCodec &&)=default
Move constructor.
DEV_ESSENTIAL_DEPRECATED_STATIC_CODEC StaticCodec()
Default constructor.
void * getElementAddress(size_t index)
DEV_ESSENTIAL_DEPRECATED_STATIC_CODEC StaticCodec & operator=(StaticCodec &&)=default
Move assignment operator.
a_util::result::Result setElementValue(size_t index, const a_util::variant::Variant &value)
Sets the current value of the given element to the given value.
Decoder for static structures defined by a DataDefinition definition.
size_t _compat_data_size
For internal use only.
StaticDecoder(const StaticDecoder &)=delete
Noncopyable.
a_util::result::Result getElement(size_t index, const StructElement *&element) const
Access information about an element.
const void * _compat_element_accessor
For internal use only.
StaticDecoder(std::shared_ptr< const StructLayout > layout, const void *data, size_t data_size, DataRepresentation rep)
For internal use only.
virtual size_t getElementCount() const
StaticDecoder(StaticDecoder &&)=default
Move constructor.
a_util::result::Result getElementValue(size_t index, a_util::variant::Variant &value) const
Returns the current value of the given element as a variant.
DEV_ESSENTIAL_DEPRECATED_STATIC_DECODER StaticDecoder & operator=(StaticDecoder &&)=default
Move assignment operator.
virtual a_util::result::Result isValid() const
~StaticDecoder()=default
virtual DTOR
StaticDecoder & operator=(const StaticDecoder &)=delete
Noncopyable.
const void * _compat_data
For internal use only.
StaticDecoder(const std::shared_ptr< LegacyCodecAccess > &legacy_codec_access)
For internal use only.
DEV_ESSENTIAL_DEPRECATED_STATIC_DECODER StaticDecoder()
Default constructor.
std::shared_ptr< LegacyCodecAccess > _legacy_access
For internal use only.
const void * getElementAddress(size_t index) const
DataRepresentation getRepresentation() const
a_util::result::Result getElementValue(size_t index, void *value) const
Returns the current value of the given element by copying its data to the passed-in location.
size_t getStaticBufferSize(DataRepresentation rep=deserialized) const
Definition of preprocessor macro DEV_ESSENTIAL_DEPRECATED.