#ifndef SERIALIZEELEMENT_H_ #define SERIALIZEELEMENT_H_ #include #include #include /** * @brief This class is used to mark datatypes for serialization with the * SerialLinkedListAdapter * @details * Used by declaring any arbitrary datatype with SerializeElement myVariable, * inside a SerialLinkedListAdapter implementation and setting the sequence * of objects with setNext() and setStart(). * Serilization and Deserialization is then performed automatically in * specified sequence order. * @ingroup serialize */ template class SerializeElement : public SerializeIF, public LinkedElement { public: /** * Arguments are forwarded to the element datatype constructor * @param args */ template SerializeElement(Args... args) : LinkedElement(this), entry(std::forward(args)...) { } SerializeElement() : LinkedElement(this) { } T entry; ReturnValue_t serialize(uint8_t** buffer, size_t* size, const size_t max_size, bool bigEndian) const { return SerializeAdapter::serialize(&entry, buffer, size, max_size, bigEndian); } size_t getSerializedSize() const { return SerializeAdapter::getSerializedSize(&entry); } virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, bool bigEndian) { return SerializeAdapter::deSerialize(&entry, buffer, size, bigEndian); } operator T() { return entry; } SerializeElement &operator=(T newValue) { entry = newValue; return *this; } T *operator->() { return &entry; } }; #endif /* SERIALIZEELEMENT_H_ */