michael@0: // sigslot.h: Signal/Slot classes michael@0: // michael@0: // Written by Sarah Thompson (sarah@telergy.com) 2002. michael@0: // michael@0: // License: Public domain. You are free to use this code however you like, with the proviso that michael@0: // the author takes on no responsibility or liability for any use. michael@0: // michael@0: // QUICK DOCUMENTATION michael@0: // michael@0: // (see also the full documentation at http://sigslot.sourceforge.net/) michael@0: // michael@0: // #define switches michael@0: // SIGSLOT_PURE_ISO - Define this to force ISO C++ compliance. This also disables michael@0: // all of the thread safety support on platforms where it is michael@0: // available. michael@0: // michael@0: // SIGSLOT_USE_POSIX_THREADS - Force use of Posix threads when using a C++ compiler other than michael@0: // gcc on a platform that supports Posix threads. (When using gcc, michael@0: // this is the default - use SIGSLOT_PURE_ISO to disable this if michael@0: // necessary) michael@0: // michael@0: // SIGSLOT_DEFAULT_MT_POLICY - Where thread support is enabled, this defaults to multi_threaded_global. michael@0: // Otherwise, the default is single_threaded. #define this yourself to michael@0: // override the default. In pure ISO mode, anything other than michael@0: // single_threaded will cause a compiler error. michael@0: // michael@0: // PLATFORM NOTES michael@0: // michael@0: // Win32 - On Win32, the WIN32 symbol must be #defined. Most mainstream michael@0: // compilers do this by default, but you may need to define it michael@0: // yourself if your build environment is less standard. This causes michael@0: // the Win32 thread support to be compiled in and used automatically. michael@0: // michael@0: // Unix/Linux/BSD, etc. - If you're using gcc, it is assumed that you have Posix threads michael@0: // available, so they are used automatically. You can override this michael@0: // (as under Windows) with the SIGSLOT_PURE_ISO switch. If you're using michael@0: // something other than gcc but still want to use Posix threads, you michael@0: // need to #define SIGSLOT_USE_POSIX_THREADS. michael@0: // michael@0: // ISO C++ - If none of the supported platforms are detected, or if michael@0: // SIGSLOT_PURE_ISO is defined, all multithreading support is turned off, michael@0: // along with any code that might cause a pure ISO C++ environment to michael@0: // complain. Before you ask, gcc -ansi -pedantic won't compile this michael@0: // library, but gcc -ansi is fine. Pedantic mode seems to throw a lot of michael@0: // errors that aren't really there. If you feel like investigating this, michael@0: // please contact the author. michael@0: // michael@0: // michael@0: // THREADING MODES michael@0: // michael@0: // single_threaded - Your program is assumed to be single threaded from the point of view michael@0: // of signal/slot usage (i.e. all objects using signals and slots are michael@0: // created and destroyed from a single thread). Behaviour if objects are michael@0: // destroyed concurrently is undefined (i.e. you'll get the occasional michael@0: // segmentation fault/memory exception). michael@0: // michael@0: // multi_threaded_global - Your program is assumed to be multi threaded. Objects using signals and michael@0: // slots can be safely created and destroyed from any thread, even when michael@0: // connections exist. In multi_threaded_global mode, this is achieved by a michael@0: // single global mutex (actually a critical section on Windows because they michael@0: // are faster). This option uses less OS resources, but results in more michael@0: // opportunities for contention, possibly resulting in more context switches michael@0: // than are strictly necessary. michael@0: // michael@0: // multi_threaded_local - Behaviour in this mode is essentially the same as multi_threaded_global, michael@0: // except that each signal, and each object that inherits has_slots, all michael@0: // have their own mutex/critical section. In practice, this means that michael@0: // mutex collisions (and hence context switches) only happen if they are michael@0: // absolutely essential. However, on some platforms, creating a lot of michael@0: // mutexes can slow down the whole OS, so use this option with care. michael@0: // michael@0: // USING THE LIBRARY michael@0: // michael@0: // See the full documentation at http://sigslot.sourceforge.net/ michael@0: // michael@0: // michael@0: // Libjingle specific: michael@0: // This file has been modified such that has_slots and signalx do not have to be michael@0: // using the same threading requirements. E.g. it is possible to connect a michael@0: // has_slots and signal0 or michael@0: // has_slots and signal0. michael@0: // If has_slots is single threaded the user must ensure that it is not trying michael@0: // to connect or disconnect to signalx concurrently or data race may occur. michael@0: // If signalx is single threaded the user must ensure that disconnect, connect michael@0: // or signal is not happening concurrently or data race may occur. michael@0: michael@0: #ifndef TALK_BASE_SIGSLOT_H__ michael@0: #define TALK_BASE_SIGSLOT_H__ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: // On our copy of sigslot.h, we set single threading as default. michael@0: #define SIGSLOT_DEFAULT_MT_POLICY single_threaded michael@0: michael@0: // For now, this avoids windows.h in bindings (PeerConnectionImpl.h) on WIN32 michael@0: // TODO: wrap win32 crit section and move to another file instead (Bug 932570) michael@0: #define SIGSLOT_LEAVE_OUT_MULTITHREADING 1 michael@0: michael@0: #if defined(SIGSLOT_PURE_ISO) || (!defined(WIN32) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS)) michael@0: # define _SIGSLOT_SINGLE_THREADED michael@0: #elif defined(WIN32) michael@0: # define _SIGSLOT_HAS_WIN32_THREADS michael@0: # ifndef SIGSLOT_LEAVE_OUT_MULTITHREADING michael@0: # if !defined(WIN32_LEAN_AND_MEAN) michael@0: # define WIN32_LEAN_AND_MEAN michael@0: # endif michael@0: # include "windows.h" michael@0: # endif michael@0: #elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS) michael@0: # define _SIGSLOT_HAS_POSIX_THREADS michael@0: # include michael@0: #else michael@0: # define _SIGSLOT_SINGLE_THREADED michael@0: #endif michael@0: michael@0: #ifndef SIGSLOT_DEFAULT_MT_POLICY michael@0: # ifdef _SIGSLOT_SINGLE_THREADED michael@0: # define SIGSLOT_DEFAULT_MT_POLICY single_threaded michael@0: # else michael@0: # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local michael@0: # endif michael@0: #endif michael@0: michael@0: // TODO: change this namespace to talk_base? michael@0: namespace sigslot { michael@0: michael@0: class single_threaded michael@0: { michael@0: public: michael@0: single_threaded() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual ~single_threaded() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual void lock() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual void unlock() michael@0: { michael@0: ; michael@0: } michael@0: }; michael@0: michael@0: #ifndef SIGSLOT_LEAVE_OUT_MULTITHREADING michael@0: # ifdef _SIGSLOT_HAS_WIN32_THREADS michael@0: michael@0: // The multi threading policies only get compiled in if they are enabled. michael@0: class multi_threaded_global michael@0: { michael@0: public: michael@0: multi_threaded_global() michael@0: { michael@0: static bool isinitialised = false; michael@0: michael@0: if(!isinitialised) michael@0: { michael@0: InitializeCriticalSection(get_critsec()); michael@0: isinitialised = true; michael@0: } michael@0: } michael@0: michael@0: multi_threaded_global(const multi_threaded_global&) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual ~multi_threaded_global() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual void lock() michael@0: { michael@0: EnterCriticalSection(get_critsec()); michael@0: } michael@0: michael@0: virtual void unlock() michael@0: { michael@0: LeaveCriticalSection(get_critsec()); michael@0: } michael@0: michael@0: private: michael@0: CRITICAL_SECTION* get_critsec() michael@0: { michael@0: static CRITICAL_SECTION g_critsec; michael@0: return &g_critsec; michael@0: } michael@0: }; michael@0: michael@0: class multi_threaded_local michael@0: { michael@0: public: michael@0: multi_threaded_local() michael@0: { michael@0: InitializeCriticalSection(&m_critsec); michael@0: } michael@0: michael@0: multi_threaded_local(const multi_threaded_local&) michael@0: { michael@0: InitializeCriticalSection(&m_critsec); michael@0: } michael@0: michael@0: virtual ~multi_threaded_local() michael@0: { michael@0: DeleteCriticalSection(&m_critsec); michael@0: } michael@0: michael@0: virtual void lock() michael@0: { michael@0: EnterCriticalSection(&m_critsec); michael@0: } michael@0: michael@0: virtual void unlock() michael@0: { michael@0: LeaveCriticalSection(&m_critsec); michael@0: } michael@0: michael@0: private: michael@0: CRITICAL_SECTION m_critsec; michael@0: }; michael@0: # endif // _SIGSLOT_HAS_WIN32_THREADS michael@0: michael@0: # ifdef _SIGSLOT_HAS_POSIX_THREADS michael@0: // The multi threading policies only get compiled in if they are enabled. michael@0: class multi_threaded_global michael@0: { michael@0: public: michael@0: multi_threaded_global() michael@0: { michael@0: pthread_mutex_init(get_mutex(), NULL); michael@0: } michael@0: michael@0: multi_threaded_global(const multi_threaded_global&) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual ~multi_threaded_global() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual void lock() michael@0: { michael@0: pthread_mutex_lock(get_mutex()); michael@0: } michael@0: michael@0: virtual void unlock() michael@0: { michael@0: pthread_mutex_unlock(get_mutex()); michael@0: } michael@0: michael@0: private: michael@0: pthread_mutex_t* get_mutex() michael@0: { michael@0: static pthread_mutex_t g_mutex; michael@0: return &g_mutex; michael@0: } michael@0: }; michael@0: michael@0: class multi_threaded_local michael@0: { michael@0: public: michael@0: multi_threaded_local() michael@0: { michael@0: pthread_mutex_init(&m_mutex, NULL); michael@0: } michael@0: michael@0: multi_threaded_local(const multi_threaded_local&) michael@0: { michael@0: pthread_mutex_init(&m_mutex, NULL); michael@0: } michael@0: michael@0: virtual ~multi_threaded_local() michael@0: { michael@0: pthread_mutex_destroy(&m_mutex); michael@0: } michael@0: michael@0: virtual void lock() michael@0: { michael@0: pthread_mutex_lock(&m_mutex); michael@0: } michael@0: michael@0: virtual void unlock() michael@0: { michael@0: pthread_mutex_unlock(&m_mutex); michael@0: } michael@0: michael@0: private: michael@0: pthread_mutex_t m_mutex; michael@0: }; michael@0: # endif // _SIGSLOT_HAS_POSIX_THREADS michael@0: #endif // SIGSLOT_LEAVE_OUT_MULTITHREADING michael@0: michael@0: template michael@0: class lock_block michael@0: { michael@0: public: michael@0: mt_policy *m_mutex; michael@0: michael@0: lock_block(mt_policy *mtx) michael@0: : m_mutex(mtx) michael@0: { michael@0: m_mutex->lock(); michael@0: } michael@0: michael@0: ~lock_block() michael@0: { michael@0: m_mutex->unlock(); michael@0: } michael@0: }; michael@0: michael@0: class has_slots_interface; michael@0: michael@0: template michael@0: class _connection_base0 michael@0: { michael@0: public: michael@0: virtual ~_connection_base0() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit() = 0; michael@0: virtual _connection_base0* clone() = 0; michael@0: virtual _connection_base0* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base1 michael@0: { michael@0: public: michael@0: virtual ~_connection_base1() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type) = 0; michael@0: virtual _connection_base1* clone() = 0; michael@0: virtual _connection_base1* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base2 michael@0: { michael@0: public: michael@0: virtual ~_connection_base2() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type) = 0; michael@0: virtual _connection_base2* clone() = 0; michael@0: virtual _connection_base2* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base3 michael@0: { michael@0: public: michael@0: virtual ~_connection_base3() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type, arg3_type) = 0; michael@0: virtual _connection_base3* clone() = 0; michael@0: virtual _connection_base3* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base4 michael@0: { michael@0: public: michael@0: virtual ~_connection_base4() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) = 0; michael@0: virtual _connection_base4* clone() = 0; michael@0: virtual _connection_base4* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base5 michael@0: { michael@0: public: michael@0: virtual ~_connection_base5() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, michael@0: arg5_type) = 0; michael@0: virtual _connection_base5* clone() = 0; michael@0: virtual _connection_base5* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base6 michael@0: { michael@0: public: michael@0: virtual ~_connection_base6() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, michael@0: arg6_type) = 0; michael@0: virtual _connection_base6* clone() = 0; michael@0: virtual _connection_base6* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base7 michael@0: { michael@0: public: michael@0: virtual ~_connection_base7() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, michael@0: arg6_type, arg7_type) = 0; michael@0: virtual _connection_base7* clone() = 0; michael@0: virtual _connection_base7* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _connection_base8 michael@0: { michael@0: public: michael@0: virtual ~_connection_base8() {} michael@0: virtual has_slots_interface* getdest() const = 0; michael@0: virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, michael@0: arg6_type, arg7_type, arg8_type) = 0; michael@0: virtual _connection_base8* clone() = 0; michael@0: virtual _connection_base8* duplicate(has_slots_interface* pnewdest) = 0; michael@0: }; michael@0: michael@0: class _signal_base_interface michael@0: { michael@0: public: michael@0: virtual void slot_disconnect(has_slots_interface* pslot) = 0; michael@0: virtual void slot_duplicate(const has_slots_interface* poldslot, has_slots_interface* pnewslot) = 0; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base : public _signal_base_interface, public mt_policy michael@0: { michael@0: }; michael@0: michael@0: class has_slots_interface michael@0: { michael@0: public: michael@0: has_slots_interface() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: virtual void signal_connect(_signal_base_interface* sender) = 0; michael@0: michael@0: virtual void signal_disconnect(_signal_base_interface* sender) = 0; michael@0: michael@0: virtual ~has_slots_interface() michael@0: { michael@0: } michael@0: michael@0: virtual void disconnect_all() = 0; michael@0: }; michael@0: michael@0: template michael@0: class has_slots : public has_slots_interface, public mt_policy michael@0: { michael@0: private: michael@0: typedef std::set<_signal_base_interface*> sender_set; michael@0: typedef sender_set::const_iterator const_iterator; michael@0: michael@0: public: michael@0: has_slots() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: has_slots(const has_slots& hs) michael@0: { michael@0: lock_block lock(this); michael@0: const_iterator it = hs.m_senders.begin(); michael@0: const_iterator itEnd = hs.m_senders.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->slot_duplicate(&hs, this); michael@0: m_senders.insert(*it); michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void signal_connect(_signal_base_interface* sender) michael@0: { michael@0: lock_block lock(this); michael@0: m_senders.insert(sender); michael@0: } michael@0: michael@0: void signal_disconnect(_signal_base_interface* sender) michael@0: { michael@0: lock_block lock(this); michael@0: m_senders.erase(sender); michael@0: } michael@0: michael@0: virtual ~has_slots() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: const_iterator it = m_senders.begin(); michael@0: const_iterator itEnd = m_senders.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->slot_disconnect(this); michael@0: ++it; michael@0: } michael@0: michael@0: m_senders.erase(m_senders.begin(), m_senders.end()); michael@0: } michael@0: michael@0: private: michael@0: sender_set m_senders; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base0 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base0 *> connections_list; michael@0: michael@0: _signal_base0() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base0(const _signal_base0& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base0() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base1 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base1 *> connections_list; michael@0: michael@0: _signal_base1() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base1(const _signal_base1& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base1() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base2 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base2 *> michael@0: connections_list; michael@0: michael@0: _signal_base2() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base2(const _signal_base2& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base2() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base3 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base3 *> michael@0: connections_list; michael@0: michael@0: _signal_base3() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base3(const _signal_base3& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base3() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base4 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base4 *> connections_list; michael@0: michael@0: _signal_base4() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base4(const _signal_base4& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base4() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base5 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base5 *> connections_list; michael@0: michael@0: _signal_base5() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base5(const _signal_base5& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base5() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base6 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base6 *> connections_list; michael@0: michael@0: _signal_base6() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base6(const _signal_base6& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base6() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base7 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base7 *> connections_list; michael@0: michael@0: _signal_base7() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base7(const _signal_base7& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base7() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: template michael@0: class _signal_base8 : public _signal_base michael@0: { michael@0: public: michael@0: typedef std::list<_connection_base8 *> michael@0: connections_list; michael@0: michael@0: _signal_base8() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: _signal_base8(const _signal_base8& s) michael@0: : _signal_base(s) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = s.m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_connect(this); michael@0: m_connected_slots.push_back((*it)->clone()); michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_duplicate(const has_slots_interface* oldtarget, has_slots_interface* newtarget) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == oldtarget) michael@0: { michael@0: m_connected_slots.push_back((*it)->duplicate(newtarget)); michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: ~_signal_base8() michael@0: { michael@0: disconnect_all(); michael@0: } michael@0: michael@0: bool is_empty() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: return it == itEnd; michael@0: } michael@0: michael@0: void disconnect_all() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: (*it)->getdest()->signal_disconnect(this); michael@0: delete *it; michael@0: michael@0: ++it; michael@0: } michael@0: michael@0: m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); michael@0: } michael@0: michael@0: #ifdef _DEBUG michael@0: bool connected(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: if ((*it)->getdest() == pclass) michael@0: return true; michael@0: it = itNext; michael@0: } michael@0: return false; michael@0: } michael@0: #endif michael@0: michael@0: void disconnect(has_slots_interface* pclass) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: if((*it)->getdest() == pclass) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: pclass->signal_disconnect(this); michael@0: return; michael@0: } michael@0: michael@0: ++it; michael@0: } michael@0: } michael@0: michael@0: void slot_disconnect(has_slots_interface* pslot) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::iterator it = m_connected_slots.begin(); michael@0: typename connections_list::iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: typename connections_list::iterator itNext = it; michael@0: ++itNext; michael@0: michael@0: if((*it)->getdest() == pslot) michael@0: { michael@0: delete *it; michael@0: m_connected_slots.erase(it); michael@0: } michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: protected: michael@0: connections_list m_connected_slots; michael@0: }; michael@0: michael@0: michael@0: template michael@0: class _connection0 : public _connection_base0 michael@0: { michael@0: public: michael@0: _connection0() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection0(dest_type* pobject, void (dest_type::*pmemfun)()) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection0() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base0* clone() michael@0: { michael@0: return new _connection0(*this); michael@0: } michael@0: michael@0: virtual _connection_base0* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection0((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit() michael@0: { michael@0: (m_pobject->*m_pmemfun)(); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(); michael@0: }; michael@0: michael@0: template michael@0: class _connection1 : public _connection_base1 michael@0: { michael@0: public: michael@0: _connection1() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection1(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection1() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base1* clone() michael@0: { michael@0: return new _connection1(*this); michael@0: } michael@0: michael@0: virtual _connection_base1* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection1((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection2 : public _connection_base2 michael@0: { michael@0: public: michael@0: _connection2() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection2(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection2() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base2* clone() michael@0: { michael@0: return new _connection2(*this); michael@0: } michael@0: michael@0: virtual _connection_base2* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection2((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection3 : public _connection_base3 michael@0: { michael@0: public: michael@0: _connection3() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection3(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection3() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base3* clone() michael@0: { michael@0: return new _connection3(*this); michael@0: } michael@0: michael@0: virtual _connection_base3* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection3((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2, a3); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection4 : public _connection_base4 michael@0: { michael@0: public: michael@0: _connection4() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection4(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection4() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base4* clone() michael@0: { michael@0: return new _connection4(*this); michael@0: } michael@0: michael@0: virtual _connection_base4* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection4((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, michael@0: arg4_type a4) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2, a3, a4); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, michael@0: arg4_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection5 : public _connection_base5 michael@0: { michael@0: public: michael@0: _connection5() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection5(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection5() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base5* clone() michael@0: { michael@0: return new _connection5(*this); michael@0: } michael@0: michael@0: virtual _connection_base5* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection5((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, michael@0: arg5_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection6 : public _connection_base6 michael@0: { michael@0: public: michael@0: _connection6() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection6(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection6() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base6* clone() michael@0: { michael@0: return new _connection6(*this); michael@0: } michael@0: michael@0: virtual _connection_base6* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection6((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, michael@0: arg5_type, arg6_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection7 : public _connection_base7 michael@0: { michael@0: public: michael@0: _connection7() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection7(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection7() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base7* clone() michael@0: { michael@0: return new _connection7(*this); michael@0: } michael@0: michael@0: virtual _connection_base7* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection7((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6, arg7_type a7) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, michael@0: arg5_type, arg6_type, arg7_type); michael@0: }; michael@0: michael@0: template michael@0: class _connection8 : public _connection_base8 michael@0: { michael@0: public: michael@0: _connection8() michael@0: { michael@0: m_pobject = NULL; michael@0: m_pmemfun = NULL; michael@0: } michael@0: michael@0: _connection8(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, michael@0: arg7_type, arg8_type)) michael@0: { michael@0: m_pobject = pobject; michael@0: m_pmemfun = pmemfun; michael@0: } michael@0: michael@0: virtual ~_connection8() michael@0: { michael@0: } michael@0: michael@0: virtual _connection_base8* clone() michael@0: { michael@0: return new _connection8(*this); michael@0: } michael@0: michael@0: virtual _connection_base8* duplicate(has_slots_interface* pnewdest) michael@0: { michael@0: return new _connection8((dest_type *)pnewdest, m_pmemfun); michael@0: } michael@0: michael@0: virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) michael@0: { michael@0: (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8); michael@0: } michael@0: michael@0: virtual has_slots_interface* getdest() const michael@0: { michael@0: return m_pobject; michael@0: } michael@0: michael@0: private: michael@0: dest_type* m_pobject; michael@0: void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, michael@0: arg5_type, arg6_type, arg7_type, arg8_type); michael@0: }; michael@0: michael@0: template michael@0: class signal0 : public _signal_base0 michael@0: { michael@0: public: michael@0: typedef _signal_base0 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal0() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal0(const signal0& s) michael@0: : _signal_base0(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)()) michael@0: { michael@0: lock_block lock(this); michael@0: _connection0* conn = michael@0: new _connection0(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()() michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal1 : public _signal_base1 michael@0: { michael@0: public: michael@0: typedef _signal_base1 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal1() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal1(const signal1& s) michael@0: : _signal_base1(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection1* conn = michael@0: new _connection1(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal2 : public _signal_base2 michael@0: { michael@0: public: michael@0: typedef _signal_base2 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal2() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal2(const signal2& s) michael@0: : _signal_base2(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection2* conn = new michael@0: _connection2(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal3 : public _signal_base3 michael@0: { michael@0: public: michael@0: typedef _signal_base3 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal3() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal3(const signal3& s) michael@0: : _signal_base3(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection3* conn = michael@0: new _connection3(pclass, michael@0: pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2, arg3_type a3) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2, arg3_type a3) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal4 : public _signal_base4 michael@0: { michael@0: public: michael@0: typedef _signal_base4 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal4() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal4(const signal4& s) michael@0: : _signal_base4(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection4* michael@0: conn = new _connection4(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal5 : public _signal_base5 michael@0: { michael@0: public: michael@0: typedef _signal_base5 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal5() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal5(const signal5& s) michael@0: : _signal_base5(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection5* conn = new _connection5(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: michael@0: template michael@0: class signal6 : public _signal_base6 michael@0: { michael@0: public: michael@0: typedef _signal_base6 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal6() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal6(const signal6& s) michael@0: : _signal_base6(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection6* conn = michael@0: new _connection6(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5, a6); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5, a6); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal7 : public _signal_base7 michael@0: { michael@0: public: michael@0: typedef _signal_base7 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal7() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal7(const signal7& s) michael@0: : _signal_base7(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, michael@0: arg7_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection7* conn = michael@0: new _connection7(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6, arg7_type a7) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5, a6, a7); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6, arg7_type a7) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5, a6, a7); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: template michael@0: class signal8 : public _signal_base8 michael@0: { michael@0: public: michael@0: typedef _signal_base8 base; michael@0: typedef typename base::connections_list connections_list; michael@0: using base::m_connected_slots; michael@0: michael@0: signal8() michael@0: { michael@0: ; michael@0: } michael@0: michael@0: signal8(const signal8& s) michael@0: : _signal_base8(s) michael@0: { michael@0: ; michael@0: } michael@0: michael@0: template michael@0: void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, michael@0: arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, michael@0: arg7_type, arg8_type)) michael@0: { michael@0: lock_block lock(this); michael@0: _connection8* conn = michael@0: new _connection8(pclass, pmemfun); michael@0: m_connected_slots.push_back(conn); michael@0: pclass->signal_connect(this); michael@0: } michael@0: michael@0: void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: michael@0: void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, michael@0: arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) michael@0: { michael@0: lock_block lock(this); michael@0: typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); michael@0: typename connections_list::const_iterator itEnd = m_connected_slots.end(); michael@0: michael@0: while(it != itEnd) michael@0: { michael@0: itNext = it; michael@0: ++itNext; michael@0: michael@0: (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8); michael@0: michael@0: it = itNext; michael@0: } michael@0: } michael@0: }; michael@0: michael@0: } // namespace sigslot michael@0: michael@0: #endif // TALK_BASE_SIGSLOT_H__