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;
92 public:
template<
typename M>
94 unsigned int _queueLimit = 1000)
99 decodedTopic, _queueLimit);
101 boost::recursive_mutex::scoped_lock lock(this->publisherMutex);
102 this->publishers.push_back(publisher);
103 this->publishersEnd = this->publishers.end();
115 public:
template<
typename M,
typename T>
117 void(T::*_fp)(
const boost::shared_ptr<M const> &), T *_obj,
118 bool _latching =
false)
122 ops.template Init<M>(decodedTopic, shared_from_this(), _latching);
124 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
142 public:
template<
typename M>
144 void(*_fp)(
const boost::shared_ptr<M const> &),
145 bool _latching =
false)
149 ops.template Init<M>(decodedTopic, shared_from_this(), _latching);
151 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
152 this->callbacks[decodedTopic].push_back(
172 void(T::*_fp)(
const std::string &), T *_obj,
173 bool _latching =
false)
177 ops.
Init(decodedTopic, shared_from_this(), _latching);
179 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
199 void(*_fp)(
const std::string &),
bool _latching =
false)
203 ops.
Init(decodedTopic, shared_from_this(), _latching);
205 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
206 this->callbacks[decodedTopic].push_back(
221 public:
bool HandleData(
const std::string &_topic,
222 const std::string &_msg);
231 const std::string &_msg);
236 public: std::string
GetMsgType(
const std::string &_topic)
const;
243 public:
void RemoveCallback(
const std::string &_topic,
unsigned int _id);
245 private: std::string topicNamespace;
246 private: std::vector<PublisherPtr> publishers;
247 private: std::vector<PublisherPtr>::iterator publishersIter;
248 private: std::vector<PublisherPtr>::iterator publishersEnd;
249 private:
static unsigned int idCounter;
250 private:
unsigned int id;
252 private:
typedef std::list<CallbackHelperPtr> Callback_L;
253 private:
typedef std::map<std::string, Callback_L> Callback_M;
254 private: Callback_M callbacks;
255 private: std::map<std::string, std::list<std::string> > incomingMsgs;
256 private: boost::recursive_mutex publisherMutex;
257 private: boost::recursive_mutex incomingMutex;
259 private:
bool initialized;