OpenDaVINCI  4.15.3
odcore::serialization::LCMSerializerVisitor Class Reference

#include <LCMSerializerVisitor.h>

Inheritance diagram for odcore::serialization::LCMSerializerVisitor:
Inheritance graph

Public Member Functions

 LCMSerializerVisitor ()
 
virtual ~LCMSerializerVisitor ()
 
virtual void getSerializedData (ostream &o)
 
void setChannelName (const string &channelName)
 
int64_t getHash () const
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, Serializable &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, bool &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, char &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, unsigned char &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, int8_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, int16_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, uint16_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, int32_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, uint32_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, int64_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, uint64_t &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, float &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, double &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, string &v)
 
virtual void visit (const uint32_t &id, const string &longName, const string &shortName, void *data, const uint32_t &size)
 

Static Public Member Functions

static int64_t calculateHash (int64_t v, const char &c)
 
static int64_t calculateHash (int64_t v, const string &s)
 
static float htonf (float f)
 
static double htond (double d)
 
static uint64_t __htonll (uint64_t ui)
 
static int64_t __htonll (int64_t i)
 

Detailed Description

This class provides a serialization visitor to encode data in LCM format (cf. https://github.com/lcm-proj/lcm).

Constructor & Destructor Documentation

odcore::serialization::LCMSerializerVisitor::LCMSerializerVisitor ( )
odcore::serialization::LCMSerializerVisitor::~LCMSerializerVisitor ( )
virtual

Member Function Documentation

uint64_t odcore::serialization::Serializer::__htonll ( uint64_t  ui)
staticinherited

This method converts a uint64_t from host byte order to network byte order.

Parameters
uiuint64_t to be converted.
Returns
ui in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

Referenced by getSerializedData(), and odcore::serialization::QueryableNetstringsSerializerAACF::writeValue().

int64_t odcore::serialization::Serializer::__htonll ( int64_t  i)
staticinherited

This method converts an int64_t from host byte order to network byte order.

Parameters
iint64_t to be converted.
Returns
i in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

int64_t odcore::serialization::LCMSerializerVisitor::calculateHash ( int64_t  v,
const char &  c 
)
static

This method is adapted from LCM to calculate the corresponding hash value.

Referenced by calculateHash(), visit(), and odcore::serialization::LCMDeserializerVisitor::visit().

int64_t odcore::serialization::LCMSerializerVisitor::calculateHash ( int64_t  v,
const string &  s 
)
static

This method is adapted from LCM to calculate the corresponding hash value.

References calculateHash().

int64_t odcore::serialization::LCMSerializerVisitor::getHash ( ) const

This method returns the calculated hash value.

Returns
Calculated hash.

Referenced by getSerializedData().

void odcore::serialization::LCMSerializerVisitor::getSerializedData ( ostream &  o)
virtual

This method returns the data in serialized format.

Parameters
oostream object (for instance a stringstream) to serialize the data into.

Implements odcore::serialization::Serializer.

References odcore::serialization::Serializer::__htonll(), and getHash().

double odcore::serialization::Serializer::htond ( double  d)
staticinherited

This method converts a double from host byte order to network byte order.

Parameters
ddouble to be converted.
Returns
d in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

Referenced by odcore::serialization::QueryableNetstringsSerializerAACF::writeValue(), and odcore::serialization::QueryableNetstringsSerializerABCF::writeValue().

float odcore::serialization::Serializer::htonf ( float  f)
staticinherited

This method converts a float from host byte order to network byte order.

Parameters
ffloat to be converted.
Returns
f in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

Referenced by odcore::serialization::QueryableNetstringsSerializerAACF::writeValue(), and odcore::serialization::QueryableNetstringsSerializerABCF::writeValue().

void odcore::serialization::LCMSerializerVisitor::setChannelName ( const string &  channelName)

This method sets the channel name to be used for the serialized data.

Parameters
channelNameName of the LCM channel for which this data shall be serialized.
void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
Serializable v 
)
virtual

This method visits a Serializable.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vSerializable to be serialized.

Implements odcore::base::Visitor.

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
bool &  v 
)
virtual

This method visits a bool.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vBool to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
char &  v 
)
virtual

This method visits a char.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vChar to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
unsigned char &  v 
)
virtual

This method visits an unsigned char.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vUnsigned char to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
int8_t &  v 
)
virtual

This method visits an int8_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
iint8_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
int16_t &  v 
)
virtual

This method visits an int16_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
iint16_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
uint16_t &  v 
)
virtual

This method visits an uint16_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vuint16_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
int32_t &  v 
)
virtual

This method visits an int32_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
iint32_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
uint32_t &  v 
)
virtual

This method visits an uint32_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vuint32_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
int64_t &  v 
)
virtual

This method visits an int64_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
iint64_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
uint64_t &  v 
)
virtual

This method visits an uint64_t.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vuint64_t to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
float &  v 
)
virtual

This method visits a float.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vFloat to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
double &  v 
)
virtual

This method visits a double.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vDouble to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
string &  v 
)
virtual

This method visits a string.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
vString to be serialized.

Implements odcore::base::Visitor.

References calculateHash().

void odcore::serialization::LCMSerializerVisitor::visit ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
void *  data,
const uint32_t &  size 
)
virtual

This method visits undefined data of length size.

Parameters
ididentifier for the v to be serialized.
longNameLong identifier (ie. with package name) for the v to be serialized.
shortNameShort identifier for the v to be serialized.
dataData to be serialized.
sizeLength of the data to be serialized.

Implements odcore::base::Visitor.