2016-06-15 23:48:41 +02:00
|
|
|
#ifndef SERIALIZEIF_H_
|
|
|
|
#define SERIALIZEIF_H_
|
|
|
|
|
|
|
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
2020-04-21 21:34:03 +02:00
|
|
|
#include <stddef.h>
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2019-08-28 14:50:24 +02:00
|
|
|
/**
|
|
|
|
* \defgroup serialize Serialization
|
|
|
|
* Contains serialisation services.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Translation of objects into data streams.
|
|
|
|
* \ingroup serialize
|
|
|
|
*/
|
2016-06-15 23:48:41 +02:00
|
|
|
class SerializeIF {
|
|
|
|
public:
|
2020-04-21 21:34:03 +02:00
|
|
|
enum class Endianness : uint8_t {
|
|
|
|
BIG, LITTLE, MACHINE
|
|
|
|
};
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::SERIALIZE_IF;
|
2016-06-15 23:48:41 +02:00
|
|
|
static const ReturnValue_t BUFFER_TOO_SHORT = MAKE_RETURN_CODE(1);
|
|
|
|
static const ReturnValue_t STREAM_TOO_SHORT = MAKE_RETURN_CODE(2);
|
|
|
|
static const ReturnValue_t TOO_MANY_ELEMENTS = MAKE_RETURN_CODE(3);
|
|
|
|
|
|
|
|
virtual ~SerializeIF() {
|
|
|
|
}
|
|
|
|
|
2020-04-21 21:34:03 +02:00
|
|
|
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
2020-04-21 22:28:43 +02:00
|
|
|
size_t maxSize, Endianness streamEndianness) const = 0;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-04-21 21:34:03 +02:00
|
|
|
virtual size_t getSerializedSize() const = 0;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-04-21 21:34:03 +02:00
|
|
|
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
|
|
|
Endianness streamEndianness) = 0;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SERIALIZEIF_H_ */
|