21 #include <boost/enable_shared_from_this.hpp>
40 class Node :
public boost::enable_shared_from_this<Node>
46 public:
virtual ~Node();
52 public:
void Init(
const std::string &_space =
"");
73 public:
unsigned int GetId()
const;
94 public:
template<
typename M>
96 unsigned int _queueLimit = 1000,
102 decodedTopic, _queueLimit, _hzRate);
104 boost::recursive_mutex::scoped_lock lock(this->publisherMutex);
105 this->publishers.push_back(publisher);
106 this->publishersEnd = this->publishers.end();
118 public:
template<
typename M,
typename T>
120 void(T::*_fp)(
const boost::shared_ptr<M const> &), T *_obj,
121 bool _latching =
false)
125 ops.template Init<M>(decodedTopic, shared_from_this(), _latching);
128 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
147 public:
template<
typename M>
149 void(*_fp)(
const boost::shared_ptr<M const> &),
150 bool _latching =
false)
154 ops.template Init<M>(decodedTopic, shared_from_this(), _latching);
157 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
158 this->callbacks[decodedTopic].push_back(
179 void(T::*_fp)(
const std::string &), T *_obj,
180 bool _latching =
false)
184 ops.
Init(decodedTopic, shared_from_this(), _latching);
187 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
208 void(*_fp)(
const std::string &),
bool _latching =
false)
212 ops.
Init(decodedTopic, shared_from_this(), _latching);
215 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
216 this->callbacks[decodedTopic].push_back(
232 public:
bool HandleData(
const std::string &_topic,
233 const std::string &_msg);
242 const std::string &_msg);
247 public: std::string
GetMsgType(
const std::string &_topic)
const;
254 public:
void RemoveCallback(
const std::string &_topic,
unsigned int _id);
256 private: std::string topicNamespace;
257 private: std::vector<PublisherPtr> publishers;
258 private: std::vector<PublisherPtr>::iterator publishersIter;
259 private: std::vector<PublisherPtr>::iterator publishersEnd;
260 private:
static unsigned int idCounter;
261 private:
unsigned int id;
263 private:
typedef std::list<CallbackHelperPtr> Callback_L;
264 private:
typedef std::map<std::string, Callback_L> Callback_M;
265 private: Callback_M callbacks;
266 private: std::map<std::string, std::list<std::string> > incomingMsgs;
267 private: boost::recursive_mutex publisherMutex;
268 private: boost::recursive_mutex incomingMutex;
270 private:
bool initialized;