17 #ifndef _CALLBACKHELPER_HH_    18 #define _CALLBACKHELPER_HH_    20 #include <google/protobuf/message.h>    21 #include <boost/function.hpp>    22 #include <boost/shared_ptr.hpp>    56       public: 
virtual std::string GetMsgType() 
const;
    64       public: 
virtual bool HandleData(
const std::string &_newdata,
    65                   boost::function<
void(uint32_t)> _cb, uint32_t _id) = 0;
    70       public: 
virtual bool HandleMessage(
MessagePtr _newMsg) = 0;
    75       public: 
virtual bool IsLocal() 
const = 0;
    79       public: 
bool GetLatching() 
const;
    84       public: 
void SetLatching(
bool _latch);
    88       public: 
unsigned int GetId() 
const;
    98       private: 
static unsigned int idCounter;
   101       private: 
unsigned int id;
   118                 void (
const boost::shared_ptr<M const> &)> &_cb,
   119                 bool _latching = 
false)
   135                 google::protobuf::Message *m;
   136                 if ((m = dynamic_cast<google::protobuf::Message*>(&test))
   138                   gzthrow(
"Message type must be a google::protobuf type\n");
   139                 return m->GetTypeName();
   144                   boost::function<
void(uint32_t)> _cb, uint32_t _id)
   146                 this->SetLatching(
false);
   147                 boost::shared_ptr<M> m(
new M);
   148                 m->ParseFromString(_newdata);
   158                 this->SetLatching(
false);
   159                 this->callback(boost::dynamic_pointer_cast<M>(_newMsg));
   169       private: boost::function<void (const boost::shared_ptr<M const> &)>
   184                   const boost::function<
void (
const std::string &)> &_cb,
   185                   bool _latching = 
false)
   198                   boost::function<
void(uint32_t)> _cb, uint32_t _id)
   200                 this->SetLatching(
false);
   201                 this->callback(_newdata);
   210                 this->SetLatching(
false);
   212                 _newMsg->SerializeToString(&data);
   213                 this->callback(data);
   224       private: boost::function<void (const std::string &)> callback;
 virtual bool HandleMessage(MessagePtr _newMsg)
Process new incoming message. 
Definition: CallbackHelper.hh:208
 
Forward declarations for the common classes. 
Definition: Animation.hh:33
 
A helper class to handle callbacks when messages arrive. 
Definition: CallbackHelper.hh:44
 
boost::shared_ptr< google::protobuf::Message > MessagePtr
Definition: TransportTypes.hh:45
 
bool latching
True means that the callback helper will get the last published message on the topic. 
Definition: CallbackHelper.hh:92
 
#define gzthrow(msg)
This macro logs an error to the throw stream and throws an exception that contains the file name and ...
Definition: Exception.hh:39
 
Forward declarations for transport. 
 
boost::shared_ptr< CallbackHelper > CallbackHelperPtr
boost shared pointer to transport::CallbackHelper 
Definition: CallbackHelper.hh:105
 
Callback helper Template. 
Definition: CallbackHelper.hh:111
 
virtual bool IsLocal() const
Is the callback local? 
Definition: CallbackHelper.hh:219
 
RawCallbackHelper(const boost::function< void(const std::string &)> &_cb, bool _latching=false)
Constructor. 
Definition: CallbackHelper.hh:183
 
std::string GetMsgType() const
Get the typename of the message that is handled. 
Definition: CallbackHelper.hh:132
 
virtual bool HandleData(const std::string &_newdata, boost::function< void(uint32_t)> _cb, uint32_t _id)
Process new incoming data. 
Definition: CallbackHelper.hh:143
 
CallbackHelperT(const boost::function< void(const boost::shared_ptr< M const > &)> &_cb, bool _latching=false)
Constructor. 
Definition: CallbackHelper.hh:117
 
virtual bool HandleMessage(MessagePtr _newMsg)
Process new incoming message. 
Definition: CallbackHelper.hh:156
 
#define NULL
Definition: CommonTypes.hh:31
 
std::mutex latchingMutex
Mutex to protect the latching variable. 
Definition: CallbackHelper.hh:95
 
virtual bool HandleData(const std::string &_newdata, boost::function< void(uint32_t)> _cb, uint32_t _id)
Process new incoming data. 
Definition: CallbackHelper.hh:197
 
Used to connect publishers to subscribers, where the subscriber wants the raw data from the publisher...
Definition: CallbackHelper.hh:177
 
std::string GetMsgType() const
Get the typename of the message that is handled. 
Definition: CallbackHelper.hh:191
 
virtual bool IsLocal() const
Is the callback local? 
Definition: CallbackHelper.hh:164