21 #include <gazebo/gazebo_config.h>
25 #include <boost/function.hpp>
26 #include <boost/bind.hpp>
27 #include <boost/shared_ptr.hpp>
28 #include <boost/thread/mutex.hpp>
74 public:
int GetId()
const;
77 private:
Event *event;
83 private:
static int counter;
88 public:
template<
typename T>
friend class EventT;
124 for (
unsigned int i = 0; i < connections.size(); i++)
126 (*this->connections[i])();
132 public:
template<
typename P >
139 public:
template<
typename P1,
typename P2 >
141 { this->
Signal(_p1, _p2); }
147 public:
template<
typename P1,
typename P2,
typename P3 >
149 { this->
Signal(_p1, _p2, _p3); }
156 public:
template<
typename P1,
typename P2,
typename P3,
typename P4 >
159 { this->
Signal(_p1, _p2, _p3, _p4); }
167 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
170 const P4 &_p4,
const P5 &_p5)
171 { this->
Signal(_p1, _p2, _p3, _p4, _p5); }
180 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
181 typename P5,
typename P6 >
183 const P4 &_p4,
const P5 &_p5,
const P6 &_p6)
184 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6); }
194 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
195 typename P5,
typename P6,
typename P7 >
197 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
199 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7); }
210 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
211 typename P5,
typename P6,
typename P7,
typename P8 >
213 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
214 const P7 &_p7,
const P8 &_p8)
215 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8); }
227 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
228 typename P5,
typename P6,
typename P7,
typename P8,
231 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
232 const P7 &_p7,
const P8 &_p8,
const P9 &_p9)
233 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9); }
246 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
247 typename P5,
typename P6,
typename P7,
typename P8,
248 typename P9,
typename P10 >
250 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
251 const P7 &_p7,
const P8 &_p8,
const P9 &_p9,
254 this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10);
259 public:
template<
typename P >
262 for (
unsigned int i = 0; i < connections.size(); i++)
264 (*this->connections[i])(_p);
271 public:
template<
typename P1,
typename P2 >
272 void Signal(
const P1 &_p1,
const P2 &_p2)
274 for (
unsigned int i = 0; i < connections.size(); i++)
276 (*this->connections[i])(_p1, _p2);
284 public:
template<
typename P1,
typename P2,
typename P3 >
285 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3)
287 for (
unsigned int i = 0; i < connections.size(); i++)
289 (*this->connections[i])(_p1, _p2, _p3);
298 public:
template<
typename P1,
typename P2,
typename P3,
typename P4>
299 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
302 for (
unsigned int i = 0; i < connections.size(); i++)
304 (*this->connections[i])(_p1, _p2, _p3, _p4);
314 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
316 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
317 const P4 &_p4,
const P5 &_p5)
319 for (
unsigned int i = 0; i < connections.size(); i++)
321 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5);
333 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
334 typename P5,
typename P6>
335 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
336 const P4 &_p4,
const P5 &_p5,
const P6 &_p6)
338 for (
unsigned int i = 0; i < connections.size(); i++)
340 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6);
352 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
353 typename P5,
typename P6,
typename P7>
354 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
355 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7)
357 for (
unsigned int i = 0; i < connections.size(); i++)
359 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7);
372 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
373 typename P5,
typename P6,
typename P7,
typename P8>
374 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
375 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
378 for (
unsigned int i = 0; i < connections.size(); i++)
380 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8);
394 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
395 typename P5,
typename P6,
typename P7,
typename P8,
397 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
398 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
399 const P8 &_p8,
const P9 &_p9)
401 for (
unsigned int i = 0; i < connections.size(); i++)
403 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9);
418 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
419 typename P5,
typename P6,
typename P7,
typename P8,
420 typename P9,
typename P10 >
421 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
422 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
423 const P8 &_p8,
const P9 &_p9,
const P10 &_p10)
425 for (
unsigned int i = 0; i < connections.size(); i++)
427 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5,
428 _p6, _p7, _p8, _p9, _p10);
433 private: std::vector<boost::function<T> *> connections;
436 private: std::vector<int> connectionIds;
439 private: boost::mutex lock;
446 for (
unsigned int i = 0; i < this->connections.size(); i++)
447 delete this->connections[i];
448 this->connections.clear();
449 this->connectionIds.clear();
457 int index = this->connections.size();
458 this->connections.push_back(
new boost::function<T>(_subscriber));
459 this->connectionIds.push_back(index);
468 this->Disconnect(_c->
GetId());
476 return this->connections.size();
485 for (
unsigned int i = 0; i < this->connectionIds.size(); i++)
487 if (_id == this->connectionIds[i])
489 this->connectionIds.erase(this->connectionIds.begin()+i);
490 this->connections.erase(this->connections.begin()+i);