Serial Fixed Array List template type clarifications

This commit is contained in:
Robin Müller 2020-01-15 17:30:23 +01:00
parent 9aa57f29b8
commit 1437f33027
3 changed files with 16 additions and 10 deletions

View File

@ -12,6 +12,7 @@
#include <utility> #include <utility>
/** /**
* Also serializes length field !
* \ingroup serialize * \ingroup serialize
*/ */
template<typename T, typename count_t = uint8_t> template<typename T, typename count_t = uint8_t>

View File

@ -11,7 +11,8 @@
* Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer. * Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer.
* *
* Can be used with SerialLinkedListAdapter by declaring a SerializeElement with * Can be used with SerialLinkedListAdapter by declaring a SerializeElement with
* SerialElement<SerialBufferAdapter<bufferLengthType(will be uint8_t mostly)>> serialBufferElement * SerialElement<SerialBufferAdapter<bufferLengthType(will be uint8_t mostly)>> serialBufferElement.
* Right now, the SerialBufferAdapter must always be initialized with the buffer and size !
* *
* \ingroup serialize * \ingroup serialize
*/ */

View File

@ -8,34 +8,38 @@
* @brief This adapter provides an interface for SerializeIF to serialize and deserialize * @brief This adapter provides an interface for SerializeIF to serialize and deserialize
* buffers with a header containing the buffer length. * buffers with a header containing the buffer length.
* @details * @details
*
* Can be used by SerialLinkedListAdapter by using this type in * Can be used by SerialLinkedListAdapter by using this type in
* SerializeElement<>. * SerializeElement<>.
*
* Buffers with a size header inside that class can be declared with * Buffers with a size header inside that class can be declared with
* SerialFixedArrayListAdapter<bufferType,MAX_BUFFER_LENGTH,typeOfMaxData>. * SerialFixedArrayListAdapter<BUFFER_TYPE, MAX_BUFFER_LENGTH, LENGTH_FIELD_TYPE>.
* typeOfMaxData specifies the data type of the buffer header containing the buffer size that follows * LENGTH_FIELD_TYPE specifies the data type of the buffer header containing the buffer size
* and MAX_BUFFER_LENGTH specifies the maximum allowed value for the buffer size. * (defaults to 1 byte length field) that follows and MAX_BUFFER_LENGTH specifies
* the maximum allowed value for the buffer size.
*
* The sequence of objects is defined in the constructor by using the setStart and setNext functions. * The sequence of objects is defined in the constructor by using the setStart and setNext functions.
* *
* @ingroup serialize * @ingroup serialize
*/ */
template<typename T, uint32_t MAX_SIZE, typename count_t = uint8_t> template<typename BUFFER_TYPE, uint32_t MAX_SIZE, typename count_t = uint8_t>
class SerialFixedArrayListAdapter : public FixedArrayList<T, MAX_SIZE, count_t>, public SerializeIF { class SerialFixedArrayListAdapter : public FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>, public SerializeIF {
public: public:
template<typename... Args> template<typename... Args>
SerialFixedArrayListAdapter(Args... args) : FixedArrayList<T, MAX_SIZE, count_t>(std::forward<Args>(args)...) { SerialFixedArrayListAdapter(Args... args) : FixedArrayList<BUFFER_TYPE, MAX_SIZE, count_t>(std::forward<Args>(args)...) {
} }
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size, ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
const uint32_t max_size, bool bigEndian) const { const uint32_t max_size, bool bigEndian) const {
return SerialArrayListAdapter<T, count_t>::serialize(this, buffer, size, max_size, bigEndian); return SerialArrayListAdapter<BUFFER_TYPE, count_t>::serialize(this, buffer, size, max_size, bigEndian);
} }
uint32_t getSerializedSize() const { uint32_t getSerializedSize() const {
return SerialArrayListAdapter<T, count_t>::getSerializedSize(this); return SerialArrayListAdapter<BUFFER_TYPE, count_t>::getSerializedSize(this);
} }
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size, ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
bool bigEndian) { bool bigEndian) {
return SerialArrayListAdapter<T, count_t>::deSerialize(this, buffer, size, bigEndian); return SerialArrayListAdapter<BUFFER_TYPE, count_t>::deSerialize(this, buffer, size, bigEndian);
} }
}; };