Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

sigslot.h 84.9 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 
 sigslot.h: Signal/Slot classes
 
 Written by Sarah Thompson (sarah@telergy.com) 2002.
 
 License: Public domain. You are free to use this code however you like,
          with the proviso that the author takes on no responsibility or
          liability for any use.
 
 QUICK DOCUMENTATION
 
 (see also the full documentation at http://sigslot.sourceforge.net/)
 
 1. #define switches

    SIGSLOT_PURE_ISO:
    Define this to force ISO C++ compliance. This also disables
    all of the thread safety support on platforms where it is 
    available.
 
    SIGSLOT_USE_POSIX_THREADS:
    Force use of Posix threads when using a C++ compiler other than
    gcc on a platform that supports Posix threads. (When using gcc,
    this is the default - use SIGSLOT_PURE_ISO to disable this if 
    necessary)
 
    SIGSLOT_DEFAULT_MT_POLICY:
    Where thread support is enabled, this defaults to multi_threaded_global.
    Otherwise, the default is single_threaded. #define this yourself to
    override the default. In pure ISO mode, anything other than
    single_threaded will cause a compiler error.

 2. PLATFORM NOTES
 
    Win32:
    On Win32, the WIN32 symbol must be #defined. Most mainstream
    compilers do this by default, but you may need to define it
    yourself if your build environment is less standard. This causes
    the Win32 thread support to be compiled in and used automatically.
 
    Unix/Linux/BSD, etc:
    If you're using gcc, it is assumed that you have Posix threads
    available, so they are used automatically. You can override this
    (as under Windows) with the SIGSLOT_PURE_ISO switch. If you're using
    something other than gcc but still want to use Posix threads, you
    need to #define SIGSLOT_USE_POSIX_THREADS.
 
    ISO C++:
    If none of the supported platforms are detected, or if
    SIGSLOT_PURE_ISO is defined, all multithreading support is turned off,
    along with any code that might cause a pure ISO C++ environment to
    complain. Before you ask, gcc -ansi -pedantic won't compile this 
    library, but gcc -ansi is fine. Pedantic mode seems to throw a lot of
    errors that aren't really there. If you feel like investigating this,
    please contact the author.
      
 THREADING MODES
 
    single_threaded:
    Your program is assumed to be single threaded from the point of view
    of signal/slot usage (i.e. all objects using signals and slots are
    created and destroyed from a single thread). Behaviour if objects are
    destroyed concurrently is undefined (i.e. you'll get the occasional
    segmentation fault/memory exception).
 
    multi_threaded_global:
    Your program is assumed to be multi threaded. Objects using signals and
    slots can be safely created and destroyed from any thread, even when
    connections exist. In multi_threaded_global mode, this is achieved by a
    single global mutex (actually a critical section on Windows because they
    are faster). This option uses less OS resources, but results in more
    opportunities for contention, possibly resulting in more context switches
    than are strictly necessary.
 
    multi_threaded_local:
    Behaviour in this mode is essentially the same as multi_threaded_global,
    except that each signal, and each object that inherits has_slots, all 
    have their own mutex/critical section. In practice, this means that
    mutex collisions (and hence context switches) only happen if they are
    absolutely essential. However, on some platforms, creating a lot of 
    mutexes can slow down the whole OS, so use this option with care.
 
 USING THE LIBRARY
 
 See the full documentation at http://sigslot.sourceforge.net/
 
*/
schultezub's avatar
schultezub committed
89

schultezub's avatar
schultezub committed
90
91
#ifndef SIGSLOT_H
#define SIGSLOT_H
schultezub's avatar
schultezub committed
92
93
94

#include <set>
#include <list>
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
95
#include "tbb/spin_mutex.h"
schultezub's avatar
schultezub committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364

#define _SIGSLOT_HAS_TBB
/*
#if defined(SIGSLOT_PURE_ISO) || (!defined(WIN32) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS))
#	define _SIGSLOT_SINGLE_THREADED
#elif defined(WIN32)
#	define _SIGSLOT_HAS_WIN32_THREADS
#	include <windows.h>
#elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS)
#	define _SIGSLOT_HAS_POSIX_THREADS
#	include <pthread.h>
#else
#	define _SIGSLOT_SINGLE_THREADED
#endif
*/
#ifndef SIGSLOT_DEFAULT_MT_POLICY
#	ifdef _SIGSLOT_SINGLE_THREADED
#		define SIGSLOT_DEFAULT_MT_POLICY single_threaded
#	else
#		define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local
#	endif
#endif

namespace sigslot {

    class single_threaded
    {
    public:
        single_threaded()
        {
            ;
        }

        virtual ~single_threaded()
        {
            ;
        }

        virtual void lock()
        {
            ;
        }

        virtual void unlock()
        {
            ;
        }
    };

#ifdef _SIGSLOT_HAS_WIN32_THREADS
    // The multi threading policies only get compiled in if they are enabled.
    class multi_threaded_global
    {
    public:
        multi_threaded_global()
        {
            static bool isinitialised = false;

            if(!isinitialised)
            {
                InitializeCriticalSection(get_critsec());
                isinitialised = true;
            }
        }

        multi_threaded_global(const multi_threaded_global&)
        {
            ;
        }

        virtual ~multi_threaded_global()
        {
            ;
        }

        virtual void lock()
        {
            EnterCriticalSection(get_critsec());
        }

        virtual void unlock()
        {
            LeaveCriticalSection(get_critsec());
        }

    private:
        CRITICAL_SECTION* get_critsec()
        {
            static CRITICAL_SECTION g_critsec;
            return &g_critsec;
        }
    };

    class multi_threaded_local
    {
    public:
        multi_threaded_local()
        {
            InitializeCriticalSection(&m_critsec);
        }

        multi_threaded_local(const multi_threaded_local&)
        {
            InitializeCriticalSection(&m_critsec);
        }

        virtual ~multi_threaded_local()
        {
            DeleteCriticalSection(&m_critsec);
        }

        virtual void lock()
        {
            EnterCriticalSection(&m_critsec);
        }

        virtual void unlock()
        {
            LeaveCriticalSection(&m_critsec);
        }

    private:
        CRITICAL_SECTION m_critsec;
    };
#endif // _SIGSLOT_HAS_WIN32_THREADS

#ifdef _SIGSLOT_HAS_POSIX_THREADS
    // The multi threading policies only get compiled in if they are enabled.
    class multi_threaded_global
    {
    public:
        multi_threaded_global()
        {
            pthread_mutex_init(get_mutex(), NULL);
        }

        multi_threaded_global(const multi_threaded_global&)
        {
            ;
        }

        virtual ~multi_threaded_global()
        {
            ;
        }

        virtual void lock()
        {
            pthread_mutex_lock(get_mutex());
        }

        virtual void unlock()
        {
            pthread_mutex_unlock(get_mutex());
        }

    private:
        pthread_mutex_t* get_mutex()
        {
            static pthread_mutex_t g_mutex;
            return &g_mutex;
        }
    };

    class multi_threaded_local
    {
    public:
        multi_threaded_local()
        {
            pthread_mutex_init(&m_mutex, NULL);
        }

        multi_threaded_local(const multi_threaded_local&)
        {
            pthread_mutex_init(&m_mutex, NULL);
        }

        virtual ~multi_threaded_local()
        {
            pthread_mutex_destroy(&m_mutex);
        }

        virtual void lock()
        {
            pthread_mutex_lock(&m_mutex);
        }

        virtual void unlock()
        {
            pthread_mutex_unlock(&m_mutex);
        }

    private:
        pthread_mutex_t m_mutex;
    };
#endif // _SIGSLOT_HAS_POSIX_THREADS

#ifdef _SIGSLOT_HAS_TBB
    typedef tbb::spin_mutex tbb_mutex;

    // The multi threading policies only get compiled in if they are enabled.
    class multi_threaded_global
    {
    public:
        multi_threaded_global()
        {
            ;
        }

        multi_threaded_global(const multi_threaded_global&)
        {
            ;
        }

        virtual ~multi_threaded_global()
        {
            ;
        }

        virtual void lock()
        {
            get_mutex()->lock();
        }

        virtual void unlock()
        {
            get_mutex()->unlock();
        }

    private:
        tbb_mutex* get_mutex()
        {
            static tbb_mutex g_mutex;
            return &g_mutex;
        }
    };

    class multi_threaded_local
    {
    public:
        multi_threaded_local()
        {
            ;
        }

        multi_threaded_local(const multi_threaded_local&)
        {
            ;
        }

        virtual ~multi_threaded_local()
        {
            ;
        }

        virtual void lock()
        {
            m_mutex.lock();
        }

        virtual void unlock()
        {
            m_mutex.unlock();
        }

    private:
        tbb_mutex m_mutex;
    };
#endif // _SIGSLOT_HAS_TBB
schultezub's avatar
schultezub committed
365
    
schultezub's avatar
schultezub committed
366
367
368
369
    template<class mt_policy>
    class lock_block
    {
    public:
schultezub's avatar
schultezub committed
370
371
372
        mt_policy* m_mutex;
        
        lock_block(mt_policy *mtx) : m_mutex(mtx)
schultezub's avatar
schultezub committed
373
374
375
        {
            m_mutex->lock();
        }
schultezub's avatar
schultezub committed
376
        
schultezub's avatar
schultezub committed
377
378
379
380
381
        ~lock_block()
        {
            m_mutex->unlock();
        }
    };
schultezub's avatar
schultezub committed
382
    
schultezub's avatar
schultezub committed
383
384
    template<class mt_policy>
    class has_slots;
schultezub's avatar
schultezub committed
385
    
schultezub's avatar
schultezub committed
386
387
388
389
    template<class mt_policy>
    class _connection_base0
    {
    public:
schultezub's avatar
schultezub committed
390
        virtual ~_connection_base0() {}
schultezub's avatar
schultezub committed
391
392
393
394
395
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal() = 0;
        virtual _connection_base0* clone() = 0;
        virtual _connection_base0* duplicate(has_slots<mt_policy>* pnewdest) = 0;
    };
schultezub's avatar
schultezub committed
396
    
schultezub's avatar
schultezub committed
397
398
399
400
    template<class arg1_type, class mt_policy>
    class _connection_base1
    {
    public:
schultezub's avatar
schultezub committed
401
        virtual ~_connection_base1() {}
schultezub's avatar
schultezub committed
402
403
404
405
406
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type) = 0;
        virtual _connection_base1<arg1_type, mt_policy>* clone() = 0;
        virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
    };
schultezub's avatar
schultezub committed
407
    
schultezub's avatar
schultezub committed
408
409
410
411
    template<class arg1_type, class arg2_type, class mt_policy>
    class _connection_base2
    {
    public:
schultezub's avatar
schultezub committed
412
        virtual ~_connection_base2() {}
schultezub's avatar
schultezub committed
413
414
415
416
417
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type) = 0;
        virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone() = 0;
        virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
    };
schultezub's avatar
schultezub committed
418
    
schultezub's avatar
schultezub committed
419
420
421
422
    template<class arg1_type, class arg2_type, class arg3_type, class mt_policy>
    class _connection_base3
    {
    public:
schultezub's avatar
schultezub committed
423
        virtual ~_connection_base3() {}
schultezub's avatar
schultezub committed
424
425
426
427
428
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type, arg3_type) = 0;
        virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone() = 0;
        virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
    };
schultezub's avatar
schultezub committed
429
    
schultezub's avatar
schultezub committed
430
431
432
433
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy>
    class _connection_base4
    {
    public:
schultezub's avatar
schultezub committed
434
        virtual ~_connection_base4() {}
schultezub's avatar
schultezub committed
435
436
437
438
439
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type, arg3_type, arg4_type) = 0;
        virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone() = 0;
        virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
    };
schultezub's avatar
schultezub committed
440
    
schultezub's avatar
schultezub committed
441
442
443
444
445
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
    class arg5_type, class mt_policy>
    class _connection_base5
    {
    public:
schultezub's avatar
schultezub committed
446
        virtual ~_connection_base5() {}
schultezub's avatar
schultezub committed
447
448
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type, arg3_type, arg4_type, 
schultezub's avatar
schultezub committed
449
                          arg5_type) = 0;
schultezub's avatar
schultezub committed
450
        virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
451
        arg5_type, mt_policy>* clone() = 0;
schultezub's avatar
schultezub committed
452
        virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
453
        arg5_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
schultezub's avatar
schultezub committed
454
    };
schultezub's avatar
schultezub committed
455
    
schultezub's avatar
schultezub committed
456
457
458
459
460
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
    class arg5_type, class arg6_type, class mt_policy>
    class _connection_base6
    {
    public:
schultezub's avatar
schultezub committed
461
        virtual ~_connection_base6() {}
schultezub's avatar
schultezub committed
462
463
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
schultezub's avatar
schultezub committed
464
                          arg6_type) = 0;
schultezub's avatar
schultezub committed
465
        virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
466
        arg5_type, arg6_type, mt_policy>* clone() = 0;
schultezub's avatar
schultezub committed
467
        virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
468
        arg5_type, arg6_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
schultezub's avatar
schultezub committed
469
    };
schultezub's avatar
schultezub committed
470
    
schultezub's avatar
schultezub committed
471
472
473
474
475
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
    class arg5_type, class arg6_type, class arg7_type, class mt_policy>
    class _connection_base7
    {
    public:
schultezub's avatar
schultezub committed
476
        virtual ~_connection_base7() {}
schultezub's avatar
schultezub committed
477
478
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
schultezub's avatar
schultezub committed
479
                          arg6_type, arg7_type) = 0;
schultezub's avatar
schultezub committed
480
        virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
481
        arg5_type, arg6_type, arg7_type, mt_policy>* clone() = 0;
schultezub's avatar
schultezub committed
482
        virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
483
        arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
schultezub's avatar
schultezub committed
484
    };
schultezub's avatar
schultezub committed
485
    
schultezub's avatar
schultezub committed
486
487
488
489
490
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
    class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy>
    class _connection_base8
    {
    public:
schultezub's avatar
schultezub committed
491
        virtual ~_connection_base8() {}
schultezub's avatar
schultezub committed
492
493
        virtual has_slots<mt_policy>* getdest() const = 0;
        virtual void emitSignal(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
schultezub's avatar
schultezub committed
494
                          arg6_type, arg7_type, arg8_type) = 0;
schultezub's avatar
schultezub committed
495
        virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
496
        arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone() = 0;
schultezub's avatar
schultezub committed
497
        virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
498
        arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
schultezub's avatar
schultezub committed
499
    };
schultezub's avatar
schultezub committed
500
    
schultezub's avatar
schultezub committed
501
502
503
504
505
    template<class mt_policy>
    class _signal_base : public mt_policy
    {
    public:
        virtual void slot_disconnect(has_slots<mt_policy>* pslot) = 0;
schultezub's avatar
schultezub committed
506
        virtual void slot_duplicate(has_slots<mt_policy> const* poldslot, has_slots<mt_policy>* pnewslot) = 0;
schultezub's avatar
schultezub committed
507
    };
schultezub's avatar
schultezub committed
508
    
schultezub's avatar
schultezub committed
509
510
511
512
    template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
    class has_slots : public mt_policy 
    {
    private:
schultezub's avatar
schultezub committed
513
        typedef typename std::set<_signal_base<mt_policy> *> sender_set;
schultezub's avatar
schultezub committed
514
        typedef typename sender_set::const_iterator const_iterator;
schultezub's avatar
schultezub committed
515
        
schultezub's avatar
schultezub committed
516
    public:
schultezub's avatar
schultezub committed
517
518
519
        has_slots() {}
        
        has_slots(has_slots const& hs) : mt_policy(hs)
schultezub's avatar
schultezub committed
520
521
522
523
        {
            lock_block<mt_policy> lock(this);
            const_iterator it = hs.m_senders.begin();
            const_iterator itEnd = hs.m_senders.end();
schultezub's avatar
schultezub committed
524
525
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
526
527
528
529
530
                (*it)->slot_duplicate(&hs, this);
                m_senders.insert(*it);
                ++it;
            }
        } 
schultezub's avatar
schultezub committed
531
        
schultezub's avatar
schultezub committed
532
533
534
535
536
        void signal_connect(_signal_base<mt_policy>* sender)
        {
            lock_block<mt_policy> lock(this);
            m_senders.insert(sender);
        }
schultezub's avatar
schultezub committed
537
        
schultezub's avatar
schultezub committed
538
539
540
541
542
        void signal_disconnect(_signal_base<mt_policy>* sender)
        {
            lock_block<mt_policy> lock(this);
            m_senders.erase(sender);
        }
schultezub's avatar
schultezub committed
543
        
schultezub's avatar
schultezub committed
544
545
546
547
        virtual ~has_slots()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
548
        
schultezub's avatar
schultezub committed
549
550
551
552
553
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
            const_iterator it = m_senders.begin();
            const_iterator itEnd = m_senders.end();
schultezub's avatar
schultezub committed
554
555
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
556
557
558
                (*it)->slot_disconnect(this);
                ++it;
            }
schultezub's avatar
schultezub committed
559
            
schultezub's avatar
schultezub committed
560
561
            m_senders.erase(m_senders.begin(), m_senders.end());
        }
schultezub's avatar
schultezub committed
562
        
schultezub's avatar
schultezub committed
563
564
565
    private:
        sender_set m_senders;
    };
schultezub's avatar
schultezub committed
566
    
schultezub's avatar
schultezub committed
567
568
569
570
571
    template<class mt_policy>
    class _signal_base0 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base0<mt_policy> *>  connections_list;
schultezub's avatar
schultezub committed
572
573
574
575
        
        _signal_base0() {}
        
        _signal_base0(_signal_base0 const& s) : _signal_base<mt_policy>(s)
schultezub's avatar
schultezub committed
576
577
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
578
579
580
581
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
582
583
584
585
586
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
                ++it;
            }
        }
schultezub's avatar
schultezub committed
587
        
schultezub's avatar
schultezub committed
588
589
590
591
        ~_signal_base0()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
592
        
schultezub's avatar
schultezub committed
593
594
595
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
596
597
598
599
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
600
601
602
603
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
                ++it;
            }
schultezub's avatar
schultezub committed
604
            
schultezub's avatar
schultezub committed
605
606
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
607
        
schultezub's avatar
schultezub committed
608
609
610
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
611
612
613
614
615
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
616
617
618
619
620
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
621
                
schultezub's avatar
schultezub committed
622
623
624
                ++it;
            }
        }
schultezub's avatar
schultezub committed
625
        
schultezub's avatar
schultezub committed
626
627
628
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
629
630
631
632
633
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                typename connections_list::iterator itNext = it;
schultezub's avatar
schultezub committed
634
                ++itNext;
schultezub's avatar
schultezub committed
635
636
                
                if ((*it)->getdest() == pslot) {
schultezub's avatar
schultezub committed
637
                    m_connected_slots.erase(it);
schultezub's avatar
schultezub committed
638
                    //          delete *it;
schultezub's avatar
schultezub committed
639
                }
schultezub's avatar
schultezub committed
640
                
schultezub's avatar
schultezub committed
641
642
643
                it = itNext;
            }
        }
schultezub's avatar
schultezub committed
644
645
        
        void slot_duplicate(has_slots<mt_policy> const* oldtarget, has_slots<mt_policy>* newtarget)
schultezub's avatar
schultezub committed
646
647
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
648
649
650
651
652
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
653
654
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
655
                
schultezub's avatar
schultezub committed
656
657
658
                ++it;
            }
        }
schultezub's avatar
schultezub committed
659
        
schultezub's avatar
schultezub committed
660
661
662
    protected:
        connections_list m_connected_slots;   
    };
schultezub's avatar
schultezub committed
663
    
schultezub's avatar
schultezub committed
664
665
666
667
668
    template<class arg1_type, class mt_policy>
    class _signal_base1 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base1<arg1_type, mt_policy> *>  connections_list;
schultezub's avatar
schultezub committed
669
670
671
672
        
        _signal_base1() {}
        
        _signal_base1(_signal_base1<arg1_type, mt_policy> const& s) : _signal_base<mt_policy>(s)
schultezub's avatar
schultezub committed
673
674
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
675
676
677
678
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
679
680
681
682
683
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
                ++it;
            }
        }
schultezub's avatar
schultezub committed
684
685
        
        void slot_duplicate(has_slots<mt_policy> const* oldtarget, has_slots<mt_policy>* newtarget)
schultezub's avatar
schultezub committed
686
687
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
688
689
690
691
692
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
693
694
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
695
                
schultezub's avatar
schultezub committed
696
697
698
                ++it;
            }
        }
schultezub's avatar
schultezub committed
699
        
schultezub's avatar
schultezub committed
700
701
702
703
        ~_signal_base1()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
704
        
schultezub's avatar
schultezub committed
705
706
707
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
708
709
710
711
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
712
713
714
715
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
                ++it;
            }
schultezub's avatar
schultezub committed
716
            
schultezub's avatar
schultezub committed
717
718
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
719
        
schultezub's avatar
schultezub committed
720
721
722
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
723
724
725
726
727
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
728
729
730
731
732
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
733
                
schultezub's avatar
schultezub committed
734
735
736
                ++it;
            }
        }
schultezub's avatar
schultezub committed
737
        
schultezub's avatar
schultezub committed
738
739
740
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
741
742
743
744
745
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                typename connections_list::iterator itNext = it;
schultezub's avatar
schultezub committed
746
                ++itNext;
schultezub's avatar
schultezub committed
747
748
                
                if ((*it)->getdest() == pslot) {
schultezub's avatar
schultezub committed
749
                    m_connected_slots.erase(it);
schultezub's avatar
schultezub committed
750
                    //          delete *it;
schultezub's avatar
schultezub committed
751
                }
schultezub's avatar
schultezub committed
752
                
schultezub's avatar
schultezub committed
753
754
755
                it = itNext;
            }
        }
schultezub's avatar
schultezub committed
756
757
        
        
schultezub's avatar
schultezub committed
758
759
760
    protected:
        connections_list m_connected_slots;   
    };
schultezub's avatar
schultezub committed
761
    
schultezub's avatar
schultezub committed
762
763
764
765
766
    template<class arg1_type, class arg2_type, class mt_policy>
    class _signal_base2 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base2<arg1_type, arg2_type, mt_policy> *>
schultezub's avatar
schultezub committed
767
768
769
770
771
        connections_list;
        
        _signal_base2() {}
        
        _signal_base2(_signal_base2<arg1_type, arg2_type, mt_policy> const& s) : _signal_base<mt_policy>(s)
schultezub's avatar
schultezub committed
772
773
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
774
775
776
777
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
778
779
780
781
782
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
                ++it;
            }
        }
schultezub's avatar
schultezub committed
783
784
        
        void slot_duplicate(has_slots<mt_policy> const* oldtarget, has_slots<mt_policy>* newtarget)
schultezub's avatar
schultezub committed
785
786
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
787
788
789
790
791
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
792
793
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
794
                
schultezub's avatar
schultezub committed
795
796
797
                ++it;
            }
        }
schultezub's avatar
schultezub committed
798
        
schultezub's avatar
schultezub committed
799
800
801
802
        ~_signal_base2()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
803
        
schultezub's avatar
schultezub committed
804
805
806
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
807
808
809
810
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
811
812
813
814
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
                ++it;
            }
schultezub's avatar
schultezub committed
815
            
schultezub's avatar
schultezub committed
816
817
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
818
        
schultezub's avatar
schultezub committed
819
820
821
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
822
823
824
825
826
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
827
828
829
830
831
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
832
                
schultezub's avatar
schultezub committed
833
834
835
                ++it;
            }
        }
schultezub's avatar
schultezub committed
836
        
schultezub's avatar
schultezub committed
837
838
839
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
840
841
842
843
844
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                typename connections_list::iterator itNext = it;
schultezub's avatar
schultezub committed
845
                ++itNext;
schultezub's avatar
schultezub committed
846
847
                
                if ((*it)->getdest() == pslot) {
schultezub's avatar
schultezub committed
848
                    m_connected_slots.erase(it);
schultezub's avatar
schultezub committed
849
                    //          delete *it;
schultezub's avatar
schultezub committed
850
                }
schultezub's avatar
schultezub committed
851
                
schultezub's avatar
schultezub committed
852
853
854
                it = itNext;
            }
        }
schultezub's avatar
schultezub committed
855
        
schultezub's avatar
schultezub committed
856
857
858
    protected:
        connections_list m_connected_slots;   
    };
schultezub's avatar
schultezub committed
859
    
schultezub's avatar
schultezub committed
860
861
862
863
864
    template<class arg1_type, class arg2_type, class arg3_type, class mt_policy>
    class _signal_base3 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base3<arg1_type, arg2_type, arg3_type, mt_policy> *>
schultezub's avatar
schultezub committed
865
866
867
868
869
870
871
872
873
874
875
876
        connections_list;
        
        _signal_base3() {}
        
        _signal_base3(_signal_base3<arg1_type, arg2_type, arg3_type, mt_policy> const& s)
        : _signal_base<mt_policy>(s)
        {
            lock_block<mt_policy> lock(this);
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
877
878
879
880
881
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
                ++it;
            }
        }
schultezub's avatar
schultezub committed
882
883
        
        void slot_duplicate(has_slots<mt_policy> const* oldtarget, has_slots<mt_policy>* newtarget)
schultezub's avatar
schultezub committed
884
885
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
886
887
888
889
890
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
891
892
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
893
                
schultezub's avatar
schultezub committed
894
895
896
                ++it;
            }
        }
schultezub's avatar
schultezub committed
897
        
schultezub's avatar
schultezub committed
898
899
900
901
        ~_signal_base3()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
902
        
schultezub's avatar
schultezub committed
903
904
905
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
906
907
908
909
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
910
911
912
913
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
                ++it;
            }
schultezub's avatar
schultezub committed
914
            
schultezub's avatar
schultezub committed
915
916
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
917
        
schultezub's avatar
schultezub committed
918
919
920
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
921
922
923
924
925
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
926
927
928
929
930
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
931
                
schultezub's avatar
schultezub committed
932
933
934
                ++it;
            }
        }
schultezub's avatar
schultezub committed
935
        
schultezub's avatar
schultezub committed
936
937
938
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
939
940
941
942
943
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                typename connections_list::iterator itNext = it;
schultezub's avatar
schultezub committed
944
                ++itNext;
schultezub's avatar
schultezub committed
945
946
                
                if ((*it)->getdest() == pslot) {
schultezub's avatar
schultezub committed
947
                    m_connected_slots.erase(it);
schultezub's avatar
schultezub committed
948
                    //          delete *it;
schultezub's avatar
schultezub committed
949
                }
schultezub's avatar
schultezub committed
950
                
schultezub's avatar
schultezub committed
951
952
953
                it = itNext;
            }
        }
schultezub's avatar
schultezub committed
954
        
schultezub's avatar
schultezub committed
955
956
957
    protected:
        connections_list m_connected_slots;   
    };
schultezub's avatar
schultezub committed
958
    
schultezub's avatar
schultezub committed
959
960
961
962
963
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy>
    class _signal_base4 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base4<arg1_type, arg2_type, arg3_type,
schultezub's avatar
schultezub committed
964
965
966
967
        arg4_type, mt_policy> *>  connections_list;
        
        _signal_base4() {}
        
schultezub's avatar
schultezub committed
968
        _signal_base4(const _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s)
schultezub's avatar
schultezub committed
969
        : _signal_base<mt_policy>(s)
schultezub's avatar
schultezub committed
970
971
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
972
973
974
975
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
976
977
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
schultezub's avatar
schultezub committed
978
                
schultezub's avatar
schultezub committed
979
980
981
                ++it;
            }
        }
schultezub's avatar
schultezub committed
982
        
schultezub's avatar
schultezub committed
983
984
985
        void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
986
987
988
989
990
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
991
992
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
993
                
schultezub's avatar
schultezub committed
994
995
996
                ++it;
            }
        }
schultezub's avatar
schultezub committed
997
        
schultezub's avatar
schultezub committed
998
999
1000
1001
        ~_signal_base4()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
1002
        
schultezub's avatar
schultezub committed
1003
1004
1005
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1006
1007
1008
1009
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
1010
1011
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
schultezub's avatar
schultezub committed
1012
                
schultezub's avatar
schultezub committed
1013
1014
                ++it;
            }
schultezub's avatar
schultezub committed
1015
            
schultezub's avatar
schultezub committed
1016
1017
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
1018
        
schultezub's avatar
schultezub committed
1019
1020
1021
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1022
1023
1024
1025
1026
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
1027
1028
1029
1030
1031
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
1032
                
schultezub's avatar
schultezub committed
1033
1034
1035
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1036
        
schultezub's avatar
schultezub committed
1037
1038
1039
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1040
1041
1042
1043
1044
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                typename connections_list::iterator itNext = it;
schultezub's avatar
schultezub committed
1045
                ++itNext;
schultezub's avatar
schultezub committed
1046
1047
                
                if ((*it)->getdest() == pslot) {
schultezub's avatar
schultezub committed
1048
                    m_connected_slots.erase(it);
schultezub's avatar
schultezub committed
1049
                    //          delete *it;
schultezub's avatar
schultezub committed
1050
                }
schultezub's avatar
schultezub committed
1051
                
schultezub's avatar
schultezub committed
1052
1053
1054
                it = itNext;
            }
        }
schultezub's avatar
schultezub committed
1055
        
schultezub's avatar
schultezub committed
1056
1057
1058
    protected:
        connections_list m_connected_slots;   
    };
schultezub's avatar
schultezub committed
1059
    
schultezub's avatar
schultezub committed
1060
1061
1062
1063
1064
1065
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
    class arg5_type, class mt_policy>
    class _signal_base5 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base5<arg1_type, arg2_type, arg3_type,
schultezub's avatar
schultezub committed
1066
1067
1068
1069
        arg4_type, arg5_type, mt_policy> *>  connections_list;
        
        _signal_base5() {}
        
schultezub's avatar
schultezub committed
1070
        _signal_base5(const _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
1071
1072
                      arg5_type, mt_policy>& s)
        : _signal_base<mt_policy>(s)
schultezub's avatar
schultezub committed
1073
1074
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1075
1076
1077
1078
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
1079
1080
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
schultezub's avatar
schultezub committed
1081
                
schultezub's avatar
schultezub committed
1082
1083
1084
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1085
        
schultezub's avatar
schultezub committed
1086
1087
1088
        void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1089
1090
1091
1092
1093
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
1094
1095
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
1096
                
schultezub's avatar
schultezub committed
1097
1098
1099
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1100
        
schultezub's avatar
schultezub committed
1101
1102
1103
1104
        ~_signal_base5()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
1105
        
schultezub's avatar
schultezub committed
1106
1107
1108
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1109
1110
1111
1112
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
1113
1114
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
schultezub's avatar
schultezub committed
1115
                
schultezub's avatar
schultezub committed
1116
1117
                ++it;
            }
schultezub's avatar
schultezub committed
1118
            
schultezub's avatar
schultezub committed
1119
1120
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
1121
        
schultezub's avatar
schultezub committed
1122
1123
1124
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1125
1126
1127
1128
1129
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
1130
1131
1132
1133
1134
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
1135
                
schultezub's avatar
schultezub committed
1136
1137
1138
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1139
        
schultezub's avatar
schultezub committed
1140
1141
1142
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1143
1144
1145
1146
1147
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                typename connections_list::iterator itNext = it;
schultezub's avatar
schultezub committed
1148
                ++itNext;
schultezub's avatar
schultezub committed
1149
1150
                
                if ((*it)->getdest() == pslot) {
schultezub's avatar
schultezub committed
1151
                    m_connected_slots.erase(it);
schultezub's avatar
schultezub committed
1152
                    //          delete *it;
schultezub's avatar
schultezub committed
1153
                }
schultezub's avatar
schultezub committed
1154
                
schultezub's avatar
schultezub committed
1155
1156
1157
                it = itNext;
            }
        }
schultezub's avatar
schultezub committed
1158
        
schultezub's avatar
schultezub committed
1159
1160
1161
    protected:
        connections_list m_connected_slots;   
    };
schultezub's avatar
schultezub committed
1162
    
schultezub's avatar
schultezub committed
1163
1164
1165
1166
1167
1168
    template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
    class arg5_type, class arg6_type, class mt_policy>
    class _signal_base6 : public _signal_base<mt_policy>
    {
    public:
        typedef std::list<_connection_base6<arg1_type, arg2_type, arg3_type, 
schultezub's avatar
schultezub committed
1169
1170
1171
1172
        arg4_type, arg5_type, arg6_type, mt_policy> *>  connections_list;
        
        _signal_base6() {}
        
schultezub's avatar
schultezub committed
1173
        _signal_base6(const _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type,
schultezub's avatar
schultezub committed
1174
1175
                      arg5_type, arg6_type, mt_policy>& s)
        : _signal_base<mt_policy>(s)
schultezub's avatar
schultezub committed
1176
1177
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1178
1179
1180
1181
            typename connections_list::const_iterator it = s.m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = s.m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
1182
1183
                (*it)->getdest()->signal_connect(this);
                m_connected_slots.push_back((*it)->clone());
schultezub's avatar
schultezub committed
1184
                
schultezub's avatar
schultezub committed
1185
1186
1187
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1188
        
schultezub's avatar
schultezub committed
1189
1190
1191
        void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1192
1193
1194
1195
1196
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == oldtarget) {
schultezub's avatar
schultezub committed
1197
1198
                    m_connected_slots.push_back((*it)->duplicate(newtarget));
                }
schultezub's avatar
schultezub committed
1199
                
schultezub's avatar
schultezub committed
1200
1201
1202
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1203
        
schultezub's avatar
schultezub committed
1204
1205
1206
1207
        ~_signal_base6()
        {
            disconnect_all();
        }
schultezub's avatar
schultezub committed
1208
        
schultezub's avatar
schultezub committed
1209
1210
1211
        void disconnect_all()
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1212
1213
1214
1215
            typename connections_list::const_iterator it = m_connected_slots.begin();
            typename connections_list::const_iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
schultezub's avatar
schultezub committed
1216
1217
                (*it)->getdest()->signal_disconnect(this);
                delete *it;
schultezub's avatar
schultezub committed
1218
                
schultezub's avatar
schultezub committed
1219
1220
                ++it;
            }
schultezub's avatar
schultezub committed
1221
            
schultezub's avatar
schultezub committed
1222
1223
            m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
        }
schultezub's avatar
schultezub committed
1224
        
schultezub's avatar
schultezub committed
1225
1226
1227
        void disconnect(has_slots<mt_policy>* pclass)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1228
1229
1230
1231
1232
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd) {
                if ((*it)->getdest() == pclass) {
schultezub's avatar
schultezub committed
1233
1234
1235
1236
1237
                    delete *it;
                    m_connected_slots.erase(it);
                    pclass->signal_disconnect(this);
                    return;
                }
schultezub's avatar
schultezub committed
1238
                
schultezub's avatar
schultezub committed
1239
1240
1241
                ++it;
            }
        }
schultezub's avatar
schultezub committed
1242
        
schultezub's avatar
schultezub committed
1243
1244
1245
        void slot_disconnect(has_slots<mt_policy>* pslot)
        {
            lock_block<mt_policy> lock(this);
schultezub's avatar
schultezub committed
1246
1247
1248
1249
1250
            typename connections_list::iterator it = m_connected_slots.begin();
            typename connections_list::iterator itEnd = m_connected_slots.end();
            
            while (it != itEnd)