17 #ifndef _TOPICMANAGER_HH_
18 #define _TOPICMANAGER_HH_
20 #include <boost/bind.hpp>
25 #include <boost/unordered/unordered_set.hpp>
102 public:
template<
typename M>
104 unsigned int _queueLimit,
107 google::protobuf::Message *msg =
NULL;
109 msg =
dynamic_cast<google::protobuf::Message *
>(&msgtype);
111 gzthrow(
"Advertise requires a google protobuf type");
116 msg->GetTypeName(), _queueLimit, _hzRate));
118 std::string msgTypename;
122 msgTypename = msg->GetTypeName();
125 GZ_ASSERT(publication !=
NULL,
"FindPublication returned NULL");
127 publication->AddPublisher(pub);
128 if (!publication->GetLocallyAdvertised())
133 publication->SetLocallyAdvertised(
true);
134 pub->SetPublication(publication);
137 SubNodeMap::iterator iter2;
138 SubNodeMap::iterator stEnd2 = this->subscribedNodes.end();
139 for (iter2 = this->subscribedNodes.begin();
140 iter2 != stEnd2; ++iter2)
142 if (iter2->first == _topic)
144 std::list<NodePtr>::iterator liter;
145 std::list<NodePtr>::iterator lEnd = iter2->second.end();
146 for (liter = iter2->second.begin();
147 liter != lEnd; ++liter)
149 publication->AddSubscription(*liter);
159 public:
void Unadvertise(
const std::string &_topic);
168 boost::function<
void(uint32_t)> _cb, uint32_t _id);
185 const std::string &_host,
193 const std::string &_host,
206 const std::string &_msgType);
220 public: std::map<std::string, std::list<std::string> >
237 private: typedef std::map<std::
string,
PublicationPtr> PublicationPtr_M;
238 private: PublicationPtr_M advertisedTopics;
239 private: PublicationPtr_M::iterator advertisedTopicsEnd;
240 private: SubNodeMap subscribedNodes;
241 private: std::vector<
NodePtr> nodes;
244 private: boost::unordered_set<
NodePtr> nodesToProcess;
246 private: boost::recursive_mutex nodeMutex;
249 private: boost::mutex subscriberMutex;
252 private: boost::mutex processNodesMutex;
254 private:
bool pauseIncoming;