blob: df26683a8338822dea518d1551a1602e148bef72 [file] [log] [blame]
henrike@webrtc.orgf0488722014-05-13 18:00:26 +00001// sigslot.h: Signal/Slot classes
2//
3// Written by Sarah Thompson (sarah@telergy.com) 2002.
4//
5// License: Public domain. You are free to use this code however you like, with the proviso that
6// the author takes on no responsibility or liability for any use.
7//
8// QUICK DOCUMENTATION
9//
10// (see also the full documentation at http://sigslot.sourceforge.net/)
11//
12// #define switches
13// SIGSLOT_PURE_ISO - Define this to force ISO C++ compliance. This also disables
14// all of the thread safety support on platforms where it is
15// available.
16//
17// SIGSLOT_USE_POSIX_THREADS - Force use of Posix threads when using a C++ compiler other than
18// gcc on a platform that supports Posix threads. (When using gcc,
19// this is the default - use SIGSLOT_PURE_ISO to disable this if
20// necessary)
21//
22// SIGSLOT_DEFAULT_MT_POLICY - Where thread support is enabled, this defaults to multi_threaded_global.
23// Otherwise, the default is single_threaded. #define this yourself to
24// override the default. In pure ISO mode, anything other than
25// single_threaded will cause a compiler error.
26//
27// PLATFORM NOTES
28//
29// Win32 - On Win32, the WEBRTC_WIN symbol must be #defined. Most mainstream
30// compilers do this by default, but you may need to define it
31// yourself if your build environment is less standard. This causes
32// the Win32 thread support to be compiled in and used automatically.
33//
34// Unix/Linux/BSD, etc. - If you're using gcc, it is assumed that you have Posix threads
35// available, so they are used automatically. You can override this
36// (as under Windows) with the SIGSLOT_PURE_ISO switch. If you're using
37// something other than gcc but still want to use Posix threads, you
38// need to #define SIGSLOT_USE_POSIX_THREADS.
39//
40// ISO C++ - If none of the supported platforms are detected, or if
41// SIGSLOT_PURE_ISO is defined, all multithreading support is turned off,
42// along with any code that might cause a pure ISO C++ environment to
43// complain. Before you ask, gcc -ansi -pedantic won't compile this
44// library, but gcc -ansi is fine. Pedantic mode seems to throw a lot of
45// errors that aren't really there. If you feel like investigating this,
46// please contact the author.
47//
48//
49// THREADING MODES
50//
51// single_threaded - Your program is assumed to be single threaded from the point of view
52// of signal/slot usage (i.e. all objects using signals and slots are
53// created and destroyed from a single thread). Behaviour if objects are
54// destroyed concurrently is undefined (i.e. you'll get the occasional
55// segmentation fault/memory exception).
56//
57// multi_threaded_global - Your program is assumed to be multi threaded. Objects using signals and
58// slots can be safely created and destroyed from any thread, even when
59// connections exist. In multi_threaded_global mode, this is achieved by a
60// single global mutex (actually a critical section on Windows because they
61// are faster). This option uses less OS resources, but results in more
62// opportunities for contention, possibly resulting in more context switches
63// than are strictly necessary.
64//
65// multi_threaded_local - Behaviour in this mode is essentially the same as multi_threaded_global,
66// except that each signal, and each object that inherits has_slots, all
67// have their own mutex/critical section. In practice, this means that
68// mutex collisions (and hence context switches) only happen if they are
69// absolutely essential. However, on some platforms, creating a lot of
70// mutexes can slow down the whole OS, so use this option with care.
71//
72// USING THE LIBRARY
73//
74// See the full documentation at http://sigslot.sourceforge.net/
75//
76//
77// Libjingle specific:
78// This file has been modified such that has_slots and signalx do not have to be
79// using the same threading requirements. E.g. it is possible to connect a
80// has_slots<single_threaded> and signal0<multi_threaded_local> or
81// has_slots<multi_threaded_local> and signal0<single_threaded>.
82// If has_slots is single threaded the user must ensure that it is not trying
83// to connect or disconnect to signalx concurrently or data race may occur.
84// If signalx is single threaded the user must ensure that disconnect, connect
85// or signal is not happening concurrently or data race may occur.
86
87#ifndef WEBRTC_BASE_SIGSLOT_H__
88#define WEBRTC_BASE_SIGSLOT_H__
89
90#include <list>
91#include <set>
92#include <stdlib.h>
93
94// On our copy of sigslot.h, we set single threading as default.
95#define SIGSLOT_DEFAULT_MT_POLICY single_threaded
96
97#if defined(SIGSLOT_PURE_ISO) || (!defined(WEBRTC_WIN) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS))
98# define _SIGSLOT_SINGLE_THREADED
99#elif defined(WEBRTC_WIN)
100# define _SIGSLOT_HAS_WIN32_THREADS
101# if !defined(WIN32_LEAN_AND_MEAN)
102# define WIN32_LEAN_AND_MEAN
103# endif
104# include "webrtc/base/win32.h"
105#elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS)
106# define _SIGSLOT_HAS_POSIX_THREADS
107# include <pthread.h>
108#else
109# define _SIGSLOT_SINGLE_THREADED
110#endif
111
112#ifndef SIGSLOT_DEFAULT_MT_POLICY
113# ifdef _SIGSLOT_SINGLE_THREADED
114# define SIGSLOT_DEFAULT_MT_POLICY single_threaded
115# else
116# define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local
117# endif
118#endif
119
120// TODO: change this namespace to rtc?
121namespace sigslot {
122
123 class single_threaded
124 {
125 public:
126 single_threaded()
127 {
128 ;
129 }
130
131 virtual ~single_threaded()
132 {
133 ;
134 }
135
136 virtual void lock()
137 {
138 ;
139 }
140
141 virtual void unlock()
142 {
143 ;
144 }
145 };
146
147#ifdef _SIGSLOT_HAS_WIN32_THREADS
148 // The multi threading policies only get compiled in if they are enabled.
149 class multi_threaded_global
150 {
151 public:
152 multi_threaded_global()
153 {
154 static bool isinitialised = false;
155
156 if(!isinitialised)
157 {
158 InitializeCriticalSection(get_critsec());
159 isinitialised = true;
160 }
161 }
162
163 multi_threaded_global(const multi_threaded_global&)
164 {
165 ;
166 }
167
168 virtual ~multi_threaded_global()
169 {
170 ;
171 }
172
173 virtual void lock()
174 {
175 EnterCriticalSection(get_critsec());
176 }
177
178 virtual void unlock()
179 {
180 LeaveCriticalSection(get_critsec());
181 }
182
183 private:
184 CRITICAL_SECTION* get_critsec()
185 {
186 static CRITICAL_SECTION g_critsec;
187 return &g_critsec;
188 }
189 };
190
191 class multi_threaded_local
192 {
193 public:
194 multi_threaded_local()
195 {
196 InitializeCriticalSection(&m_critsec);
197 }
198
199 multi_threaded_local(const multi_threaded_local&)
200 {
201 InitializeCriticalSection(&m_critsec);
202 }
203
204 virtual ~multi_threaded_local()
205 {
206 DeleteCriticalSection(&m_critsec);
207 }
208
209 virtual void lock()
210 {
211 EnterCriticalSection(&m_critsec);
212 }
213
214 virtual void unlock()
215 {
216 LeaveCriticalSection(&m_critsec);
217 }
218
219 private:
220 CRITICAL_SECTION m_critsec;
221 };
222#endif // _SIGSLOT_HAS_WIN32_THREADS
223
224#ifdef _SIGSLOT_HAS_POSIX_THREADS
225 // The multi threading policies only get compiled in if they are enabled.
226 class multi_threaded_global
227 {
228 public:
229 multi_threaded_global()
230 {
231 pthread_mutex_init(get_mutex(), NULL);
232 }
233
234 multi_threaded_global(const multi_threaded_global&)
235 {
236 ;
237 }
238
239 virtual ~multi_threaded_global()
240 {
241 ;
242 }
243
244 virtual void lock()
245 {
246 pthread_mutex_lock(get_mutex());
247 }
248
249 virtual void unlock()
250 {
251 pthread_mutex_unlock(get_mutex());
252 }
253
254 private:
255 pthread_mutex_t* get_mutex()
256 {
257 static pthread_mutex_t g_mutex;
258 return &g_mutex;
259 }
260 };
261
262 class multi_threaded_local
263 {
264 public:
265 multi_threaded_local()
266 {
267 pthread_mutex_init(&m_mutex, NULL);
268 }
269
270 multi_threaded_local(const multi_threaded_local&)
271 {
272 pthread_mutex_init(&m_mutex, NULL);
273 }
274
275 virtual ~multi_threaded_local()
276 {
277 pthread_mutex_destroy(&m_mutex);
278 }
279
280 virtual void lock()
281 {
282 pthread_mutex_lock(&m_mutex);
283 }
284
285 virtual void unlock()
286 {
287 pthread_mutex_unlock(&m_mutex);
288 }
289
290 private:
291 pthread_mutex_t m_mutex;
292 };
293#endif // _SIGSLOT_HAS_POSIX_THREADS
294
295 template<class mt_policy>
296 class lock_block
297 {
298 public:
299 mt_policy *m_mutex;
300
301 lock_block(mt_policy *mtx)
302 : m_mutex(mtx)
303 {
304 m_mutex->lock();
305 }
306
307 ~lock_block()
308 {
309 m_mutex->unlock();
310 }
311 };
312
313 class has_slots_interface;
314
315 template<class mt_policy>
316 class _connection_base0
317 {
318 public:
319 virtual ~_connection_base0() {}
320 virtual has_slots_interface* getdest() const = 0;
321 virtual void emit() = 0;
322 virtual _connection_base0* clone() = 0;
323 virtual _connection_base0* duplicate(has_slots_interface* pnewdest) = 0;
324 };
325
326 template<class arg1_type, class mt_policy>
327 class _connection_base1
328 {
329 public:
330 virtual ~_connection_base1() {}
331 virtual has_slots_interface* getdest() const = 0;
332 virtual void emit(arg1_type) = 0;
333 virtual _connection_base1<arg1_type, mt_policy>* clone() = 0;
334 virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
335 };
336
337 template<class arg1_type, class arg2_type, class mt_policy>
338 class _connection_base2
339 {
340 public:
341 virtual ~_connection_base2() {}
342 virtual has_slots_interface* getdest() const = 0;
343 virtual void emit(arg1_type, arg2_type) = 0;
344 virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone() = 0;
345 virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
346 };
347
348 template<class arg1_type, class arg2_type, class arg3_type, class mt_policy>
349 class _connection_base3
350 {
351 public:
352 virtual ~_connection_base3() {}
353 virtual has_slots_interface* getdest() const = 0;
354 virtual void emit(arg1_type, arg2_type, arg3_type) = 0;
355 virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone() = 0;
356 virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
357 };
358
359 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy>
360 class _connection_base4
361 {
362 public:
363 virtual ~_connection_base4() {}
364 virtual has_slots_interface* getdest() const = 0;
365 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) = 0;
366 virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone() = 0;
367 virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
368 };
369
370 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
371 class arg5_type, class mt_policy>
372 class _connection_base5
373 {
374 public:
375 virtual ~_connection_base5() {}
376 virtual has_slots_interface* getdest() const = 0;
377 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type,
378 arg5_type) = 0;
379 virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
380 arg5_type, mt_policy>* clone() = 0;
381 virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
382 arg5_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
383 };
384
385 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
386 class arg5_type, class arg6_type, class mt_policy>
387 class _connection_base6
388 {
389 public:
390 virtual ~_connection_base6() {}
391 virtual has_slots_interface* getdest() const = 0;
392 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
393 arg6_type) = 0;
394 virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
395 arg5_type, arg6_type, mt_policy>* clone() = 0;
396 virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
397 arg5_type, arg6_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
398 };
399
400 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
401 class arg5_type, class arg6_type, class arg7_type, class mt_policy>
402 class _connection_base7
403 {
404 public:
405 virtual ~_connection_base7() {}
406 virtual has_slots_interface* getdest() const = 0;
407 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
408 arg6_type, arg7_type) = 0;
409 virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
410 arg5_type, arg6_type, arg7_type, mt_policy>* clone() = 0;
411 virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
412 arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
413 };
414
415 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
416 class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy>
417 class _connection_base8
418 {
419 public:
420 virtual ~_connection_base8() {}
421 virtual has_slots_interface* getdest() const = 0;
422 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
423 arg6_type, arg7_type, arg8_type) = 0;
424 virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
425 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone() = 0;
426 virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
427 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0;
428 };
429
430 class _signal_base_interface
431 {
432 public:
pthatcher@webrtc.org40b276e2014-12-12 02:44:30 +0000433 virtual ~_signal_base_interface() {}
henrike@webrtc.orgf0488722014-05-13 18:00:26 +0000434 virtual void slot_disconnect(has_slots_interface* pslot) = 0;
435 virtual void slot_duplicate(const has_slots_interface* poldslot, has_slots_interface* pnewslot) = 0;
436 };
437
438 template<class mt_policy>
439 class _signal_base : public _signal_base_interface, public mt_policy
440 {
441 };
442
443 class has_slots_interface
444 {
445 public:
446 has_slots_interface()
447 {
448 ;
449 }
450
451 virtual void signal_connect(_signal_base_interface* sender) = 0;
452
453 virtual void signal_disconnect(_signal_base_interface* sender) = 0;
454
455 virtual ~has_slots_interface()
456 {
457 }
458
459 virtual void disconnect_all() = 0;
460 };
461
462 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
463 class has_slots : public has_slots_interface, public mt_policy
464 {
465 private:
466 typedef std::set<_signal_base_interface*> sender_set;
467 typedef sender_set::const_iterator const_iterator;
468
469 public:
470 has_slots()
471 {
472 ;
473 }
474
475 has_slots(const has_slots& hs)
476 {
477 lock_block<mt_policy> lock(this);
478 const_iterator it = hs.m_senders.begin();
479 const_iterator itEnd = hs.m_senders.end();
480
481 while(it != itEnd)
482 {
483 (*it)->slot_duplicate(&hs, this);
484 m_senders.insert(*it);
485 ++it;
486 }
487 }
488
489 void signal_connect(_signal_base_interface* sender)
490 {
491 lock_block<mt_policy> lock(this);
492 m_senders.insert(sender);
493 }
494
495 void signal_disconnect(_signal_base_interface* sender)
496 {
497 lock_block<mt_policy> lock(this);
498 m_senders.erase(sender);
499 }
500
501 virtual ~has_slots()
502 {
503 disconnect_all();
504 }
505
506 void disconnect_all()
507 {
508 lock_block<mt_policy> lock(this);
509 const_iterator it = m_senders.begin();
510 const_iterator itEnd = m_senders.end();
511
512 while(it != itEnd)
513 {
514 (*it)->slot_disconnect(this);
515 ++it;
516 }
517
518 m_senders.erase(m_senders.begin(), m_senders.end());
519 }
520
521 private:
522 sender_set m_senders;
523 };
524
525 template<class mt_policy>
526 class _signal_base0 : public _signal_base<mt_policy>
527 {
528 public:
529 typedef std::list<_connection_base0<mt_policy> *> connections_list;
530
531 _signal_base0()
532 {
533 ;
534 }
535
536 _signal_base0(const _signal_base0& s)
537 : _signal_base<mt_policy>(s)
538 {
539 lock_block<mt_policy> lock(this);
540 typename connections_list::const_iterator it = s.m_connected_slots.begin();
541 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
542
543 while(it != itEnd)
544 {
545 (*it)->getdest()->signal_connect(this);
546 m_connected_slots.push_back((*it)->clone());
547
548 ++it;
549 }
550 }
551
552 ~_signal_base0()
553 {
554 disconnect_all();
555 }
556
557 bool is_empty()
558 {
559 lock_block<mt_policy> lock(this);
560 typename connections_list::const_iterator it = m_connected_slots.begin();
561 typename connections_list::const_iterator itEnd = m_connected_slots.end();
562 return it == itEnd;
563 }
564
565 void disconnect_all()
566 {
567 lock_block<mt_policy> lock(this);
568 typename connections_list::const_iterator it = m_connected_slots.begin();
569 typename connections_list::const_iterator itEnd = m_connected_slots.end();
570
571 while(it != itEnd)
572 {
573 (*it)->getdest()->signal_disconnect(this);
574 delete *it;
575
576 ++it;
577 }
578
579 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
580 }
581
582#ifdef _DEBUG
583 bool connected(has_slots_interface* pclass)
584 {
585 lock_block<mt_policy> lock(this);
586 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
587 typename connections_list::const_iterator itEnd = m_connected_slots.end();
588 while(it != itEnd)
589 {
590 itNext = it;
591 ++itNext;
592 if ((*it)->getdest() == pclass)
593 return true;
594 it = itNext;
595 }
596 return false;
597 }
598#endif
599
600 void disconnect(has_slots_interface* pclass)
601 {
602 lock_block<mt_policy> lock(this);
603 typename connections_list::iterator it = m_connected_slots.begin();
604 typename connections_list::iterator itEnd = m_connected_slots.end();
605
606 while(it != itEnd)
607 {
608 if((*it)->getdest() == pclass)
609 {
610 delete *it;
611 m_connected_slots.erase(it);
612 pclass->signal_disconnect(this);
613 return;
614 }
615
616 ++it;
617 }
618 }
619
620 void slot_disconnect(has_slots_interface* pslot)
621 {
622 lock_block<mt_policy> lock(this);
623 typename connections_list::iterator it = m_connected_slots.begin();
624 typename connections_list::iterator itEnd = m_connected_slots.end();
625
626 while(it != itEnd)
627 {
628 typename connections_list::iterator itNext = it;
629 ++itNext;
630
631 if((*it)->getdest() == pslot)
632 {
633 delete *it;
634 m_connected_slots.erase(it);
635 }
636
637 it = itNext;
638 }
639 }
640
641 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
642 {
643 lock_block<mt_policy> lock(this);
644 typename connections_list::iterator it = m_connected_slots.begin();
645 typename connections_list::iterator itEnd = m_connected_slots.end();
646
647 while(it != itEnd)
648 {
649 if((*it)->getdest() == oldtarget)
650 {
651 m_connected_slots.push_back((*it)->duplicate(newtarget));
652 }
653
654 ++it;
655 }
656 }
657
658 protected:
659 connections_list m_connected_slots;
660 };
661
662 template<class arg1_type, class mt_policy>
663 class _signal_base1 : public _signal_base<mt_policy>
664 {
665 public:
666 typedef std::list<_connection_base1<arg1_type, mt_policy> *> connections_list;
667
668 _signal_base1()
669 {
670 ;
671 }
672
673 _signal_base1(const _signal_base1<arg1_type, mt_policy>& s)
674 : _signal_base<mt_policy>(s)
675 {
676 lock_block<mt_policy> lock(this);
677 typename connections_list::const_iterator it = s.m_connected_slots.begin();
678 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
679
680 while(it != itEnd)
681 {
682 (*it)->getdest()->signal_connect(this);
683 m_connected_slots.push_back((*it)->clone());
684
685 ++it;
686 }
687 }
688
689 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
690 {
691 lock_block<mt_policy> lock(this);
692 typename connections_list::iterator it = m_connected_slots.begin();
693 typename connections_list::iterator itEnd = m_connected_slots.end();
694
695 while(it != itEnd)
696 {
697 if((*it)->getdest() == oldtarget)
698 {
699 m_connected_slots.push_back((*it)->duplicate(newtarget));
700 }
701
702 ++it;
703 }
704 }
705
706 ~_signal_base1()
707 {
708 disconnect_all();
709 }
710
711 bool is_empty()
712 {
713 lock_block<mt_policy> lock(this);
714 typename connections_list::const_iterator it = m_connected_slots.begin();
715 typename connections_list::const_iterator itEnd = m_connected_slots.end();
716 return it == itEnd;
717 }
718
719 void disconnect_all()
720 {
721 lock_block<mt_policy> lock(this);
722 typename connections_list::const_iterator it = m_connected_slots.begin();
723 typename connections_list::const_iterator itEnd = m_connected_slots.end();
724
725 while(it != itEnd)
726 {
727 (*it)->getdest()->signal_disconnect(this);
728 delete *it;
729
730 ++it;
731 }
732
733 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
734 }
735
736#ifdef _DEBUG
737 bool connected(has_slots_interface* pclass)
738 {
739 lock_block<mt_policy> lock(this);
740 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
741 typename connections_list::const_iterator itEnd = m_connected_slots.end();
742 while(it != itEnd)
743 {
744 itNext = it;
745 ++itNext;
746 if ((*it)->getdest() == pclass)
747 return true;
748 it = itNext;
749 }
750 return false;
751 }
752#endif
753
754 void disconnect(has_slots_interface* pclass)
755 {
756 lock_block<mt_policy> lock(this);
757 typename connections_list::iterator it = m_connected_slots.begin();
758 typename connections_list::iterator itEnd = m_connected_slots.end();
759
760 while(it != itEnd)
761 {
762 if((*it)->getdest() == pclass)
763 {
764 delete *it;
765 m_connected_slots.erase(it);
766 pclass->signal_disconnect(this);
767 return;
768 }
769
770 ++it;
771 }
772 }
773
774 void slot_disconnect(has_slots_interface* pslot)
775 {
776 lock_block<mt_policy> lock(this);
777 typename connections_list::iterator it = m_connected_slots.begin();
778 typename connections_list::iterator itEnd = m_connected_slots.end();
779
780 while(it != itEnd)
781 {
782 typename connections_list::iterator itNext = it;
783 ++itNext;
784
785 if((*it)->getdest() == pslot)
786 {
787 delete *it;
788 m_connected_slots.erase(it);
789 }
790
791 it = itNext;
792 }
793 }
794
795
796 protected:
797 connections_list m_connected_slots;
798 };
799
800 template<class arg1_type, class arg2_type, class mt_policy>
801 class _signal_base2 : public _signal_base<mt_policy>
802 {
803 public:
804 typedef std::list<_connection_base2<arg1_type, arg2_type, mt_policy> *>
805 connections_list;
806
807 _signal_base2()
808 {
809 ;
810 }
811
812 _signal_base2(const _signal_base2<arg1_type, arg2_type, mt_policy>& s)
813 : _signal_base<mt_policy>(s)
814 {
815 lock_block<mt_policy> lock(this);
816 typename connections_list::const_iterator it = s.m_connected_slots.begin();
817 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
818
819 while(it != itEnd)
820 {
821 (*it)->getdest()->signal_connect(this);
822 m_connected_slots.push_back((*it)->clone());
823
824 ++it;
825 }
826 }
827
828 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
829 {
830 lock_block<mt_policy> lock(this);
831 typename connections_list::iterator it = m_connected_slots.begin();
832 typename connections_list::iterator itEnd = m_connected_slots.end();
833
834 while(it != itEnd)
835 {
836 if((*it)->getdest() == oldtarget)
837 {
838 m_connected_slots.push_back((*it)->duplicate(newtarget));
839 }
840
841 ++it;
842 }
843 }
844
845 ~_signal_base2()
846 {
847 disconnect_all();
848 }
849
850 bool is_empty()
851 {
852 lock_block<mt_policy> lock(this);
853 typename connections_list::const_iterator it = m_connected_slots.begin();
854 typename connections_list::const_iterator itEnd = m_connected_slots.end();
855 return it == itEnd;
856 }
857
858 void disconnect_all()
859 {
860 lock_block<mt_policy> lock(this);
861 typename connections_list::const_iterator it = m_connected_slots.begin();
862 typename connections_list::const_iterator itEnd = m_connected_slots.end();
863
864 while(it != itEnd)
865 {
866 (*it)->getdest()->signal_disconnect(this);
867 delete *it;
868
869 ++it;
870 }
871
872 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
873 }
874
875#ifdef _DEBUG
876 bool connected(has_slots_interface* pclass)
877 {
878 lock_block<mt_policy> lock(this);
879 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
880 typename connections_list::const_iterator itEnd = m_connected_slots.end();
881 while(it != itEnd)
882 {
883 itNext = it;
884 ++itNext;
885 if ((*it)->getdest() == pclass)
886 return true;
887 it = itNext;
888 }
889 return false;
890 }
891#endif
892
893 void disconnect(has_slots_interface* pclass)
894 {
895 lock_block<mt_policy> lock(this);
896 typename connections_list::iterator it = m_connected_slots.begin();
897 typename connections_list::iterator itEnd = m_connected_slots.end();
898
899 while(it != itEnd)
900 {
901 if((*it)->getdest() == pclass)
902 {
903 delete *it;
904 m_connected_slots.erase(it);
905 pclass->signal_disconnect(this);
906 return;
907 }
908
909 ++it;
910 }
911 }
912
913 void slot_disconnect(has_slots_interface* pslot)
914 {
915 lock_block<mt_policy> lock(this);
916 typename connections_list::iterator it = m_connected_slots.begin();
917 typename connections_list::iterator itEnd = m_connected_slots.end();
918
919 while(it != itEnd)
920 {
921 typename connections_list::iterator itNext = it;
922 ++itNext;
923
924 if((*it)->getdest() == pslot)
925 {
926 delete *it;
927 m_connected_slots.erase(it);
928 }
929
930 it = itNext;
931 }
932 }
933
934 protected:
935 connections_list m_connected_slots;
936 };
937
938 template<class arg1_type, class arg2_type, class arg3_type, class mt_policy>
939 class _signal_base3 : public _signal_base<mt_policy>
940 {
941 public:
942 typedef std::list<_connection_base3<arg1_type, arg2_type, arg3_type, mt_policy> *>
943 connections_list;
944
945 _signal_base3()
946 {
947 ;
948 }
949
950 _signal_base3(const _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>& s)
951 : _signal_base<mt_policy>(s)
952 {
953 lock_block<mt_policy> lock(this);
954 typename connections_list::const_iterator it = s.m_connected_slots.begin();
955 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
956
957 while(it != itEnd)
958 {
959 (*it)->getdest()->signal_connect(this);
960 m_connected_slots.push_back((*it)->clone());
961
962 ++it;
963 }
964 }
965
966 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
967 {
968 lock_block<mt_policy> lock(this);
969 typename connections_list::iterator it = m_connected_slots.begin();
970 typename connections_list::iterator itEnd = m_connected_slots.end();
971
972 while(it != itEnd)
973 {
974 if((*it)->getdest() == oldtarget)
975 {
976 m_connected_slots.push_back((*it)->duplicate(newtarget));
977 }
978
979 ++it;
980 }
981 }
982
983 ~_signal_base3()
984 {
985 disconnect_all();
986 }
987
988 bool is_empty()
989 {
990 lock_block<mt_policy> lock(this);
991 typename connections_list::const_iterator it = m_connected_slots.begin();
992 typename connections_list::const_iterator itEnd = m_connected_slots.end();
993 return it == itEnd;
994 }
995
996 void disconnect_all()
997 {
998 lock_block<mt_policy> lock(this);
999 typename connections_list::const_iterator it = m_connected_slots.begin();
1000 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1001
1002 while(it != itEnd)
1003 {
1004 (*it)->getdest()->signal_disconnect(this);
1005 delete *it;
1006
1007 ++it;
1008 }
1009
1010 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
1011 }
1012
1013#ifdef _DEBUG
1014 bool connected(has_slots_interface* pclass)
1015 {
1016 lock_block<mt_policy> lock(this);
1017 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
1018 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1019 while(it != itEnd)
1020 {
1021 itNext = it;
1022 ++itNext;
1023 if ((*it)->getdest() == pclass)
1024 return true;
1025 it = itNext;
1026 }
1027 return false;
1028 }
1029#endif
1030
1031 void disconnect(has_slots_interface* pclass)
1032 {
1033 lock_block<mt_policy> lock(this);
1034 typename connections_list::iterator it = m_connected_slots.begin();
1035 typename connections_list::iterator itEnd = m_connected_slots.end();
1036
1037 while(it != itEnd)
1038 {
1039 if((*it)->getdest() == pclass)
1040 {
1041 delete *it;
1042 m_connected_slots.erase(it);
1043 pclass->signal_disconnect(this);
1044 return;
1045 }
1046
1047 ++it;
1048 }
1049 }
1050
1051 void slot_disconnect(has_slots_interface* pslot)
1052 {
1053 lock_block<mt_policy> lock(this);
1054 typename connections_list::iterator it = m_connected_slots.begin();
1055 typename connections_list::iterator itEnd = m_connected_slots.end();
1056
1057 while(it != itEnd)
1058 {
1059 typename connections_list::iterator itNext = it;
1060 ++itNext;
1061
1062 if((*it)->getdest() == pslot)
1063 {
1064 delete *it;
1065 m_connected_slots.erase(it);
1066 }
1067
1068 it = itNext;
1069 }
1070 }
1071
1072 protected:
1073 connections_list m_connected_slots;
1074 };
1075
1076 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy>
1077 class _signal_base4 : public _signal_base<mt_policy>
1078 {
1079 public:
1080 typedef std::list<_connection_base4<arg1_type, arg2_type, arg3_type,
1081 arg4_type, mt_policy> *> connections_list;
1082
1083 _signal_base4()
1084 {
1085 ;
1086 }
1087
1088 _signal_base4(const _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s)
1089 : _signal_base<mt_policy>(s)
1090 {
1091 lock_block<mt_policy> lock(this);
1092 typename connections_list::const_iterator it = s.m_connected_slots.begin();
1093 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
1094
1095 while(it != itEnd)
1096 {
1097 (*it)->getdest()->signal_connect(this);
1098 m_connected_slots.push_back((*it)->clone());
1099
1100 ++it;
1101 }
1102 }
1103
1104 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
1105 {
1106 lock_block<mt_policy> lock(this);
1107 typename connections_list::iterator it = m_connected_slots.begin();
1108 typename connections_list::iterator itEnd = m_connected_slots.end();
1109
1110 while(it != itEnd)
1111 {
1112 if((*it)->getdest() == oldtarget)
1113 {
1114 m_connected_slots.push_back((*it)->duplicate(newtarget));
1115 }
1116
1117 ++it;
1118 }
1119 }
1120
1121 ~_signal_base4()
1122 {
1123 disconnect_all();
1124 }
1125
1126 bool is_empty()
1127 {
1128 lock_block<mt_policy> lock(this);
1129 typename connections_list::const_iterator it = m_connected_slots.begin();
1130 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1131 return it == itEnd;
1132 }
1133
1134 void disconnect_all()
1135 {
1136 lock_block<mt_policy> lock(this);
1137 typename connections_list::const_iterator it = m_connected_slots.begin();
1138 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1139
1140 while(it != itEnd)
1141 {
1142 (*it)->getdest()->signal_disconnect(this);
1143 delete *it;
1144
1145 ++it;
1146 }
1147
1148 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
1149 }
1150
1151#ifdef _DEBUG
1152 bool connected(has_slots_interface* pclass)
1153 {
1154 lock_block<mt_policy> lock(this);
1155 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
1156 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1157 while(it != itEnd)
1158 {
1159 itNext = it;
1160 ++itNext;
1161 if ((*it)->getdest() == pclass)
1162 return true;
1163 it = itNext;
1164 }
1165 return false;
1166 }
1167#endif
1168
1169 void disconnect(has_slots_interface* pclass)
1170 {
1171 lock_block<mt_policy> lock(this);
1172 typename connections_list::iterator it = m_connected_slots.begin();
1173 typename connections_list::iterator itEnd = m_connected_slots.end();
1174
1175 while(it != itEnd)
1176 {
1177 if((*it)->getdest() == pclass)
1178 {
1179 delete *it;
1180 m_connected_slots.erase(it);
1181 pclass->signal_disconnect(this);
1182 return;
1183 }
1184
1185 ++it;
1186 }
1187 }
1188
1189 void slot_disconnect(has_slots_interface* pslot)
1190 {
1191 lock_block<mt_policy> lock(this);
1192 typename connections_list::iterator it = m_connected_slots.begin();
1193 typename connections_list::iterator itEnd = m_connected_slots.end();
1194
1195 while(it != itEnd)
1196 {
1197 typename connections_list::iterator itNext = it;
1198 ++itNext;
1199
1200 if((*it)->getdest() == pslot)
1201 {
1202 delete *it;
1203 m_connected_slots.erase(it);
1204 }
1205
1206 it = itNext;
1207 }
1208 }
1209
1210 protected:
1211 connections_list m_connected_slots;
1212 };
1213
1214 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
1215 class arg5_type, class mt_policy>
1216 class _signal_base5 : public _signal_base<mt_policy>
1217 {
1218 public:
1219 typedef std::list<_connection_base5<arg1_type, arg2_type, arg3_type,
1220 arg4_type, arg5_type, mt_policy> *> connections_list;
1221
1222 _signal_base5()
1223 {
1224 ;
1225 }
1226
1227 _signal_base5(const _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type,
1228 arg5_type, mt_policy>& s)
1229 : _signal_base<mt_policy>(s)
1230 {
1231 lock_block<mt_policy> lock(this);
1232 typename connections_list::const_iterator it = s.m_connected_slots.begin();
1233 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
1234
1235 while(it != itEnd)
1236 {
1237 (*it)->getdest()->signal_connect(this);
1238 m_connected_slots.push_back((*it)->clone());
1239
1240 ++it;
1241 }
1242 }
1243
1244 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
1245 {
1246 lock_block<mt_policy> lock(this);
1247 typename connections_list::iterator it = m_connected_slots.begin();
1248 typename connections_list::iterator itEnd = m_connected_slots.end();
1249
1250 while(it != itEnd)
1251 {
1252 if((*it)->getdest() == oldtarget)
1253 {
1254 m_connected_slots.push_back((*it)->duplicate(newtarget));
1255 }
1256
1257 ++it;
1258 }
1259 }
1260
1261 ~_signal_base5()
1262 {
1263 disconnect_all();
1264 }
1265
1266 bool is_empty()
1267 {
1268 lock_block<mt_policy> lock(this);
1269 typename connections_list::const_iterator it = m_connected_slots.begin();
1270 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1271 return it == itEnd;
1272 }
1273
1274 void disconnect_all()
1275 {
1276 lock_block<mt_policy> lock(this);
1277 typename connections_list::const_iterator it = m_connected_slots.begin();
1278 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1279
1280 while(it != itEnd)
1281 {
1282 (*it)->getdest()->signal_disconnect(this);
1283 delete *it;
1284
1285 ++it;
1286 }
1287
1288 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
1289 }
1290
1291#ifdef _DEBUG
1292 bool connected(has_slots_interface* pclass)
1293 {
1294 lock_block<mt_policy> lock(this);
1295 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
1296 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1297 while(it != itEnd)
1298 {
1299 itNext = it;
1300 ++itNext;
1301 if ((*it)->getdest() == pclass)
1302 return true;
1303 it = itNext;
1304 }
1305 return false;
1306 }
1307#endif
1308
1309 void disconnect(has_slots_interface* pclass)
1310 {
1311 lock_block<mt_policy> lock(this);
1312 typename connections_list::iterator it = m_connected_slots.begin();
1313 typename connections_list::iterator itEnd = m_connected_slots.end();
1314
1315 while(it != itEnd)
1316 {
1317 if((*it)->getdest() == pclass)
1318 {
1319 delete *it;
1320 m_connected_slots.erase(it);
1321 pclass->signal_disconnect(this);
1322 return;
1323 }
1324
1325 ++it;
1326 }
1327 }
1328
1329 void slot_disconnect(has_slots_interface* pslot)
1330 {
1331 lock_block<mt_policy> lock(this);
1332 typename connections_list::iterator it = m_connected_slots.begin();
1333 typename connections_list::iterator itEnd = m_connected_slots.end();
1334
1335 while(it != itEnd)
1336 {
1337 typename connections_list::iterator itNext = it;
1338 ++itNext;
1339
1340 if((*it)->getdest() == pslot)
1341 {
1342 delete *it;
1343 m_connected_slots.erase(it);
1344 }
1345
1346 it = itNext;
1347 }
1348 }
1349
1350 protected:
1351 connections_list m_connected_slots;
1352 };
1353
1354 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
1355 class arg5_type, class arg6_type, class mt_policy>
1356 class _signal_base6 : public _signal_base<mt_policy>
1357 {
1358 public:
1359 typedef std::list<_connection_base6<arg1_type, arg2_type, arg3_type,
1360 arg4_type, arg5_type, arg6_type, mt_policy> *> connections_list;
1361
1362 _signal_base6()
1363 {
1364 ;
1365 }
1366
1367 _signal_base6(const _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type,
1368 arg5_type, arg6_type, mt_policy>& s)
1369 : _signal_base<mt_policy>(s)
1370 {
1371 lock_block<mt_policy> lock(this);
1372 typename connections_list::const_iterator it = s.m_connected_slots.begin();
1373 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
1374
1375 while(it != itEnd)
1376 {
1377 (*it)->getdest()->signal_connect(this);
1378 m_connected_slots.push_back((*it)->clone());
1379
1380 ++it;
1381 }
1382 }
1383
1384 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
1385 {
1386 lock_block<mt_policy> lock(this);
1387 typename connections_list::iterator it = m_connected_slots.begin();
1388 typename connections_list::iterator itEnd = m_connected_slots.end();
1389
1390 while(it != itEnd)
1391 {
1392 if((*it)->getdest() == oldtarget)
1393 {
1394 m_connected_slots.push_back((*it)->duplicate(newtarget));
1395 }
1396
1397 ++it;
1398 }
1399 }
1400
1401 ~_signal_base6()
1402 {
1403 disconnect_all();
1404 }
1405
1406 bool is_empty()
1407 {
1408 lock_block<mt_policy> lock(this);
1409 typename connections_list::const_iterator it = m_connected_slots.begin();
1410 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1411 return it == itEnd;
1412 }
1413
1414 void disconnect_all()
1415 {
1416 lock_block<mt_policy> lock(this);
1417 typename connections_list::const_iterator it = m_connected_slots.begin();
1418 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1419
1420 while(it != itEnd)
1421 {
1422 (*it)->getdest()->signal_disconnect(this);
1423 delete *it;
1424
1425 ++it;
1426 }
1427
1428 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
1429 }
1430
1431#ifdef _DEBUG
1432 bool connected(has_slots_interface* pclass)
1433 {
1434 lock_block<mt_policy> lock(this);
1435 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
1436 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1437 while(it != itEnd)
1438 {
1439 itNext = it;
1440 ++itNext;
1441 if ((*it)->getdest() == pclass)
1442 return true;
1443 it = itNext;
1444 }
1445 return false;
1446 }
1447#endif
1448
1449 void disconnect(has_slots_interface* pclass)
1450 {
1451 lock_block<mt_policy> lock(this);
1452 typename connections_list::iterator it = m_connected_slots.begin();
1453 typename connections_list::iterator itEnd = m_connected_slots.end();
1454
1455 while(it != itEnd)
1456 {
1457 if((*it)->getdest() == pclass)
1458 {
1459 delete *it;
1460 m_connected_slots.erase(it);
1461 pclass->signal_disconnect(this);
1462 return;
1463 }
1464
1465 ++it;
1466 }
1467 }
1468
1469 void slot_disconnect(has_slots_interface* pslot)
1470 {
1471 lock_block<mt_policy> lock(this);
1472 typename connections_list::iterator it = m_connected_slots.begin();
1473 typename connections_list::iterator itEnd = m_connected_slots.end();
1474
1475 while(it != itEnd)
1476 {
1477 typename connections_list::iterator itNext = it;
1478 ++itNext;
1479
1480 if((*it)->getdest() == pslot)
1481 {
1482 delete *it;
1483 m_connected_slots.erase(it);
1484 }
1485
1486 it = itNext;
1487 }
1488 }
1489
1490 protected:
1491 connections_list m_connected_slots;
1492 };
1493
1494 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
1495 class arg5_type, class arg6_type, class arg7_type, class mt_policy>
1496 class _signal_base7 : public _signal_base<mt_policy>
1497 {
1498 public:
1499 typedef std::list<_connection_base7<arg1_type, arg2_type, arg3_type,
1500 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> *> connections_list;
1501
1502 _signal_base7()
1503 {
1504 ;
1505 }
1506
1507 _signal_base7(const _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type,
1508 arg5_type, arg6_type, arg7_type, mt_policy>& s)
1509 : _signal_base<mt_policy>(s)
1510 {
1511 lock_block<mt_policy> lock(this);
1512 typename connections_list::const_iterator it = s.m_connected_slots.begin();
1513 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
1514
1515 while(it != itEnd)
1516 {
1517 (*it)->getdest()->signal_connect(this);
1518 m_connected_slots.push_back((*it)->clone());
1519
1520 ++it;
1521 }
1522 }
1523
1524 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
1525 {
1526 lock_block<mt_policy> lock(this);
1527 typename connections_list::iterator it = m_connected_slots.begin();
1528 typename connections_list::iterator itEnd = m_connected_slots.end();
1529
1530 while(it != itEnd)
1531 {
1532 if((*it)->getdest() == oldtarget)
1533 {
1534 m_connected_slots.push_back((*it)->duplicate(newtarget));
1535 }
1536
1537 ++it;
1538 }
1539 }
1540
1541 ~_signal_base7()
1542 {
1543 disconnect_all();
1544 }
1545
1546 bool is_empty()
1547 {
1548 lock_block<mt_policy> lock(this);
1549 typename connections_list::const_iterator it = m_connected_slots.begin();
1550 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1551 return it == itEnd;
1552 }
1553
1554 void disconnect_all()
1555 {
1556 lock_block<mt_policy> lock(this);
1557 typename connections_list::const_iterator it = m_connected_slots.begin();
1558 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1559
1560 while(it != itEnd)
1561 {
1562 (*it)->getdest()->signal_disconnect(this);
1563 delete *it;
1564
1565 ++it;
1566 }
1567
1568 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
1569 }
1570
1571#ifdef _DEBUG
1572 bool connected(has_slots_interface* pclass)
1573 {
1574 lock_block<mt_policy> lock(this);
1575 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
1576 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1577 while(it != itEnd)
1578 {
1579 itNext = it;
1580 ++itNext;
1581 if ((*it)->getdest() == pclass)
1582 return true;
1583 it = itNext;
1584 }
1585 return false;
1586 }
1587#endif
1588
1589 void disconnect(has_slots_interface* pclass)
1590 {
1591 lock_block<mt_policy> lock(this);
1592 typename connections_list::iterator it = m_connected_slots.begin();
1593 typename connections_list::iterator itEnd = m_connected_slots.end();
1594
1595 while(it != itEnd)
1596 {
1597 if((*it)->getdest() == pclass)
1598 {
1599 delete *it;
1600 m_connected_slots.erase(it);
1601 pclass->signal_disconnect(this);
1602 return;
1603 }
1604
1605 ++it;
1606 }
1607 }
1608
1609 void slot_disconnect(has_slots_interface* pslot)
1610 {
1611 lock_block<mt_policy> lock(this);
1612 typename connections_list::iterator it = m_connected_slots.begin();
1613 typename connections_list::iterator itEnd = m_connected_slots.end();
1614
1615 while(it != itEnd)
1616 {
1617 typename connections_list::iterator itNext = it;
1618 ++itNext;
1619
1620 if((*it)->getdest() == pslot)
1621 {
1622 delete *it;
1623 m_connected_slots.erase(it);
1624 }
1625
1626 it = itNext;
1627 }
1628 }
1629
1630 protected:
1631 connections_list m_connected_slots;
1632 };
1633
1634 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
1635 class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy>
1636 class _signal_base8 : public _signal_base<mt_policy>
1637 {
1638 public:
1639 typedef std::list<_connection_base8<arg1_type, arg2_type, arg3_type,
1640 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> *>
1641 connections_list;
1642
1643 _signal_base8()
1644 {
1645 ;
1646 }
1647
1648 _signal_base8(const _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type,
1649 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>& s)
1650 : _signal_base<mt_policy>(s)
1651 {
1652 lock_block<mt_policy> lock(this);
1653 typename connections_list::const_iterator it = s.m_connected_slots.begin();
1654 typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
1655
1656 while(it != itEnd)
1657 {
1658 (*it)->getdest()->signal_connect(this);
1659 m_connected_slots.push_back((*it)->clone());
1660
1661 ++it;
1662 }
1663 }
1664
1665 void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget)
1666 {
1667 lock_block<mt_policy> lock(this);
1668 typename connections_list::iterator it = m_connected_slots.begin();
1669 typename connections_list::iterator itEnd = m_connected_slots.end();
1670
1671 while(it != itEnd)
1672 {
1673 if((*it)->getdest() == oldtarget)
1674 {
1675 m_connected_slots.push_back((*it)->duplicate(newtarget));
1676 }
1677
1678 ++it;
1679 }
1680 }
1681
1682 ~_signal_base8()
1683 {
1684 disconnect_all();
1685 }
1686
1687 bool is_empty()
1688 {
1689 lock_block<mt_policy> lock(this);
1690 typename connections_list::const_iterator it = m_connected_slots.begin();
1691 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1692 return it == itEnd;
1693 }
1694
1695 void disconnect_all()
1696 {
1697 lock_block<mt_policy> lock(this);
1698 typename connections_list::const_iterator it = m_connected_slots.begin();
1699 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1700
1701 while(it != itEnd)
1702 {
1703 (*it)->getdest()->signal_disconnect(this);
1704 delete *it;
1705
1706 ++it;
1707 }
1708
1709 m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
1710 }
1711
1712#ifdef _DEBUG
1713 bool connected(has_slots_interface* pclass)
1714 {
1715 lock_block<mt_policy> lock(this);
1716 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
1717 typename connections_list::const_iterator itEnd = m_connected_slots.end();
1718 while(it != itEnd)
1719 {
1720 itNext = it;
1721 ++itNext;
1722 if ((*it)->getdest() == pclass)
1723 return true;
1724 it = itNext;
1725 }
1726 return false;
1727 }
1728#endif
1729
1730 void disconnect(has_slots_interface* pclass)
1731 {
1732 lock_block<mt_policy> lock(this);
1733 typename connections_list::iterator it = m_connected_slots.begin();
1734 typename connections_list::iterator itEnd = m_connected_slots.end();
1735
1736 while(it != itEnd)
1737 {
1738 if((*it)->getdest() == pclass)
1739 {
1740 delete *it;
1741 m_connected_slots.erase(it);
1742 pclass->signal_disconnect(this);
1743 return;
1744 }
1745
1746 ++it;
1747 }
1748 }
1749
1750 void slot_disconnect(has_slots_interface* pslot)
1751 {
1752 lock_block<mt_policy> lock(this);
1753 typename connections_list::iterator it = m_connected_slots.begin();
1754 typename connections_list::iterator itEnd = m_connected_slots.end();
1755
1756 while(it != itEnd)
1757 {
1758 typename connections_list::iterator itNext = it;
1759 ++itNext;
1760
1761 if((*it)->getdest() == pslot)
1762 {
1763 delete *it;
1764 m_connected_slots.erase(it);
1765 }
1766
1767 it = itNext;
1768 }
1769 }
1770
1771 protected:
1772 connections_list m_connected_slots;
1773 };
1774
1775
1776 template<class dest_type, class mt_policy>
1777 class _connection0 : public _connection_base0<mt_policy>
1778 {
1779 public:
1780 _connection0()
1781 {
1782 m_pobject = NULL;
1783 m_pmemfun = NULL;
1784 }
1785
1786 _connection0(dest_type* pobject, void (dest_type::*pmemfun)())
1787 {
1788 m_pobject = pobject;
1789 m_pmemfun = pmemfun;
1790 }
1791
1792 virtual ~_connection0()
1793 {
1794 }
1795
1796 virtual _connection_base0<mt_policy>* clone()
1797 {
1798 return new _connection0<dest_type, mt_policy>(*this);
1799 }
1800
1801 virtual _connection_base0<mt_policy>* duplicate(has_slots_interface* pnewdest)
1802 {
1803 return new _connection0<dest_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
1804 }
1805
1806 virtual void emit()
1807 {
1808 (m_pobject->*m_pmemfun)();
1809 }
1810
1811 virtual has_slots_interface* getdest() const
1812 {
1813 return m_pobject;
1814 }
1815
1816 private:
1817 dest_type* m_pobject;
1818 void (dest_type::* m_pmemfun)();
1819 };
1820
1821 template<class dest_type, class arg1_type, class mt_policy>
1822 class _connection1 : public _connection_base1<arg1_type, mt_policy>
1823 {
1824 public:
1825 _connection1()
1826 {
1827 m_pobject = NULL;
1828 m_pmemfun = NULL;
1829 }
1830
1831 _connection1(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type))
1832 {
1833 m_pobject = pobject;
1834 m_pmemfun = pmemfun;
1835 }
1836
1837 virtual ~_connection1()
1838 {
1839 }
1840
1841 virtual _connection_base1<arg1_type, mt_policy>* clone()
1842 {
1843 return new _connection1<dest_type, arg1_type, mt_policy>(*this);
1844 }
1845
1846 virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
1847 {
1848 return new _connection1<dest_type, arg1_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
1849 }
1850
1851 virtual void emit(arg1_type a1)
1852 {
1853 (m_pobject->*m_pmemfun)(a1);
1854 }
1855
1856 virtual has_slots_interface* getdest() const
1857 {
1858 return m_pobject;
1859 }
1860
1861 private:
1862 dest_type* m_pobject;
1863 void (dest_type::* m_pmemfun)(arg1_type);
1864 };
1865
1866 template<class dest_type, class arg1_type, class arg2_type, class mt_policy>
1867 class _connection2 : public _connection_base2<arg1_type, arg2_type, mt_policy>
1868 {
1869 public:
1870 _connection2()
1871 {
1872 m_pobject = NULL;
1873 m_pmemfun = NULL;
1874 }
1875
1876 _connection2(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
1877 arg2_type))
1878 {
1879 m_pobject = pobject;
1880 m_pmemfun = pmemfun;
1881 }
1882
1883 virtual ~_connection2()
1884 {
1885 }
1886
1887 virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone()
1888 {
1889 return new _connection2<dest_type, arg1_type, arg2_type, mt_policy>(*this);
1890 }
1891
1892 virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
1893 {
1894 return new _connection2<dest_type, arg1_type, arg2_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
1895 }
1896
1897 virtual void emit(arg1_type a1, arg2_type a2)
1898 {
1899 (m_pobject->*m_pmemfun)(a1, a2);
1900 }
1901
1902 virtual has_slots_interface* getdest() const
1903 {
1904 return m_pobject;
1905 }
1906
1907 private:
1908 dest_type* m_pobject;
1909 void (dest_type::* m_pmemfun)(arg1_type, arg2_type);
1910 };
1911
1912 template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class mt_policy>
1913 class _connection3 : public _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>
1914 {
1915 public:
1916 _connection3()
1917 {
1918 m_pobject = NULL;
1919 m_pmemfun = NULL;
1920 }
1921
1922 _connection3(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
1923 arg2_type, arg3_type))
1924 {
1925 m_pobject = pobject;
1926 m_pmemfun = pmemfun;
1927 }
1928
1929 virtual ~_connection3()
1930 {
1931 }
1932
1933 virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone()
1934 {
1935 return new _connection3<dest_type, arg1_type, arg2_type, arg3_type, mt_policy>(*this);
1936 }
1937
1938 virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
1939 {
1940 return new _connection3<dest_type, arg1_type, arg2_type, arg3_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
1941 }
1942
1943 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3)
1944 {
1945 (m_pobject->*m_pmemfun)(a1, a2, a3);
1946 }
1947
1948 virtual has_slots_interface* getdest() const
1949 {
1950 return m_pobject;
1951 }
1952
1953 private:
1954 dest_type* m_pobject;
1955 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type);
1956 };
1957
1958 template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
1959 class arg4_type, class mt_policy>
1960 class _connection4 : public _connection_base4<arg1_type, arg2_type,
1961 arg3_type, arg4_type, mt_policy>
1962 {
1963 public:
1964 _connection4()
1965 {
1966 m_pobject = NULL;
1967 m_pmemfun = NULL;
1968 }
1969
1970 _connection4(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
1971 arg2_type, arg3_type, arg4_type))
1972 {
1973 m_pobject = pobject;
1974 m_pmemfun = pmemfun;
1975 }
1976
1977 virtual ~_connection4()
1978 {
1979 }
1980
1981 virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone()
1982 {
1983 return new _connection4<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(*this);
1984 }
1985
1986 virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
1987 {
1988 return new _connection4<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
1989 }
1990
1991 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3,
1992 arg4_type a4)
1993 {
1994 (m_pobject->*m_pmemfun)(a1, a2, a3, a4);
1995 }
1996
1997 virtual has_slots_interface* getdest() const
1998 {
1999 return m_pobject;
2000 }
2001
2002 private:
2003 dest_type* m_pobject;
2004 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type,
2005 arg4_type);
2006 };
2007
2008 template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
2009 class arg4_type, class arg5_type, class mt_policy>
2010 class _connection5 : public _connection_base5<arg1_type, arg2_type,
2011 arg3_type, arg4_type, arg5_type, mt_policy>
2012 {
2013 public:
2014 _connection5()
2015 {
2016 m_pobject = NULL;
2017 m_pmemfun = NULL;
2018 }
2019
2020 _connection5(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
2021 arg2_type, arg3_type, arg4_type, arg5_type))
2022 {
2023 m_pobject = pobject;
2024 m_pmemfun = pmemfun;
2025 }
2026
2027 virtual ~_connection5()
2028 {
2029 }
2030
2031 virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
2032 arg5_type, mt_policy>* clone()
2033 {
2034 return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2035 arg5_type, mt_policy>(*this);
2036 }
2037
2038 virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
2039 arg5_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
2040 {
2041 return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2042 arg5_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
2043 }
2044
2045 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2046 arg5_type a5)
2047 {
2048 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5);
2049 }
2050
2051 virtual has_slots_interface* getdest() const
2052 {
2053 return m_pobject;
2054 }
2055
2056 private:
2057 dest_type* m_pobject;
2058 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
2059 arg5_type);
2060 };
2061
2062 template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
2063 class arg4_type, class arg5_type, class arg6_type, class mt_policy>
2064 class _connection6 : public _connection_base6<arg1_type, arg2_type,
2065 arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>
2066 {
2067 public:
2068 _connection6()
2069 {
2070 m_pobject = NULL;
2071 m_pmemfun = NULL;
2072 }
2073
2074 _connection6(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
2075 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type))
2076 {
2077 m_pobject = pobject;
2078 m_pmemfun = pmemfun;
2079 }
2080
2081 virtual ~_connection6()
2082 {
2083 }
2084
2085 virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
2086 arg5_type, arg6_type, mt_policy>* clone()
2087 {
2088 return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2089 arg5_type, arg6_type, mt_policy>(*this);
2090 }
2091
2092 virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
2093 arg5_type, arg6_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
2094 {
2095 return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2096 arg5_type, arg6_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
2097 }
2098
2099 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2100 arg5_type a5, arg6_type a6)
2101 {
2102 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6);
2103 }
2104
2105 virtual has_slots_interface* getdest() const
2106 {
2107 return m_pobject;
2108 }
2109
2110 private:
2111 dest_type* m_pobject;
2112 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
2113 arg5_type, arg6_type);
2114 };
2115
2116 template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
2117 class arg4_type, class arg5_type, class arg6_type, class arg7_type, class mt_policy>
2118 class _connection7 : public _connection_base7<arg1_type, arg2_type,
2119 arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>
2120 {
2121 public:
2122 _connection7()
2123 {
2124 m_pobject = NULL;
2125 m_pmemfun = NULL;
2126 }
2127
2128 _connection7(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
2129 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type))
2130 {
2131 m_pobject = pobject;
2132 m_pmemfun = pmemfun;
2133 }
2134
2135 virtual ~_connection7()
2136 {
2137 }
2138
2139 virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
2140 arg5_type, arg6_type, arg7_type, mt_policy>* clone()
2141 {
2142 return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2143 arg5_type, arg6_type, arg7_type, mt_policy>(*this);
2144 }
2145
2146 virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
2147 arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
2148 {
2149 return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2150 arg5_type, arg6_type, arg7_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
2151 }
2152
2153 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2154 arg5_type a5, arg6_type a6, arg7_type a7)
2155 {
2156 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7);
2157 }
2158
2159 virtual has_slots_interface* getdest() const
2160 {
2161 return m_pobject;
2162 }
2163
2164 private:
2165 dest_type* m_pobject;
2166 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
2167 arg5_type, arg6_type, arg7_type);
2168 };
2169
2170 template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
2171 class arg4_type, class arg5_type, class arg6_type, class arg7_type,
2172 class arg8_type, class mt_policy>
2173 class _connection8 : public _connection_base8<arg1_type, arg2_type,
2174 arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>
2175 {
2176 public:
2177 _connection8()
2178 {
2179 m_pobject = NULL;
2180 m_pmemfun = NULL;
2181 }
2182
2183 _connection8(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
2184 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
2185 arg7_type, arg8_type))
2186 {
2187 m_pobject = pobject;
2188 m_pmemfun = pmemfun;
2189 }
2190
2191 virtual ~_connection8()
2192 {
2193 }
2194
2195 virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
2196 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone()
2197 {
2198 return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2199 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(*this);
2200 }
2201
2202 virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
2203 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots_interface* pnewdest)
2204 {
2205 return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
2206 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
2207 }
2208
2209 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2210 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
2211 {
2212 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8);
2213 }
2214
2215 virtual has_slots_interface* getdest() const
2216 {
2217 return m_pobject;
2218 }
2219
2220 private:
2221 dest_type* m_pobject;
2222 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
2223 arg5_type, arg6_type, arg7_type, arg8_type);
2224 };
2225
2226 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2227 class signal0 : public _signal_base0<mt_policy>
2228 {
2229 public:
2230 typedef _signal_base0<mt_policy> base;
2231 typedef typename base::connections_list connections_list;
2232 using base::m_connected_slots;
2233
2234 signal0()
2235 {
2236 ;
2237 }
2238
2239 signal0(const signal0<mt_policy>& s)
2240 : _signal_base0<mt_policy>(s)
2241 {
2242 ;
2243 }
2244
2245 template<class desttype>
2246 void connect(desttype* pclass, void (desttype::*pmemfun)())
2247 {
2248 lock_block<mt_policy> lock(this);
2249 _connection0<desttype, mt_policy>* conn =
2250 new _connection0<desttype, mt_policy>(pclass, pmemfun);
2251 m_connected_slots.push_back(conn);
2252 pclass->signal_connect(this);
2253 }
2254
2255 void emit()
2256 {
2257 lock_block<mt_policy> lock(this);
2258 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2259 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2260
2261 while(it != itEnd)
2262 {
2263 itNext = it;
2264 ++itNext;
2265
2266 (*it)->emit();
2267
2268 it = itNext;
2269 }
2270 }
2271
2272 void operator()()
2273 {
2274 lock_block<mt_policy> lock(this);
2275 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2276 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2277
2278 while(it != itEnd)
2279 {
2280 itNext = it;
2281 ++itNext;
2282
2283 (*it)->emit();
2284
2285 it = itNext;
2286 }
2287 }
2288 };
2289
2290 template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2291 class signal1 : public _signal_base1<arg1_type, mt_policy>
2292 {
2293 public:
2294 typedef _signal_base1<arg1_type, mt_policy> base;
2295 typedef typename base::connections_list connections_list;
2296 using base::m_connected_slots;
2297
2298 signal1()
2299 {
2300 ;
2301 }
2302
2303 signal1(const signal1<arg1_type, mt_policy>& s)
2304 : _signal_base1<arg1_type, mt_policy>(s)
2305 {
2306 ;
2307 }
2308
2309 template<class desttype>
2310 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type))
2311 {
2312 lock_block<mt_policy> lock(this);
2313 _connection1<desttype, arg1_type, mt_policy>* conn =
2314 new _connection1<desttype, arg1_type, mt_policy>(pclass, pmemfun);
2315 m_connected_slots.push_back(conn);
2316 pclass->signal_connect(this);
2317 }
2318
2319 void emit(arg1_type a1)
2320 {
2321 lock_block<mt_policy> lock(this);
2322 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2323 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2324
2325 while(it != itEnd)
2326 {
2327 itNext = it;
2328 ++itNext;
2329
2330 (*it)->emit(a1);
2331
2332 it = itNext;
2333 }
2334 }
2335
2336 void operator()(arg1_type a1)
2337 {
2338 lock_block<mt_policy> lock(this);
2339 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2340 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2341
2342 while(it != itEnd)
2343 {
2344 itNext = it;
2345 ++itNext;
2346
2347 (*it)->emit(a1);
2348
2349 it = itNext;
2350 }
2351 }
2352 };
2353
2354 template<class arg1_type, class arg2_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2355 class signal2 : public _signal_base2<arg1_type, arg2_type, mt_policy>
2356 {
2357 public:
2358 typedef _signal_base2<arg1_type, arg2_type, mt_policy> base;
2359 typedef typename base::connections_list connections_list;
2360 using base::m_connected_slots;
2361
2362 signal2()
2363 {
2364 ;
2365 }
2366
2367 signal2(const signal2<arg1_type, arg2_type, mt_policy>& s)
2368 : _signal_base2<arg1_type, arg2_type, mt_policy>(s)
2369 {
2370 ;
2371 }
2372
2373 template<class desttype>
2374 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2375 arg2_type))
2376 {
2377 lock_block<mt_policy> lock(this);
2378 _connection2<desttype, arg1_type, arg2_type, mt_policy>* conn = new
2379 _connection2<desttype, arg1_type, arg2_type, mt_policy>(pclass, pmemfun);
2380 m_connected_slots.push_back(conn);
2381 pclass->signal_connect(this);
2382 }
2383
2384 void emit(arg1_type a1, arg2_type a2)
2385 {
2386 lock_block<mt_policy> lock(this);
2387 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2388 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2389
2390 while(it != itEnd)
2391 {
2392 itNext = it;
2393 ++itNext;
2394
2395 (*it)->emit(a1, a2);
2396
2397 it = itNext;
2398 }
2399 }
2400
2401 void operator()(arg1_type a1, arg2_type a2)
2402 {
2403 lock_block<mt_policy> lock(this);
2404 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2405 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2406
2407 while(it != itEnd)
2408 {
2409 itNext = it;
2410 ++itNext;
2411
2412 (*it)->emit(a1, a2);
2413
2414 it = itNext;
2415 }
2416 }
2417 };
2418
2419 template<class arg1_type, class arg2_type, class arg3_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2420 class signal3 : public _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>
2421 {
2422 public:
2423 typedef _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy> base;
2424 typedef typename base::connections_list connections_list;
2425 using base::m_connected_slots;
2426
2427 signal3()
2428 {
2429 ;
2430 }
2431
2432 signal3(const signal3<arg1_type, arg2_type, arg3_type, mt_policy>& s)
2433 : _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>(s)
2434 {
2435 ;
2436 }
2437
2438 template<class desttype>
2439 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2440 arg2_type, arg3_type))
2441 {
2442 lock_block<mt_policy> lock(this);
2443 _connection3<desttype, arg1_type, arg2_type, arg3_type, mt_policy>* conn =
2444 new _connection3<desttype, arg1_type, arg2_type, arg3_type, mt_policy>(pclass,
2445 pmemfun);
2446 m_connected_slots.push_back(conn);
2447 pclass->signal_connect(this);
2448 }
2449
2450 void emit(arg1_type a1, arg2_type a2, arg3_type a3)
2451 {
2452 lock_block<mt_policy> lock(this);
2453 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2454 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2455
2456 while(it != itEnd)
2457 {
2458 itNext = it;
2459 ++itNext;
2460
2461 (*it)->emit(a1, a2, a3);
2462
2463 it = itNext;
2464 }
2465 }
2466
2467 void operator()(arg1_type a1, arg2_type a2, arg3_type a3)
2468 {
2469 lock_block<mt_policy> lock(this);
2470 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2471 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2472
2473 while(it != itEnd)
2474 {
2475 itNext = it;
2476 ++itNext;
2477
2478 (*it)->emit(a1, a2, a3);
2479
2480 it = itNext;
2481 }
2482 }
2483 };
2484
2485 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2486 class signal4 : public _signal_base4<arg1_type, arg2_type, arg3_type,
2487 arg4_type, mt_policy>
2488 {
2489 public:
2490 typedef _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy> base;
2491 typedef typename base::connections_list connections_list;
2492 using base::m_connected_slots;
2493
2494 signal4()
2495 {
2496 ;
2497 }
2498
2499 signal4(const signal4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s)
2500 : _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(s)
2501 {
2502 ;
2503 }
2504
2505 template<class desttype>
2506 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2507 arg2_type, arg3_type, arg4_type))
2508 {
2509 lock_block<mt_policy> lock(this);
2510 _connection4<desttype, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>*
2511 conn = new _connection4<desttype, arg1_type, arg2_type, arg3_type,
2512 arg4_type, mt_policy>(pclass, pmemfun);
2513 m_connected_slots.push_back(conn);
2514 pclass->signal_connect(this);
2515 }
2516
2517 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
2518 {
2519 lock_block<mt_policy> lock(this);
2520 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2521 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2522
2523 while(it != itEnd)
2524 {
2525 itNext = it;
2526 ++itNext;
2527
2528 (*it)->emit(a1, a2, a3, a4);
2529
2530 it = itNext;
2531 }
2532 }
2533
2534 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
2535 {
2536 lock_block<mt_policy> lock(this);
2537 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2538 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2539
2540 while(it != itEnd)
2541 {
2542 itNext = it;
2543 ++itNext;
2544
2545 (*it)->emit(a1, a2, a3, a4);
2546
2547 it = itNext;
2548 }
2549 }
2550 };
2551
2552 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
2553 class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2554 class signal5 : public _signal_base5<arg1_type, arg2_type, arg3_type,
2555 arg4_type, arg5_type, mt_policy>
2556 {
2557 public:
2558 typedef _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy> base;
2559 typedef typename base::connections_list connections_list;
2560 using base::m_connected_slots;
2561
2562 signal5()
2563 {
2564 ;
2565 }
2566
2567 signal5(const signal5<arg1_type, arg2_type, arg3_type, arg4_type,
2568 arg5_type, mt_policy>& s)
2569 : _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type,
2570 arg5_type, mt_policy>(s)
2571 {
2572 ;
2573 }
2574
2575 template<class desttype>
2576 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2577 arg2_type, arg3_type, arg4_type, arg5_type))
2578 {
2579 lock_block<mt_policy> lock(this);
2580 _connection5<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2581 arg5_type, mt_policy>* conn = new _connection5<desttype, arg1_type, arg2_type,
2582 arg3_type, arg4_type, arg5_type, mt_policy>(pclass, pmemfun);
2583 m_connected_slots.push_back(conn);
2584 pclass->signal_connect(this);
2585 }
2586
2587 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2588 arg5_type a5)
2589 {
2590 lock_block<mt_policy> lock(this);
2591 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2592 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2593
2594 while(it != itEnd)
2595 {
2596 itNext = it;
2597 ++itNext;
2598
2599 (*it)->emit(a1, a2, a3, a4, a5);
2600
2601 it = itNext;
2602 }
2603 }
2604
2605 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2606 arg5_type a5)
2607 {
2608 lock_block<mt_policy> lock(this);
2609 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2610 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2611
2612 while(it != itEnd)
2613 {
2614 itNext = it;
2615 ++itNext;
2616
2617 (*it)->emit(a1, a2, a3, a4, a5);
2618
2619 it = itNext;
2620 }
2621 }
2622 };
2623
2624
2625 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
2626 class arg5_type, class arg6_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2627 class signal6 : public _signal_base6<arg1_type, arg2_type, arg3_type,
2628 arg4_type, arg5_type, arg6_type, mt_policy>
2629 {
2630 public:
2631 typedef _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy> base;
2632 typedef typename base::connections_list connections_list;
2633 using base::m_connected_slots;
2634
2635 signal6()
2636 {
2637 ;
2638 }
2639
2640 signal6(const signal6<arg1_type, arg2_type, arg3_type, arg4_type,
2641 arg5_type, arg6_type, mt_policy>& s)
2642 : _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type,
2643 arg5_type, arg6_type, mt_policy>(s)
2644 {
2645 ;
2646 }
2647
2648 template<class desttype>
2649 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2650 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type))
2651 {
2652 lock_block<mt_policy> lock(this);
2653 _connection6<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2654 arg5_type, arg6_type, mt_policy>* conn =
2655 new _connection6<desttype, arg1_type, arg2_type, arg3_type,
2656 arg4_type, arg5_type, arg6_type, mt_policy>(pclass, pmemfun);
2657 m_connected_slots.push_back(conn);
2658 pclass->signal_connect(this);
2659 }
2660
2661 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2662 arg5_type a5, arg6_type a6)
2663 {
2664 lock_block<mt_policy> lock(this);
2665 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2666 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2667
2668 while(it != itEnd)
2669 {
2670 itNext = it;
2671 ++itNext;
2672
2673 (*it)->emit(a1, a2, a3, a4, a5, a6);
2674
2675 it = itNext;
2676 }
2677 }
2678
2679 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2680 arg5_type a5, arg6_type a6)
2681 {
2682 lock_block<mt_policy> lock(this);
2683 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2684 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2685
2686 while(it != itEnd)
2687 {
2688 itNext = it;
2689 ++itNext;
2690
2691 (*it)->emit(a1, a2, a3, a4, a5, a6);
2692
2693 it = itNext;
2694 }
2695 }
2696 };
2697
2698 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
2699 class arg5_type, class arg6_type, class arg7_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2700 class signal7 : public _signal_base7<arg1_type, arg2_type, arg3_type,
2701 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>
2702 {
2703 public:
2704 typedef _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type,
2705 arg5_type, arg6_type, arg7_type, mt_policy> base;
2706 typedef typename base::connections_list connections_list;
2707 using base::m_connected_slots;
2708
2709 signal7()
2710 {
2711 ;
2712 }
2713
2714 signal7(const signal7<arg1_type, arg2_type, arg3_type, arg4_type,
2715 arg5_type, arg6_type, arg7_type, mt_policy>& s)
2716 : _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type,
2717 arg5_type, arg6_type, arg7_type, mt_policy>(s)
2718 {
2719 ;
2720 }
2721
2722 template<class desttype>
2723 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2724 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
2725 arg7_type))
2726 {
2727 lock_block<mt_policy> lock(this);
2728 _connection7<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2729 arg5_type, arg6_type, arg7_type, mt_policy>* conn =
2730 new _connection7<desttype, arg1_type, arg2_type, arg3_type,
2731 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>(pclass, pmemfun);
2732 m_connected_slots.push_back(conn);
2733 pclass->signal_connect(this);
2734 }
2735
2736 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2737 arg5_type a5, arg6_type a6, arg7_type a7)
2738 {
2739 lock_block<mt_policy> lock(this);
2740 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2741 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2742
2743 while(it != itEnd)
2744 {
2745 itNext = it;
2746 ++itNext;
2747
2748 (*it)->emit(a1, a2, a3, a4, a5, a6, a7);
2749
2750 it = itNext;
2751 }
2752 }
2753
2754 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2755 arg5_type a5, arg6_type a6, arg7_type a7)
2756 {
2757 lock_block<mt_policy> lock(this);
2758 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2759 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2760
2761 while(it != itEnd)
2762 {
2763 itNext = it;
2764 ++itNext;
2765
2766 (*it)->emit(a1, a2, a3, a4, a5, a6, a7);
2767
2768 it = itNext;
2769 }
2770 }
2771 };
2772
2773 template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
2774 class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2775 class signal8 : public _signal_base8<arg1_type, arg2_type, arg3_type,
2776 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>
2777 {
2778 public:
2779 typedef _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type,
2780 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> base;
2781 typedef typename base::connections_list connections_list;
2782 using base::m_connected_slots;
2783
2784 signal8()
2785 {
2786 ;
2787 }
2788
2789 signal8(const signal8<arg1_type, arg2_type, arg3_type, arg4_type,
2790 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>& s)
2791 : _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type,
2792 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(s)
2793 {
2794 ;
2795 }
2796
2797 template<class desttype>
2798 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
2799 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
2800 arg7_type, arg8_type))
2801 {
2802 lock_block<mt_policy> lock(this);
2803 _connection8<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2804 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* conn =
2805 new _connection8<desttype, arg1_type, arg2_type, arg3_type,
2806 arg4_type, arg5_type, arg6_type, arg7_type,
2807 arg8_type, mt_policy>(pclass, pmemfun);
2808 m_connected_slots.push_back(conn);
2809 pclass->signal_connect(this);
2810 }
2811
2812 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2813 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
2814 {
2815 lock_block<mt_policy> lock(this);
2816 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2817 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2818
2819 while(it != itEnd)
2820 {
2821 itNext = it;
2822 ++itNext;
2823
2824 (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8);
2825
2826 it = itNext;
2827 }
2828 }
2829
2830 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
2831 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
2832 {
2833 lock_block<mt_policy> lock(this);
2834 typename connections_list::const_iterator itNext, it = m_connected_slots.begin();
2835 typename connections_list::const_iterator itEnd = m_connected_slots.end();
2836
2837 while(it != itEnd)
2838 {
2839 itNext = it;
2840 ++itNext;
2841
2842 (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8);
2843
2844 it = itNext;
2845 }
2846 }
2847 };
2848
2849}; // namespace sigslot
2850
2851#endif // WEBRTC_BASE_SIGSLOT_H__