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