21 #include <boost/enable_shared_from_this.hpp>
39 class Node :
public boost::enable_shared_from_this<Node>
45 public:
virtual ~Node();
51 public:
void Init(
const std::string &_space =
"");
66 public:
unsigned int GetId()
const;
76 unsigned int _queueLimit = 1000,
82 decodedTopic, _queueLimit, _latch);
84 boost::recursive_mutex::scoped_lock lock(this->publisherMutex);
85 this->publishers.push_back(publisher);
86 this->publishersEnd = this->publishers.end();
92 template<
typename M,
typename T>
94 void(T::*fp)(
const boost::shared_ptr<M const> &), T *obj,
95 bool _latching =
false)
99 ops.template Init<M>(decodedTopic, shared_from_this(), _latching);
101 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
111 void(*fp)(
const boost::shared_ptr<M const> &),
bool _latching =
false)
115 ops.template Init<M>(decodedTopic, shared_from_this(), _latching);
117 boost::recursive_mutex::scoped_lock lock(this->incomingMutex);
118 this->callbacks[decodedTopic].push_back(
124 public:
bool HandleData(
const std::string &_topic,
125 const std::string &_msg);
134 const std::string &_msg);
138 public: std::string
GetMsgType(
const std::string &_topic)
const;
140 private: std::string topicNamespace;
141 private: std::vector<PublisherPtr> publishers;
142 private: std::vector<PublisherPtr>::iterator publishersIter;
143 private: std::vector<PublisherPtr>::iterator publishersEnd;
144 private:
static unsigned int idCounter;
145 private:
unsigned int id;
147 private:
typedef std::list<CallbackHelperPtr> Callback_L;
148 private:
typedef std::map<std::string, Callback_L> Callback_M;
149 private: Callback_M callbacks;
150 private: std::map<std::string, std::list<std::string> > incomingMsgs;
151 private: boost::recursive_mutex publisherMutex;
152 private: boost::recursive_mutex incomingMutex;
154 private:
bool initialized;