changes taken over
This commit is contained in:
parent
305d8ef840
commit
721b981df2
@ -1,17 +1,10 @@
|
||||
/**
|
||||
* @file SerialLinkedListAdapter.h
|
||||
* @brief This file defines the SerialLinkedListAdapter class.
|
||||
* @date 22.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#ifndef SERIALLINKEDLISTADAPTER_H_
|
||||
#define SERIALLINKEDLISTADAPTER_H_
|
||||
#ifndef FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_
|
||||
#define FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_
|
||||
|
||||
#include "../container/SinglyLinkedList.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serialize/SerializeElement.h"
|
||||
#include "../serialize/SerializeIF.h"
|
||||
//This is where we need the SerializeAdapter!
|
||||
#include "SerializeAdapter.h"
|
||||
#include "SerializeElement.h"
|
||||
#include "SerializeIF.h"
|
||||
|
||||
/**
|
||||
* @brief Implement the conversion of object data to data streams
|
||||
@ -22,7 +15,7 @@
|
||||
* SerializeElement<element_type> members inside the class
|
||||
* implementing this adapter.
|
||||
* - 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
|
||||
* 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.
|
||||
* The size of data to serialize can be supplied and is
|
||||
* decremented in the function. Range checking is done internally.
|
||||
*
|
||||
* @author baetz
|
||||
* @ingroup serialize
|
||||
*/
|
||||
template<typename T, typename count_t = uint8_t>
|
||||
class SerialLinkedListAdapter: public SinglyLinkedList<T>, public SerializeIF {
|
||||
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,
|
||||
bool printCount = false) :
|
||||
@ -85,7 +69,7 @@ public:
|
||||
uint8_t** buffer, size_t* size, size_t maxSize,
|
||||
Endianness streamEndianness) {
|
||||
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,
|
||||
streamEndianness);
|
||||
element = element->getNext();
|
||||
@ -104,7 +88,7 @@ public:
|
||||
|
||||
static size_t getSerializedSize(const LinkedElement<T> *element) {
|
||||
size_t size = 0;
|
||||
while (element != NULL) {
|
||||
while (element != nullptr) {
|
||||
size += element->value->getSerializedSize();
|
||||
element = element->getNext();
|
||||
}
|
||||
@ -114,20 +98,31 @@ public:
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||
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,
|
||||
const uint8_t** buffer, size_t* size, Endianness streamEndianness) {
|
||||
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);
|
||||
element = element->getNext();
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
#endif /* SERIALLINKEDLISTADAPTER_H_ */
|
||||
#endif /* FSFW_SERIALIZE_SERIALLINKEDLISTADAPTER_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user