Drake
TranslatorBase< DataType, MsgType > Class Template Referenceabstract

Base API for a translator between arbitrary data of DataType and a Lcm message of MsgType. More...

#include <drake/lcm/translator_base.h>

Public Member Functions

 TranslatorBase ()
 
virtual ~TranslatorBase ()
 
virtual const DataType & get_default_data () const =0
 Returns a const reference to the default data value. More...
 
virtual const MsgType & get_default_msg () const =0
 Returns a const reference to the default message value. More...
 
virtual void Encode (const DataType &data, MsgType *msg) const =0
 Encodes data into msg. More...
 
virtual void Decode (const MsgType &msg, DataType *data) const =0
 Decodes msg into data. More...
 
virtual void EncodeTime (double time, MsgType *msg) const
 Encodes time into msg. More...
 
virtual void DecodeTime (const MsgType &msg, double *time) const
 Decodes msg into time. More...
 
Does not allow copy, move, or assignment
 TranslatorBase (const TranslatorBase &)=delete
 
TranslatorBaseoperator= (const TranslatorBase &)=delete
 
 TranslatorBase (TranslatorBase &&)=delete
 
TranslatorBaseoperator= (TranslatorBase &&)=delete
 

Detailed Description

template<typename DataType, typename MsgType>
class drake::lcm::TranslatorBase< DataType, MsgType >

Base API for a translator between arbitrary data of DataType and a Lcm message of MsgType.

This class is intended to facilitate Lcm communication under the System framework. Within the System framework, time can be acquired directly from the Context, so it is not uncommon to omit time from state representations (DataType). Meanwhile, a well defined Lcm message (MsgType) almost always contains an time stamp. Thus, additional time information (often extracted from some Context) can be used for message encoding (from DataType to MsgType). For decoding (from MsgType to DataType), the message's time stamp can be extracted and stored separately.

Note that MsgType is not required to be a Lcm message. In fact, it can be any arbitrary data type as well.

Constructor & Destructor Documentation

◆ TranslatorBase() [1/3]

TranslatorBase ( const TranslatorBase< DataType, MsgType > &  )
delete

◆ TranslatorBase() [2/3]

TranslatorBase ( TranslatorBase< DataType, MsgType > &&  )
delete

◆ TranslatorBase() [3/3]

TranslatorBase ( )
inline

◆ ~TranslatorBase()

virtual ~TranslatorBase ( )
inlinevirtual

Member Function Documentation

◆ Decode()

virtual void Decode ( const MsgType &  msg,
DataType *  data 
) const
pure virtual

Decodes msg into data.

◆ DecodeTime()

virtual void DecodeTime ( const MsgType &  msg,
double time 
) const
inlinevirtual

Decodes msg into time.

The default implementation does nothing.

◆ Encode()

virtual void Encode ( const DataType &  data,
MsgType *  msg 
) const
pure virtual

Encodes data into msg.

◆ EncodeTime()

virtual void EncodeTime ( double  time,
MsgType *  msg 
) const
inlinevirtual

Encodes time into msg.

The default implementation does nothing.

◆ get_default_data()

virtual const DataType& get_default_data ( ) const
pure virtual

Returns a const reference to the default data value.

◆ get_default_msg()

virtual const MsgType& get_default_msg ( ) const
pure virtual

Returns a const reference to the default message value.

◆ operator=() [1/2]

TranslatorBase& operator= ( const TranslatorBase< DataType, MsgType > &  )
delete

◆ operator=() [2/2]

TranslatorBase& operator= ( TranslatorBase< DataType, MsgType > &&  )
delete

The documentation for this class was generated from the following file: