2017-03-25 19:01:32 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
|
2017-04-01 18:05:53 +02:00
|
|
|
#include "serialiser/rsserial.h"
|
|
|
|
|
|
|
|
#define SERIALIZE_ERROR() std::cerr << __PRETTY_FUNCTION__ << " : "
|
2017-03-25 19:01:32 +01:00
|
|
|
|
2017-04-01 18:05:53 +02:00
|
|
|
class RsSerializer: public RsSerialType
|
2017-03-25 19:01:32 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-04-01 18:05:53 +02:00
|
|
|
RsSerializer(uint16_t service_id) : RsSerialType(service_id) {}
|
|
|
|
|
2017-03-25 19:01:32 +01:00
|
|
|
/*! create_item
|
|
|
|
* should be overloaded to create the correct type of item depending on the data
|
|
|
|
*/
|
2017-04-05 16:53:20 +02:00
|
|
|
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */)
|
2017-03-25 19:01:32 +01:00
|
|
|
{
|
|
|
|
return NULL ;
|
|
|
|
}
|
|
|
|
|
2017-04-04 14:01:33 +02:00
|
|
|
// The following functions *should not* be overloaded.
|
|
|
|
// They are kept public in order to allow them to be called if needed.
|
|
|
|
|
2017-04-02 14:48:17 +02:00
|
|
|
RsItem *deserialise(const uint8_t *data,uint32_t size) ;
|
|
|
|
bool serialise(RsItem *item,uint8_t *const data,uint32_t size) ;
|
|
|
|
uint32_t size(RsItem *item) ;
|
2017-04-04 14:01:33 +02:00
|
|
|
void print(RsItem *item) ;
|
2017-03-25 19:01:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|