ADTF  3.18.2
codec_legacy.h
Go to the documentation of this file.
1 
15 #ifndef DDL_CODEC_LEGACY_CLASS_HEADER
16 #define DDL_CODEC_LEGACY_CLASS_HEADER
17 
18 #include <a_util/preprocessor/deprecated.h> // DEV_ESSENTIAL_DEPRECATED()
19 #include <a_util/result.h>
20 #include <ddl/codec/codec.h>
22 
24 #define DEV_ESSENTIAL_DEPRECATED_DECODER \
25  DEV_ESSENTIAL_DEPRECATED("Use the new ddl::codec::Decoder() instead.")
26 
27 #define DEV_ESSENTIAL_DEPRECATED_CODEC \
28  DEV_ESSENTIAL_DEPRECATED("Use the new ddl::codec::Codec() instead.")
30 
31 namespace ddl {
32 class Codec;
33 
37 struct LegacyOffsets {
38  size_t deserialized;
39  size_t serialized;
40 };
41 
46 class Decoder : public StaticDecoder {
47 public:
51  DEV_ESSENTIAL_DEPRECATED_DECODER
52  Decoder() = default;
53 
57  Decoder(Decoder&&) = default;
58 
62  DEV_ESSENTIAL_DEPRECATED_DECODER
63  Decoder& operator=(Decoder&&) = default;
64 
68  Decoder(const Decoder&) = delete;
69 
73  Decoder& operator=(const Decoder&) = delete;
74 
78  a_util::result::Result isValid() const override;
79 
83  size_t getElementCount() const override;
84 
90 
98  Codec makeCodecFor(void* data, size_t data_size, DataRepresentation rep) const;
99 
100 protected:
101  friend class CodecFactory;
103  virtual const void* getLayoutElement(size_t index) const;
105  Decoder(const std::shared_ptr<LegacyCodecAccess>& legacy_codec_access);
106 
109  Decoder(std::shared_ptr<const StructLayout>,
110  const void* data,
111  size_t data_size,
112  DataRepresentation rep);
113 
114 private:
117  std::shared_ptr<std::vector<int32_t>> _compat_dynamic_elements;
121 };
122 
129 class Codec : public Decoder {
130 public:
134  DEV_ESSENTIAL_DEPRECATED_CODEC
135  Codec() = default;
136 
140  Codec(Codec&&) = default;
141 
145  DEV_ESSENTIAL_DEPRECATED_CODEC
146  Codec& operator=(Codec&&) = default;
147 
155  a_util::result::Result setElementValue(size_t index, const void* value);
156 
164 
169  void* getElementAddress(size_t index);
171 
177 
178 protected:
179  friend class CodecFactory;
180  friend class Decoder;
184  Codec(std::shared_ptr<const StructLayout> layout,
185  void* data,
186  size_t data_size,
187  DataRepresentation rep);
189  Codec(codec::Codec&& codec);
190 };
191 
192 } // namespace ddl
193 
194 #endif // DDL_CODEC_LEGACY_CLASS_HEADER
A common result class usable as return value throughout.
Factory class for ddl codecs.
Decoder for dynamic structures defined by a DataDefinition definition.
Definition: codec_legacy.h:129
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.
Codec(std::shared_ptr< const StructLayout > layout, void *data, size_t data_size, DataRepresentation rep)
For internal use only.
void * getElementAddress(size_t index)
DEV_ESSENTIAL_DEPRECATED_CODEC Codec & operator=(Codec &&)=default
Move assignment operator.
Codec(codec::Codec &&codec)
For internal use only.
Codec(Codec &&)=default
Move constructor.
DEV_ESSENTIAL_DEPRECATED_CODEC Codec()=default
Default constructor.
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 dynamic structures defined by a DataDefinition definition.
Definition: codec_legacy.h:46
Codec makeCodecFor(void *data, size_t data_size, DataRepresentation rep) const
Create a new codec with the current dynamic structure layout for a new data buffer.
size_t getElementCount() const override
LegacyOffsets _compat_buffer_sizes
For internal use only.
Definition: codec_legacy.h:120
Decoder(Decoder &&)=default
Move constructor.
DEV_ESSENTIAL_DEPRECATED_DECODER Decoder()=default
Default constructor.
Decoder(std::shared_ptr< const StructLayout >, const void *data, size_t data_size, DataRepresentation rep)
This CTOR must stay there for binary compatible reason due to an inline usage within old CodecFactory...
size_t getBufferSize(DataRepresentation rep=deserialized) const
Decoder(const Decoder &)=delete
No copy constructor.
Decoder & operator=(const Decoder &)=delete
No copy assignment operator.
virtual const void * getLayoutElement(size_t index) const
this virtual pointer must stay for binary compatiblity.
a_util::result::Result isValid() const override
DEV_ESSENTIAL_DEPRECATED_DECODER Decoder & operator=(Decoder &&)=default
Move assignment operator.
std::shared_ptr< std::vector< int32_t > > _compat_dynamic_elements
For internal use only.
Definition: codec_legacy.h:117
Decoder(const std::shared_ptr< LegacyCodecAccess > &legacy_codec_access)
For internal use only.
Decoder for static structures defined by a DataDefinition definition.
const void * getElementAddress(size_t index) const
Definition of preprocessor macro DEV_ESSENTIAL_DEPRECATED.
Definition of old StaticCodec legacy header for old Codec API.
Legacy offset structure for binary compatiblity.
Definition: codec_legacy.h:37
size_t deserialized
legacy value
Definition: codec_legacy.h:38
size_t serialized
legacy value
Definition: codec_legacy.h:39
Common include for component a_util::result.