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>
52 public:
virtual std::string
GetMsgType()
const;
57 public:
virtual bool HandleData(
const std::string &_newdata) = 0;
62 public:
virtual bool IsLocal()
const = 0;
70 public:
unsigned int GetId()
const;
77 private:
static unsigned int idCounter;
80 private:
unsigned int id;
97 void (
const boost::shared_ptr<M const> &)> &_cb,
98 bool _latching =
false)
114 google::protobuf::Message *m;
115 if ((m = dynamic_cast<google::protobuf::Message*>(&test))
117 gzthrow(
"Message type must be a google::protobuf type\n");
118 return m->GetTypeName();
124 boost::shared_ptr<M> m(
new M);
125 m->ParseFromString(_newdata);
136 private: boost::function<void (const boost::shared_ptr<M const> &)>
151 const boost::function<
void (
const std::string &)> &_cb,
152 bool _latching =
false)
166 this->callback(_newdata);
176 private: boost::function<void (const std::string &)> callback;