Serialization documentation update
This commit is contained in:
@ -14,29 +14,30 @@
|
||||
//This is where we need the SerializeAdapter!
|
||||
|
||||
/**
|
||||
* An alternative to the AutoSerializeAdapter functions to implement the conversion
|
||||
* of object data to data streams or vice-versa, using linked lists.
|
||||
* @brief Implement the conversion of object data to data streams
|
||||
* or vice-versa, using linked lists.
|
||||
* @details
|
||||
* An alternative to the AutoSerializeAdapter functions
|
||||
* - All object members with a datatype are declared as SerializeElement<element_type>
|
||||
* inside the class implementing this adapter.
|
||||
* - The element type can also be a SerialBufferAdapter to de-/serialize buffers,
|
||||
* with a known size, where the size can also be serialized
|
||||
* - The element type can also be a SerialFixedArrayListAdapter to de-/serialize buffers
|
||||
* with a size header, which is scanned automatically
|
||||
*
|
||||
* All object members with a datatype are declared as SerializeElement<element_type> inside the class
|
||||
* implementing this adapter.
|
||||
* The sequence of objects is defined in the constructor by using
|
||||
* the setStart and setNext functions.
|
||||
*
|
||||
* Buffers with a size header inside that class can be declared with
|
||||
* SerialFixedArrayListAdapter<uint8_t,MAX_BUFFER_LENGTH,typeOfMaxData>.
|
||||
* typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows
|
||||
* and MAX_BUFFER_LENGTH specifies the maximum allowed value for the buffer size.
|
||||
* Please note that a direct link from a linked element to a SerialFixedArrayListAdapter element is not possible and a
|
||||
* helper needs to be used by calling <LinkedElement>.setNext(&linkHelper)
|
||||
* and initialising the link helper as linkHelper(&SerialFixedArrayListAdapterElement).
|
||||
* - The serialization process is done by instantiating the class and
|
||||
* calling the serialize after all SerializeElement entries have been set by
|
||||
* using a constructor or setter functions. An additional size variable can be supplied
|
||||
* which is calculated/incremented automatically
|
||||
* - The deserialization process is done by instantiating the class and supplying
|
||||
* a buffer with the data which is converted into an object. The size of
|
||||
* data to serialize can be supplied and is decremented in the function
|
||||
*
|
||||
* For buffers with no size header, declare
|
||||
* SerializeElement<SerializeBufferAdapter<T>> and initialise the buffer adapter in the constructor.
|
||||
*
|
||||
* The sequence of objects is defined in the constructor by using the setStart and setNext functions.
|
||||
*
|
||||
* The serialization and deserialization process is done by instantiating the class and
|
||||
* calling the serialize or deserialize function.
|
||||
*
|
||||
* \ingroup serialize
|
||||
* @ingroup serialize
|
||||
*/
|
||||
template<typename T, typename count_t = uint8_t>
|
||||
class SerialLinkedListAdapter: public SinglyLinkedList<T>, public SerializeIF {
|
||||
@ -53,6 +54,16 @@ public:
|
||||
SinglyLinkedList<T>(), printCount(printCount) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize object implementing this adapter into the supplied buffer
|
||||
* and calculate the serialized size
|
||||
* @param buffer [out] Object is serialized into this buffer. Note that the buffer pointer
|
||||
* *buffer is incremented automatically inside the respective serialize functions
|
||||
* @param size [out] Calculated serialized size. Don't forget to set to 0.
|
||||
* @param max_size
|
||||
* @param bigEndian Specify endianness
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
||||
const uint32_t max_size, bool bigEndian) const {
|
||||
if (printCount) {
|
||||
@ -95,6 +106,13 @@ public:
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize supplied buffer with supplied size into object implementing this adapter
|
||||
* @param buffer
|
||||
* @param size Decremented in respective deSerialize functions automatically
|
||||
* @param bigEndian Specify endianness
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
||||
bool bigEndian) {
|
||||
return deSerialize(SinglyLinkedList<T>::start, buffer, size, bigEndian);
|
||||
|
Reference in New Issue
Block a user