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;
120 for (
unsigned int i = 0; i < connections.size(); i++)
122 (*this->connections[i])();
128 public:
template<
typename P >
135 public:
template<
typename P1,
typename P2 >
137 { this->
Signal(_p1, _p2); }
143 public:
template<
typename P1,
typename P2,
typename P3 >
145 { this->
Signal(_p1, _p2, _p3); }
152 public:
template<
typename P1,
typename P2,
typename P3,
typename P4 >
155 { this->
Signal(_p1, _p2, _p3, _p4); }
163 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
166 const P4 &_p4,
const P5 &_p5)
167 { this->
Signal(_p1, _p2, _p3, _p4, _p5); }
176 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
177 typename P5,
typename P6 >
179 const P4 &_p4,
const P5 &_p5,
const P6 &_p6)
180 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6); }
190 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
191 typename P5,
typename P6,
typename P7 >
193 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
195 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7); }
206 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
207 typename P5,
typename P6,
typename P7,
typename P8 >
209 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
210 const P7 &_p7,
const P8 &_p8)
211 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8); }
223 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
224 typename P5,
typename P6,
typename P7,
typename P8,
227 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
228 const P7 &_p7,
const P8 &_p8,
const P9 &_p9)
229 { this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9); }
242 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
243 typename P5,
typename P6,
typename P7,
typename P8,
244 typename P9,
typename P10 >
246 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
247 const P7 &_p7,
const P8 &_p8,
const P9 &_p9,
250 this->
Signal(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9, _p10);
255 public:
template<
typename P >
258 for (
unsigned int i = 0; i < connections.size(); i++)
260 (*this->connections[i])(_p);
267 public:
template<
typename P1,
typename P2 >
268 void Signal(
const P1 &_p1,
const P2 &_p2)
270 for (
unsigned int i = 0; i < connections.size(); i++)
272 (*this->connections[i])(_p1, _p2);
280 public:
template<
typename P1,
typename P2,
typename P3 >
281 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3)
283 for (
unsigned int i = 0; i < connections.size(); i++)
285 (*this->connections[i])(_p1, _p2, _p3);
294 public:
template<
typename P1,
typename P2,
typename P3,
typename P4>
295 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
298 for (
unsigned int i = 0; i < connections.size(); i++)
300 (*this->connections[i])(_p1, _p2, _p3, _p4);
310 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
312 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
313 const P4 &_p4,
const P5 &_p5)
315 for (
unsigned int i = 0; i < connections.size(); i++)
317 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5);
329 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
330 typename P5,
typename P6>
331 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
332 const P4 &_p4,
const P5 &_p5,
const P6 &_p6)
334 for (
unsigned int i = 0; i < connections.size(); i++)
336 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6);
348 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
349 typename P5,
typename P6,
typename P7>
350 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
351 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7)
353 for (
unsigned int i = 0; i < connections.size(); i++)
355 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7);
368 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
369 typename P5,
typename P6,
typename P7,
typename P8>
370 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
371 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
374 for (
unsigned int i = 0; i < connections.size(); i++)
376 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8);
390 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
391 typename P5,
typename P6,
typename P7,
typename P8,
393 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
394 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
395 const P8 &_p8,
const P9 &_p9)
397 for (
unsigned int i = 0; i < connections.size(); i++)
399 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5, _p6, _p7, _p8, _p9);
414 public:
template<
typename P1,
typename P2,
typename P3,
typename P4,
415 typename P5,
typename P6,
typename P7,
typename P8,
416 typename P9,
typename P10 >
417 void Signal(
const P1 &_p1,
const P2 &_p2,
const P3 &_p3,
418 const P4 &_p4,
const P5 &_p5,
const P6 &_p6,
const P7 &_p7,
419 const P8 &_p8,
const P9 &_p9,
const P10 &_p10)
421 for (
unsigned int i = 0; i < connections.size(); i++)
423 (*this->connections[i])(_p1, _p2, _p3, _p4, _p5,
424 _p6, _p7, _p8, _p9, _p10);
429 private: std::vector<boost::function<T> *> connections;
432 private: std::vector<int> connectionIds;
435 private: boost::mutex lock;
442 for (
unsigned int i = 0; i < this->connections.size(); i++)
443 delete this->connections[i];
444 this->connections.clear();
445 this->connectionIds.clear();
453 int index = this->connections.size();
454 this->connections.push_back(
new boost::function<T>(_subscriber));
455 this->connectionIds.push_back(index);
464 this->Disconnect(_c->
GetId());
475 for (
unsigned int i = 0; i < this->connectionIds.size(); i++)
477 if (_id == this->connectionIds[i])
479 this->connectionIds.erase(this->connectionIds.begin()+i);
480 this->connections.erase(this->connections.begin()+i);