2016-06-15 23:48:41 +02:00
|
|
|
#ifndef SERIALFIXEDARRAYLISTADAPTER_H_
|
|
|
|
#define SERIALFIXEDARRAYLISTADAPTER_H_
|
|
|
|
|
|
|
|
#include <framework/container/FixedArrayList.h>
|
|
|
|
#include <framework/serialize/SerialArrayListAdapter.h>
|
|
|
|
|
2019-08-28 14:50:24 +02:00
|
|
|
/**
|
2019-12-08 22:57:03 +01:00
|
|
|
* @brief This adapter provides an interface for SerializeIF to serialize and deserialize
|
|
|
|
* buffers with a header containing the buffer length.
|
|
|
|
* @details
|
|
|
|
* Can be used by SerialLinkedListAdapter by using this type in
|
|
|
|
* SerializeElement<>
|
2019-11-02 23:30:12 +01:00
|
|
|
* Buffers with a size header inside that class can be declared with
|
2019-12-08 22:57:03 +01:00
|
|
|
* SerialFixedArrayListAdapter<bufferType,MAX_BUFFER_LENGTH,typeOfMaxData>.
|
2019-11-02 23:30:12 +01:00
|
|
|
* 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.
|
|
|
|
* The sequence of objects is defined in the constructor by using the setStart and setNext functions.
|
|
|
|
*
|
2019-12-08 22:57:03 +01:00
|
|
|
* @ingroup serialize
|
2019-08-28 14:50:24 +02:00
|
|
|
*/
|
2016-06-15 23:48:41 +02:00
|
|
|
template<typename T, uint32_t MAX_SIZE, typename count_t = uint8_t>
|
|
|
|
class SerialFixedArrayListAdapter : public FixedArrayList<T, MAX_SIZE, count_t>, public SerializeIF {
|
|
|
|
public:
|
|
|
|
template<typename... Args>
|
|
|
|
SerialFixedArrayListAdapter(Args... args) : FixedArrayList<T, MAX_SIZE, count_t>(std::forward<Args>(args)...) {
|
|
|
|
}
|
2019-12-08 19:04:53 +01:00
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
ReturnValue_t serialize(uint8_t** buffer, uint32_t* size,
|
|
|
|
const uint32_t max_size, bool bigEndian) const {
|
|
|
|
return SerialArrayListAdapter<T, count_t>::serialize(this, buffer, size, max_size, bigEndian);
|
|
|
|
}
|
2019-12-08 19:04:53 +01:00
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
uint32_t getSerializedSize() const {
|
|
|
|
return SerialArrayListAdapter<T, count_t>::getSerializedSize(this);
|
|
|
|
}
|
|
|
|
ReturnValue_t deSerialize(const uint8_t** buffer, int32_t* size,
|
|
|
|
bool bigEndian) {
|
|
|
|
return SerialArrayListAdapter<T, count_t>::deSerialize(this, buffer, size, bigEndian);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SERIALFIXEDARRAYLISTADAPTER_H_ */
|