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>
73 public:
int GetId()
const;
76 private:
Event *event;
82 private:
static int counter;
87 public:
template<
typename T>
friend class EventT;
118 for (
unsigned int i = 0; i < connections.size(); i++)
120 (*this->connections[i])();
126 public:
template<
typename P >
133 public:
template<
typename P1,
typename P2 >
135 { this->
Signal(_p1, _p2); }
141 public:
template<
typename P1,
typename P2,
typename P3 >
143 { this->
Signal(_p1, _p2, _p3); }
150 public:
template<
typename P1,
typename P2,
typename P3,
typename P4 >
153 { this->
Signal(_p1, _p2, _p3, _p4); }
161 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
164 const P4 &_p4,
const P5 &_p5)
165 { this->
Signal(_p1, _p2, _p3, _p4, _p5); }
174 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
175 typename P5,
typename P6 >
177 const P4 &_p4,
const P5 &_p5,
const P6 &_p6)
178 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6); }
188 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
189 typename P5,
typename P6,
typename P7 >
191 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
193 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7); }
204 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
205 typename P5,
typename P6,
typename P7,
typename P8 >
207 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
208 const P7 &_p7,
const P8 &_p8)
209 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8); }
221 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
222 typename P5,
typename P6,
typename P7,
typename P8,
225 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
226 const P7 &_p7,
const P8 &_p8,
const P9 &_p9)
227 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9); }
240 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
241 typename P5,
typename P6,
typename P7,
typename P8,
242 typename P9,
typename P10 >
244 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
245 const P7 &_p7,
const P8 &_p8,
const P9 &_p9,
248 this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10);
253 public:
template<
typename P >
256 for (
unsigned int i = 0; i < connections.size(); i++)
258 (*this->connections[i])(_p);
265 public:
template<
typename P1,
typename P2 >
266 void Signal(
const P1 &_p1,
const P2 &_p2)
268 for (
unsigned int i = 0; i < connections.size(); i++)
270 (*this->connections[i])(_p1, _p2);
278 public:
template<
typename P1,
typename P2,
typename P3 >
279 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3)
281 for (
unsigned int i = 0; i < connections.size(); i++)
283 (*this->connections[i])(_p1, _p2, _p3);
292 public:
template<
typename P1,
typename P2,
typename P3,
typename P4>
293 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
296 for (
unsigned int i = 0; i < connections.size(); i++)
298 (*this->connections[i])(_p1, _p2, _p3, _p4);
308 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
310 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
311 const P4 &_p4,
const P5 &_p5)
313 for (
unsigned int i = 0; i < connections.size(); i++)
315 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5);
327 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
328 typename P5,
typename P6>
329 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
330 const P4 &_p4,
const P5 &_p5,
const P6 &_p6)
332 for (
unsigned int i = 0; i < connections.size(); i++)
334 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6);
346 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
347 typename P5,
typename P6,
typename P7>
348 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
349 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7)
351 for (
unsigned int i = 0; i < connections.size(); i++)
353 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7);
366 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
367 typename P5,
typename P6,
typename P7,
typename P8>
368 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
369 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
372 for (
unsigned int i = 0; i < connections.size(); i++)
374 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8);
388 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
389 typename P5,
typename P6,
typename P7,
typename P8,
391 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
392 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
393 const P8 &_p8,
const P9 &_p9)
395 for (
unsigned int i = 0; i < connections.size(); i++)
397 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9);
412 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
413 typename P5,
typename P6,
typename P7,
typename P8,
414 typename P9,
typename P10 >
415 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
416 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
417 const P8 &_p8,
const P9 &_p9,
const P10 &_p10)
419 for (
unsigned int i = 0; i < connections.size(); i++)
421 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5,
422 _p6, _p7, _p8, _p9, _p10);
427 private: std::vector<boost::function<T> *> connections;
430 private: std::vector<int> connectionIds;
433 private: boost::mutex lock;
440 for (
unsigned int i = 0; i < this->connections.size(); i++)
441 delete this->connections[i];
442 this->connections.clear();
443 this->connectionIds.clear();
451 int index = this->connections.size();
452 this->connections.push_back(
new boost::function<T>(_subscriber));
453 this->connectionIds.push_back(index);
462 this->Disconnect(_c->
GetId());
473 for (
unsigned int i = 0; i < this->connectionIds.size(); i++)
475 if (_id == this->connectionIds[i])
477 this->connectionIds.erase(this->connectionIds.begin()+i);
478 this->connections.erase(this->connections.begin()+i);