changes taken over
This commit is contained in:
parent
305d8ef840
commit
721b981df2
@ -1,17 +1,10 @@
|
|||||||
/**
|
#ifndef FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_
|
||||||
* @file SerialLinkedListAdapter.h
|
#define FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_
|
||||||
* @brief This file defines the SerialLinkedListAdapter class.
|
|
||||||
* @date 22.07.2014
|
|
||||||
* @author baetz
|
|
||||||
*/
|
|
||||||
#ifndef SERIALLINKEDLISTADAPTER_H_
|
|
||||||
#define SERIALLINKEDLISTADAPTER_H_
|
|
||||||
|
|
||||||
#include "../container/SinglyLinkedList.h"
|
#include "../container/SinglyLinkedList.h"
|
||||||
#include "../serialize/SerializeAdapter.h"
|
#include "SerializeAdapter.h"
|
||||||
#include "../serialize/SerializeElement.h"
|
#include "SerializeElement.h"
|
||||||
#include "../serialize/SerializeIF.h"
|
#include "SerializeIF.h"
|
||||||
//This is where we need the SerializeAdapter!
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Implement the conversion of object data to data streams
|
* @brief Implement the conversion of object data to data streams
|
||||||
@ -22,7 +15,7 @@
|
|||||||
* SerializeElement<element_type> members inside the class
|
* SerializeElement<element_type> members inside the class
|
||||||
* implementing this adapter.
|
* implementing this adapter.
|
||||||
* - The element type can also be a SerialBufferAdapter to
|
* - The element type can also be a SerialBufferAdapter to
|
||||||
* de-/serialize buffers with a known size
|
* de-/serialize buffers.
|
||||||
* - The element type can also be a SerialFixedArrayListAdapter to
|
* - The element type can also be a SerialFixedArrayListAdapter to
|
||||||
* de-/serialize buffers with a size header, which is scanned automatically.
|
* de-/serialize buffers with a size header, which is scanned automatically.
|
||||||
*
|
*
|
||||||
@ -37,21 +30,12 @@
|
|||||||
* supplying a buffer with the data which is converted into an object.
|
* supplying a buffer with the data which is converted into an object.
|
||||||
* The size of data to serialize can be supplied and is
|
* The size of data to serialize can be supplied and is
|
||||||
* decremented in the function. Range checking is done internally.
|
* decremented in the function. Range checking is done internally.
|
||||||
*
|
* @author baetz
|
||||||
* @ingroup serialize
|
* @ingroup serialize
|
||||||
*/
|
*/
|
||||||
template<typename T, typename count_t = uint8_t>
|
template<typename T, typename count_t = uint8_t>
|
||||||
class SerialLinkedListAdapter: public SinglyLinkedList<T>, public SerializeIF {
|
class SerialLinkedListAdapter: public SinglyLinkedList<T>, public SerializeIF {
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* Copying is forbidden by deleting the copy constructor and the copy
|
|
||||||
* assignment operator because of the pointers to the linked list members.
|
|
||||||
* Unless the child class implements an own copy constructor or
|
|
||||||
* copy assignment operator, these operation will throw a compiler error.
|
|
||||||
* @param
|
|
||||||
*/
|
|
||||||
SerialLinkedListAdapter(const SerialLinkedListAdapter &) = delete;
|
|
||||||
SerialLinkedListAdapter& operator=(const SerialLinkedListAdapter&) = delete;
|
|
||||||
|
|
||||||
SerialLinkedListAdapter(typename LinkedElement<T>::Iterator start,
|
SerialLinkedListAdapter(typename LinkedElement<T>::Iterator start,
|
||||||
bool printCount = false) :
|
bool printCount = false) :
|
||||||
@ -85,7 +69,7 @@ public:
|
|||||||
uint8_t** buffer, size_t* size, size_t maxSize,
|
uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
|
while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) {
|
||||||
result = element->value->serialize(buffer, size, maxSize,
|
result = element->value->serialize(buffer, size, maxSize,
|
||||||
streamEndianness);
|
streamEndianness);
|
||||||
element = element->getNext();
|
element = element->getNext();
|
||||||
@ -104,7 +88,7 @@ public:
|
|||||||
|
|
||||||
static size_t getSerializedSize(const LinkedElement<T> *element) {
|
static size_t getSerializedSize(const LinkedElement<T> *element) {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
while (element != NULL) {
|
while (element != nullptr) {
|
||||||
size += element->value->getSerializedSize();
|
size += element->value->getSerializedSize();
|
||||||
element = element->getNext();
|
element = element->getNext();
|
||||||
}
|
}
|
||||||
@ -114,20 +98,31 @@ public:
|
|||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) override {
|
Endianness streamEndianness) override {
|
||||||
return deSerialize(SinglyLinkedList<T>::start, buffer, size, streamEndianness);
|
return deSerialize(SinglyLinkedList<T>::start, buffer, size,
|
||||||
|
streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ReturnValue_t deSerialize(LinkedElement<T>* element,
|
static ReturnValue_t deSerialize(LinkedElement<T>* element,
|
||||||
const uint8_t** buffer, size_t* size, Endianness streamEndianness) {
|
const uint8_t** buffer, size_t* size, Endianness streamEndianness) {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
while ((result == HasReturnvaluesIF::RETURN_OK) && (element != NULL)) {
|
while ((result == HasReturnvaluesIF::RETURN_OK) and (element != nullptr)) {
|
||||||
result = element->value->deSerialize(buffer, size, streamEndianness);
|
result = element->value->deSerialize(buffer, size, streamEndianness);
|
||||||
element = element->getNext();
|
element = element->getNext();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copying is forbidden by deleting the copy constructor and the copy
|
||||||
|
* assignment operator because of the pointers to the linked list members.
|
||||||
|
* Unless the child class implements an own copy constructor or
|
||||||
|
* copy assignment operator, these operation will throw a compiler error.
|
||||||
|
* @param
|
||||||
|
*/
|
||||||
|
SerialLinkedListAdapter(const SerialLinkedListAdapter &) = delete;
|
||||||
|
SerialLinkedListAdapter& operator=(const SerialLinkedListAdapter&) = delete;
|
||||||
|
|
||||||
bool printCount;
|
bool printCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SERIALLINKEDLISTADAPTER_H_ */
|
#endif /* FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user