35 lines
852 B
C
Raw Normal View History

2017-03-25 19:01:32 +01:00
#pragma once
#include <stdint.h>
#include <string.h>
#include <iostream>
#include <string>
#include "serialiser/rsserial.h"
#define SERIALIZE_ERROR() std::cerr << __PRETTY_FUNCTION__ << " : "
2017-03-25 19:01:32 +01:00
class RsSerializer: public RsSerialType
2017-03-25 19:01:32 +01:00
{
public:
2017-04-05 18:09:45 +02:00
RsSerializer(uint16_t service_id) : RsSerialType(RS_PKT_VERSION_SERVICE,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-16 19:59:22 +02:00
virtual RsItem *create_item(uint16_t /* service */, uint8_t /* item_sub_id */) const
2017-03-25 19:01:32 +01:00
{
return NULL ;
}
2017-04-05 18:09:45 +02:00
// The following functions overload RsSerialType. They *should not* need to be further overloaded.
2017-04-05 18:09:45 +02:00
RsItem *deserialise(void *data,uint32_t *size) ;
bool serialise(RsItem *item,void *data,uint32_t *size) ;
2017-04-02 14:48:17 +02:00
uint32_t size(RsItem *item) ;
void print(RsItem *item) ;
2017-03-25 19:01:32 +01:00
};