Fawkes API Fawkes Development Version
protoboard::pb_converter< ProtoT, IfaceT > Class Template Reference

The workhorse of the ProtoBuf to Blackboard conversion. More...

#include <protobuf_to_bb.h>

Inheritance diagram for protoboard::pb_converter< ProtoT, IfaceT >:

Public Types

typedef ProtoT input_type
 The ProtoBuf message type that goes in. More...
 
typedef IfaceT output_type
 The blackboard interface type that the ProtoBuf contents are written to. More...
 

Public Member Functions

 pb_converter ()
 Empty-init. More...
 
 pb_converter (const pb_converter< ProtoT, IfaceT > &)=delete
 Copying this is prohibited. More...
 
pb_converter< ProtoT, IfaceT > & operator= (const pb_converter< ProtoT, IfaceT > &)=delete
 Copying this is prohibited. More...
 
 pb_converter (pb_converter< ProtoT, IfaceT > &&o)
 Move construction. More...
 
pb_converter< ProtoT, IfaceT > & operator= (pb_converter< ProtoT, IfaceT > &&o)
 Move assignment. More...
 
virtual ~pb_converter ()
 Close blackboard interface on destruction. More...
 
virtual void init (fawkes::BlackBoard *blackboard, fawkes::Logger *logger, const std::string &id="") override
 Deferred initialization, coincides with main thread initialization. More...
 
virtual void handle (const google::protobuf::Message &msg) override
 Handle a ProtoBuf message by reference. More...
 
virtual void handle (const ProtoT &msg)
 Handle a ProtoBuf message with known type. More...
 
virtual bool is_open ()
 
virtual void close ()
 Give up the current blackboard interface (closes it) More...
 
IfaceT * interface ()
 
const char * name ()
 
- Public Member Functions inherited from protoboard::pb_convert
 pb_convert ()
 Empty-init constructor. More...
 
 pb_convert (const pb_convert &)=default
 Default copy constructor. More...
 
virtual ~pb_convert ()
 Destructor. Does nothing since members aren't owned by this class. More...
 
pb_convertoperator= (const pb_convert &)=default
 Default copy assignment. More...
 
virtual void init (fawkes::BlackBoard *blackboard, fawkes::Logger *logger, const std::string &="")
 Deferred initialization. More...
 
virtual void handle (std::shared_ptr< google::protobuf::Message > msg)
 Dereference msg and pass it on to handle it by reference. More...
 
virtual void handle (const google::protobuf::Message &msg)
 Handle a ProtoBuf message by reference. More...
 

Static Public Member Functions

static std::string get_sequence_id (const ProtoT &)
 

Protected Member Functions

virtual void handle (const ProtoT &msg, IfaceT *iface)
 Write the contents of a ProtoBuf message into the appropriate blackboard interface. More...
 

Additional Inherited Members

- Protected Attributes inherited from protoboard::pb_convert
fawkes::BlackBoardblackboard_
 Blackboard used by the main thread. More...
 
fawkes::Loggerlogger_
 Logger from the main thread. More...
 

Detailed Description

template<class ProtoT, class IfaceT>
class protoboard::pb_converter< ProtoT, IfaceT >

The workhorse of the ProtoBuf to Blackboard conversion.

Template Parameters
Aconcrete ProtoBuf message type
TheBlackBoard interface type that the ProtoBuf type should be mapped to

Definition at line 99 of file protobuf_to_bb.h.

Member Typedef Documentation

◆ input_type

template<class ProtoT , class IfaceT >
typedef ProtoT protoboard::pb_converter< ProtoT, IfaceT >::input_type

The ProtoBuf message type that goes in.

Definition at line 103 of file protobuf_to_bb.h.

◆ output_type

template<class ProtoT , class IfaceT >
typedef IfaceT protoboard::pb_converter< ProtoT, IfaceT >::output_type

The blackboard interface type that the ProtoBuf contents are written to.

Definition at line 105 of file protobuf_to_bb.h.

Constructor & Destructor Documentation

◆ pb_converter() [1/3]

template<class ProtoT , class IfaceT >
protoboard::pb_converter< ProtoT, IfaceT >::pb_converter ( )
inline

Empty-init.

Definition at line 108 of file protobuf_to_bb.h.

◆ pb_converter() [2/3]

template<class ProtoT , class IfaceT >
protoboard::pb_converter< ProtoT, IfaceT >::pb_converter ( const pb_converter< ProtoT, IfaceT > &  )
delete

Copying this is prohibited.

Parameters
""deleted

◆ pb_converter() [3/3]

template<class ProtoT , class IfaceT >
protoboard::pb_converter< ProtoT, IfaceT >::pb_converter ( pb_converter< ProtoT, IfaceT > &&  o)
inline

Move construction.

Parameters
oAnother pb_converter to move from

Definition at line 124 of file protobuf_to_bb.h.

◆ ~pb_converter()

template<class ProtoT , class IfaceT >
virtual protoboard::pb_converter< ProtoT, IfaceT >::~pb_converter ( )
inlinevirtual

Close blackboard interface on destruction.

Definition at line 146 of file protobuf_to_bb.h.

References protoboard::pb_converter< ProtoT, IfaceT >::close().

Member Function Documentation

◆ close()

template<class ProtoT , class IfaceT >
virtual void protoboard::pb_converter< ProtoT, IfaceT >::close ( )
inlinevirtual

◆ get_sequence_id()

template<class ProtoT , class IfaceT >
static std::string protoboard::pb_converter< ProtoT, IfaceT >::get_sequence_id ( const ProtoT &  )
inlinestatic
Returns
The blackboard ID suffix if this is part of a sequence. Defaults to "". Must be overriden for ProtoBuf message types that are part of a sequence and should be put in separate interfaces.

Definition at line 215 of file protobuf_to_bb.h.

◆ handle() [1/3]

template<class ProtoT , class IfaceT >
virtual void protoboard::pb_converter< ProtoT, IfaceT >::handle ( const google::protobuf::Message &  msg)
inlineoverridevirtual

Handle a ProtoBuf message by reference.

Overridden in pb_converter

Parameters
msgReference to a generic ProtoBuf message

Reimplemented from protoboard::pb_convert.

Definition at line 172 of file protobuf_to_bb.h.

References protoboard::pb_converter< ProtoT, IfaceT >::handle().

Referenced by protoboard::pb_converter< ProtoT, IfaceT >::handle().

◆ handle() [2/3]

template<class ProtoT , class IfaceT >
virtual void protoboard::pb_converter< ProtoT, IfaceT >::handle ( const ProtoT &  msg)
inlinevirtual

Handle a ProtoBuf message with known type.

Just delegates to a user-definable method where the ProtoBuf message is matched up with the appropriate blackboard interface.

Parameters
msgThe incoming ProtoBuf message

Definition at line 181 of file protobuf_to_bb.h.

References protoboard::pb_converter< ProtoT, IfaceT >::handle().

◆ handle() [3/3]

template<class ProtoT , class IfaceT >
virtual void protoboard::pb_converter< ProtoT, IfaceT >::handle ( const ProtoT &  msg,
IfaceT *  iface 
)
protectedvirtual

Write the contents of a ProtoBuf message into the appropriate blackboard interface.

Must be specialized by the user for each ProtoBuf message -> blackboard interface pair

Parameters
msgThe message received
ifaceThe appropriate interface

◆ init()

template<class ProtoT , class IfaceT >
virtual void protoboard::pb_converter< ProtoT, IfaceT >::init ( fawkes::BlackBoard blackboard,
fawkes::Logger logger,
const std::string &  id = "" 
)
inlineoverridevirtual

Deferred initialization, coincides with main thread initialization.

Parameters
blackboardInitialized blackboard
loggerLogger used by the main thread
idBlackboard interface ID to open

Reimplemented from protoboard::pb_convert.

Definition at line 156 of file protobuf_to_bb.h.

References protoboard::pb_convert::blackboard_, protoboard::pb_convert::init(), fawkes::MultiLogger::log_info(), protoboard::pb_converter< ProtoT, IfaceT >::name(), and fawkes::BlackBoard::open_for_writing().

◆ interface()

template<class ProtoT , class IfaceT >
IfaceT * protoboard::pb_converter< ProtoT, IfaceT >::interface ( )
inline
Returns
the current blackboard interface

Definition at line 206 of file protobuf_to_bb.h.

◆ is_open()

template<class ProtoT , class IfaceT >
virtual bool protoboard::pb_converter< ProtoT, IfaceT >::is_open ( )
inlinevirtual
Returns
whether we have a Blackboard interface

Definition at line 189 of file protobuf_to_bb.h.

Referenced by protoboard::pb_converter< ProtoT, IfaceT >::close().

◆ name()

template<class ProtoT , class IfaceT >
const char * protoboard::pb_converter< ProtoT, IfaceT >::name ( )
inline
Returns
The demangled class name for logging

Definition at line 222 of file protobuf_to_bb.h.

Referenced by protoboard::pb_converter< ProtoT, IfaceT >::init().

◆ operator=() [1/2]

template<class ProtoT , class IfaceT >
pb_converter< ProtoT, IfaceT > & protoboard::pb_converter< ProtoT, IfaceT >::operator= ( const pb_converter< ProtoT, IfaceT > &  )
delete

Copying this is prohibited.

Parameters
""deleted
Returns
deleted

◆ operator=() [2/2]

template<class ProtoT , class IfaceT >
pb_converter< ProtoT, IfaceT > & protoboard::pb_converter< ProtoT, IfaceT >::operator= ( pb_converter< ProtoT, IfaceT > &&  o)
inline

Move assignment.

Parameters
oAnother pb_converter to move from
Returns
A reference to this pb_converter

Definition at line 136 of file protobuf_to_bb.h.

References protoboard::pb_convert::operator=().


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