- 浏览: 2037382 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (651)
- ACE (35)
- BAT (9)
- C/C++ (116)
- fast-cgi (14)
- COM (27)
- python (59)
- CGI (4)
- C# (2)
- VC (84)
- DataBase (29)
- Linux (96)
- P2P (6)
- PHP (15)
- Web (6)
- Memcached (7)
- IME输入法 (11)
- 设计模式 (2)
- 搜索引擎 (1)
- 个人情感 (4)
- 笔试/面试 (3)
- 一亩三分地 (33)
- 历史 (2)
- 地理 (1)
- 人物 (3)
- 经济 (0)
- 不仅仅是笑哦 (43)
- 小故事大道理 (2)
- http://www.bjdsmyysjk120.com/ (0)
- http://www.bjdsmyy120.com/ (0)
- 它山之石可以攻玉 (15)
- 大学生你关注些什么 (28)
- 数据恢复 (1)
最新评论
-
luokaichuang:
这个规范里还是没有让我明白当浏览器上传文件时,STDIN的消息 ...
FastCGI规范 -
effort_fan:
好文章!学习了,谢谢分享!
com技术简介 -
vcell:
有错误os.walk(strPath)返回的已经是全部的文件和 ...
通过python获取目录的大小 -
feifeigd:
feifeigd 写道注意:文章中的CPP示例第二行 #inc ...
ATL入门:利用ATL编写简单的COM组件 -
feifeigd:
注意:文章中的CPP示例第二行 #include " ...
ATL入门:利用ATL编写简单的COM组件
//测试代码
#include "sigslot.h" #include <string> #include <stdio.h> #include <iostream> using namespace std; class CSender { public: sigslot::signal2<string, int> m_pfnsigDanger; void Panic() { static int nVal = 0; char szVal[20] = {0}; sprintf(szVal, "help--%d", nVal); m_pfnsigDanger(szVal, nVal++); } }; class CReceiver:public sigslot::has_slots<> { public: void OnDanger(string strMsg, int nVal) { //printf("%s ==> %d", strMsg.c_str(), nVal); cout << strMsg.c_str() << " ==> " << nVal << endl; } }; int main() { CSender sender; CReceiver recever; cout << "create object ok..." << endl; sender.m_pfnsigDanger.connect(&recever, &CReceiver::OnDanger); cout << "connect succ!" << endl; while (1) { cout << "in while..." << endl; sender.Panic(); sleep(2); cout << "end of sleep" << endl; } return 0; }
//sigslot
// sigslot.h: Signal/Slot classes // // Written by Sarah Thompson (sarah@telergy.com) 2002. // // License: Public domain. You are free to use this code however you like, with the proviso that // the author takes on no responsibility or liability for any use. // // QUICK DOCUMENTATION // // (see also the full documentation at http://sigslot.sourceforge.net/) // // #define switches // SIGSLOT_PURE_ISO - Define this to force ISO C++ compliance. This also disables // all of the thread safety support on platforms where it is // available. // // SIGSLOT_USE_POSIX_THREADS - Force use of Posix threads when using a C++ compiler other than // gcc on a platform that supports Posix threads. (When using gcc, // this is the default - use SIGSLOT_PURE_ISO to disable this if // necessary) // // SIGSLOT_DEFAULT_MT_POLICY - Where thread support is enabled, this defaults to multi_threaded_global. // Otherwise, the default is single_threaded. #define this yourself to // override the default. In pure ISO mode, anything other than // single_threaded will cause a compiler error. // // PLATFORM NOTES // // Win32 - On Win32, the WIN32 symbol must be #defined. Most mainstream // compilers do this by default, but you may need to define it // yourself if your build environment is less standard. This causes // the Win32 thread support to be compiled in and used automatically. // // Unix/Linux/BSD, etc. - If you're using gcc, it is assumed that you have Posix threads // available, so they are used automatically. You can override this // (as under Windows) with the SIGSLOT_PURE_ISO switch. If you're using // something other than gcc but still want to use Posix threads, you // need to #define SIGSLOT_USE_POSIX_THREADS. // // ISO C++ - If none of the supported platforms are detected, or if // SIGSLOT_PURE_ISO is defined, all multithreading support is turned off, // along with any code that might cause a pure ISO C++ environment to // complain. Before you ask, gcc -ansi -pedantic won't compile this // library, but gcc -ansi is fine. Pedantic mode seems to throw a lot of // errors that aren't really there. If you feel like investigating this, // please contact the author. // // // THREADING MODES // // single_threaded - Your program is assumed to be single threaded from the point of view // of signal/slot usage (i.e. all objects using signals and slots are // created and destroyed from a single thread). Behaviour if objects are // destroyed concurrently is undefined (i.e. you'll get the occasional // segmentation fault/memory exception). // // multi_threaded_global - Your program is assumed to be multi threaded. Objects using signals and // slots can be safely created and destroyed from any thread, even when // connections exist. In multi_threaded_global mode, this is achieved by a // single global mutex (actually a critical section on Windows because they // are faster). This option uses less OS resources, but results in more // opportunities for contention, possibly resulting in more context switches // than are strictly necessary. // // multi_threaded_local - Behaviour in this mode is essentially the same as multi_threaded_global, // except that each signal, and each object that inherits has_slots, all // have their own mutex/critical section. In practice, this means that // mutex collisions (and hence context switches) only happen if they are // absolutely essential. However, on some platforms, creating a lot of // mutexes can slow down the whole OS, so use this option with care. // // USING THE LIBRARY // // See the full documentation at http://sigslot.sourceforge.net/ // // #ifndef TALK_BASE_SIGSLOT_H__ #define TALK_BASE_SIGSLOT_H__ #include <set> #include <list> // On our copy of sigslot.h, we force single threading #define SIGSLOT_PURE_ISO #if defined(SIGSLOT_PURE_ISO) || (!defined(WIN32) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS)) # define _SIGSLOT_SINGLE_THREADED #elif defined(WIN32) # define _SIGSLOT_HAS_WIN32_THREADS # include <windows.h> #elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS) # define _SIGSLOT_HAS_POSIX_THREADS # include <pthread.h> #else # define _SIGSLOT_SINGLE_THREADED #endif #ifndef SIGSLOT_DEFAULT_MT_POLICY # ifdef _SIGSLOT_SINGLE_THREADED # define SIGSLOT_DEFAULT_MT_POLICY single_threaded # else # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local # endif #endif // TODO: change this namespace to talk_base? namespace sigslot { class single_threaded { public: single_threaded() { ; } virtual ~single_threaded() { ; } virtual void lock() { ; } virtual void unlock() { ; } }; #ifdef _SIGSLOT_HAS_WIN32_THREADS // The multi threading policies only get compiled in if they are enabled. class multi_threaded_global { public: multi_threaded_global() { static bool isinitialised = false; if(!isinitialised) { InitializeCriticalSection(get_critsec()); isinitialised = true; } } multi_threaded_global(const multi_threaded_global&) { ; } virtual ~multi_threaded_global() { ; } virtual void lock() { EnterCriticalSection(get_critsec()); } virtual void unlock() { LeaveCriticalSection(get_critsec()); } private: CRITICAL_SECTION* get_critsec() { static CRITICAL_SECTION g_critsec; return &g_critsec; } }; class multi_threaded_local { public: multi_threaded_local() { InitializeCriticalSection(&m_critsec); } multi_threaded_local(const multi_threaded_local&) { InitializeCriticalSection(&m_critsec); } virtual ~multi_threaded_local() { DeleteCriticalSection(&m_critsec); } virtual void lock() { EnterCriticalSection(&m_critsec); } virtual void unlock() { LeaveCriticalSection(&m_critsec); } private: CRITICAL_SECTION m_critsec; }; #endif // _SIGSLOT_HAS_WIN32_THREADS #ifdef _SIGSLOT_HAS_POSIX_THREADS // The multi threading policies only get compiled in if they are enabled. class multi_threaded_global { public: multi_threaded_global() { pthread_mutex_init(get_mutex(), NULL); } multi_threaded_global(const multi_threaded_global&) { ; } virtual ~multi_threaded_global() { ; } virtual void lock() { pthread_mutex_lock(get_mutex()); } virtual void unlock() { pthread_mutex_unlock(get_mutex()); } private: pthread_mutex_t* get_mutex() { static pthread_mutex_t g_mutex; return &g_mutex; } }; class multi_threaded_local { public: multi_threaded_local() { pthread_mutex_init(&m_mutex, NULL); } multi_threaded_local(const multi_threaded_local&) { pthread_mutex_init(&m_mutex, NULL); } virtual ~multi_threaded_local() { pthread_mutex_destroy(&m_mutex); } virtual void lock() { pthread_mutex_lock(&m_mutex); } virtual void unlock() { pthread_mutex_unlock(&m_mutex); } private: pthread_mutex_t m_mutex; }; #endif // _SIGSLOT_HAS_POSIX_THREADS template<class mt_policy> class lock_block { public: mt_policy *m_mutex; lock_block(mt_policy *mtx) : m_mutex(mtx) { m_mutex->lock(); } ~lock_block() { m_mutex->unlock(); } }; template<class mt_policy> class has_slots; template<class mt_policy> class _connection_base0 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit() = 0; virtual _connection_base0* clone() = 0; virtual _connection_base0* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class mt_policy> class _connection_base1 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type) = 0; virtual _connection_base1<arg1_type, mt_policy>* clone() = 0; virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class mt_policy> class _connection_base2 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type) = 0; virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone() = 0; virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class mt_policy> class _connection_base3 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type) = 0; virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone() = 0; virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy> class _connection_base4 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) = 0; virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone() = 0; virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class mt_policy> class _connection_base5 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type) = 0; virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>* clone() = 0; virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class mt_policy> class _connection_base6 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type) = 0; virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>* clone() = 0; virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class mt_policy> class _connection_base7 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type) = 0; virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>* clone() = 0; virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy> class _connection_base8 { public: virtual has_slots<mt_policy>* getdest() const = 0; virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type) = 0; virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone() = 0; virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0; }; template<class mt_policy> class _signal_base : public mt_policy { public: virtual void slot_disconnect(has_slots<mt_policy>* pslot) = 0; virtual void slot_duplicate(const has_slots<mt_policy>* poldslot, has_slots<mt_policy>* pnewslot) = 0; }; template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class has_slots : public mt_policy { private: typedef typename std::set<_signal_base<mt_policy> *> sender_set; typedef typename sender_set::const_iterator const_iterator; public: has_slots() { ; } has_slots(const has_slots& hs) : mt_policy(hs) { lock_block<mt_policy> lock(this); const_iterator it = hs.m_senders.begin(); const_iterator itEnd = hs.m_senders.end(); while(it != itEnd) { (*it)->slot_duplicate(&hs, this); m_senders.insert(*it); ++it; } } void signal_connect(_signal_base<mt_policy>* sender) { lock_block<mt_policy> lock(this); m_senders.insert(sender); } void signal_disconnect(_signal_base<mt_policy>* sender) { lock_block<mt_policy> lock(this); m_senders.erase(sender); } virtual ~has_slots() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); const_iterator it = m_senders.begin(); const_iterator itEnd = m_senders.end(); while(it != itEnd) { (*it)->slot_disconnect(this); ++it; } m_senders.erase(m_senders.begin(), m_senders.end()); } private: sender_set m_senders; }; template<class mt_policy> class _signal_base0 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base0<mt_policy> *> connections_list; _signal_base0() { ; } _signal_base0(const _signal_base0& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } ~_signal_base0() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class mt_policy> class _signal_base1 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base1<arg1_type, mt_policy> *> connections_list; _signal_base1() { ; } _signal_base1(const _signal_base1<arg1_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base1() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class mt_policy> class _signal_base2 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base2<arg1_type, arg2_type, mt_policy> *> connections_list; _signal_base2() { ; } _signal_base2(const _signal_base2<arg1_type, arg2_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base2() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class mt_policy> class _signal_base3 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base3<arg1_type, arg2_type, arg3_type, mt_policy> *> connections_list; _signal_base3() { ; } _signal_base3(const _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base3() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy> class _signal_base4 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy> *> connections_list; _signal_base4() { ; } _signal_base4(const _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base4() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class mt_policy> class _signal_base5 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy> *> connections_list; _signal_base5() { ; } _signal_base5(const _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base5() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class mt_policy> class _signal_base6 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy> *> connections_list; _signal_base6() { ; } _signal_base6(const _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base6() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class mt_policy> class _signal_base7 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> *> connections_list; _signal_base7() { ; } _signal_base7(const _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base7() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy> class _signal_base8 : public _signal_base<mt_policy> { public: typedef std::list<_connection_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> *> connections_list; _signal_base8() { ; } _signal_base8(const _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>& s) : _signal_base<mt_policy>(s) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = s.m_connected_slots.begin(); typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_connect(this); m_connected_slots.push_back((*it)->clone()); ++it; } } void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == oldtarget) { m_connected_slots.push_back((*it)->duplicate(newtarget)); } ++it; } } ~_signal_base8() { disconnect_all(); } void disconnect_all() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { (*it)->getdest()->signal_disconnect(this); delete *it; ++it; } m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } #ifdef _DEBUG bool connected(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; if ((*it)->getdest() == pclass) return true; it = itNext; } return false; } #endif void disconnect(has_slots<mt_policy>* pclass) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { if((*it)->getdest() == pclass) { delete *it; m_connected_slots.erase(it); pclass->signal_disconnect(this); return; } ++it; } } void slot_disconnect(has_slots<mt_policy>* pslot) { lock_block<mt_policy> lock(this); typename connections_list::iterator it = m_connected_slots.begin(); typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { typename connections_list::iterator itNext = it; ++itNext; if((*it)->getdest() == pslot) { m_connected_slots.erase(it); // delete *it; } it = itNext; } } protected: connections_list m_connected_slots; }; template<class dest_type, class mt_policy> class _connection0 : public _connection_base0<mt_policy> { public: _connection0() { m_pobject = NULL; m_pmemfun = NULL; } _connection0(dest_type* pobject, void (dest_type::*pmemfun)()) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base0<mt_policy>* clone() { return new _connection0<dest_type, mt_policy>(*this); } virtual _connection_base0<mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection0<dest_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit() { (m_pobject->*m_pmemfun)(); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(); }; template<class dest_type, class arg1_type, class mt_policy> class _connection1 : public _connection_base1<arg1_type, mt_policy> { public: _connection1() { m_pobject = NULL; m_pmemfun = NULL; } _connection1(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base1<arg1_type, mt_policy>* clone() { return new _connection1<dest_type, arg1_type, mt_policy>(*this); } virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection1<dest_type, arg1_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1) { (m_pobject->*m_pmemfun)(a1); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type); }; template<class dest_type, class arg1_type, class arg2_type, class mt_policy> class _connection2 : public _connection_base2<arg1_type, arg2_type, mt_policy> { public: _connection2() { m_pobject = NULL; m_pmemfun = NULL; } _connection2(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone() { return new _connection2<dest_type, arg1_type, arg2_type, mt_policy>(*this); } virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection2<dest_type, arg1_type, arg2_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2) { (m_pobject->*m_pmemfun)(a1, a2); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class mt_policy> class _connection3 : public _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy> { public: _connection3() { m_pobject = NULL; m_pmemfun = NULL; } _connection3(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone() { return new _connection3<dest_type, arg1_type, arg2_type, arg3_type, mt_policy>(*this); } virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection3<dest_type, arg1_type, arg2_type, arg3_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3) { (m_pobject->*m_pmemfun)(a1, a2, a3); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy> class _connection4 : public _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy> { public: _connection4() { m_pobject = NULL; m_pmemfun = NULL; } _connection4(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone() { return new _connection4<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(*this); } virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection4<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class mt_policy> class _connection5 : public _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy> { public: _connection5() { m_pobject = NULL; m_pmemfun = NULL; } _connection5(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>* clone() { return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>(*this); } virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class mt_policy> class _connection6 : public _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy> { public: _connection6() { m_pobject = NULL; m_pmemfun = NULL; } _connection6(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>* clone() { return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>(*this); } virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class mt_policy> class _connection7 : public _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> { public: _connection7() { m_pobject = NULL; m_pmemfun = NULL; } _connection7(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>* clone() { return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>(*this); } virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type); }; template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class arg4_type, class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy> class _connection8 : public _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> { public: _connection8() { m_pobject = NULL; m_pmemfun = NULL; } _connection8(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type)) { m_pobject = pobject; m_pmemfun = pmemfun; } virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone() { return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(*this); } virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) { return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); } virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) { (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8); } virtual has_slots<mt_policy>* getdest() const { return m_pobject; } private: dest_type* m_pobject; void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type); }; template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal0 : public _signal_base0<mt_policy> { public: typedef _signal_base0<mt_policy> base; typedef typename base::connections_list connections_list; using base::m_connected_slots; signal0() { ; } signal0(const signal0<mt_policy>& s) : _signal_base0<mt_policy>(s) { ; } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)()) { lock_block<mt_policy> lock(this); _connection0<desttype, mt_policy>* conn = new _connection0<desttype, mt_policy>(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } void emit() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(); it = itNext; } } void operator()() { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(); it = itNext; } } }; template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal1 : public _signal_base1<arg1_type, mt_policy> { public: typedef _signal_base1<arg1_type, mt_policy> base; typedef typename base::connections_list connections_list; using base::m_connected_slots; signal1() { ; } signal1(const signal1<arg1_type, mt_policy>& s) : _signal_base1<arg1_type, mt_policy>(s) { ; } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type)) { lock_block<mt_policy> lock(this); _connection1<desttype, arg1_type, mt_policy>* conn = new _connection1<desttype, arg1_type, mt_policy>(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } void emit(arg1_type a1) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(a1); it = itNext; } } void operator()(arg1_type a1) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(a1); it = itNext; } } }; template<class arg1_type, class arg2_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal2 : public _signal_base2<arg1_type, arg2_type, mt_policy> { public: typedef _signal_base2<arg1_type, arg2_type, mt_policy> base; typedef typename base::connections_list connections_list; using base::m_connected_slots; signal2() { ; } signal2(const signal2<arg1_type, arg2_type, mt_policy>& s) : _signal_base2<arg1_type, arg2_type, mt_policy>(s) { ; } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type)) { lock_block<mt_policy> lock(this); _connection2<desttype, arg1_type, arg2_type, mt_policy>* conn = new _connection2<desttype, arg1_type, arg2_type, mt_policy>(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } void emit(arg1_type a1, arg2_type a2) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(a1, a2); it = itNext; } } void operator()(arg1_type a1, arg2_type a2) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(a1, a2); it = itNext; } } }; template<class arg1_type, class arg2_type, class arg3_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal3 : public _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy> { public: typedef _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy> base; typedef typename base::connections_list connections_list; using base::m_connected_slots; signal3() { ; } signal3(const signal3<arg1_type, arg2_type, arg3_type, mt_policy>& s) : _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>(s) { ; } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type)) { lock_block<mt_policy> lock(this); _connection3<desttype, arg1_type, arg2_type, arg3_type, mt_policy>* conn = new _connection3<desttype, arg1_type, arg2_type, arg3_type, mt_policy>(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } void emit(arg1_type a1, arg2_type a2, arg3_type a3) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(a1, a2, a3); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3) { lock_block<mt_policy> lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { itNext = it; ++itNext; (*it)->emit(a1, a2, a3); it = itNext; } } }; template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> class signal4 : public _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy> { public: typedef _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy> base; typedef typename base::connections_list connections_list; using base::m_connected_slots; signal4() { ; } signal4(const signal4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s) : _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(s) { ; } template<class desttype> void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type)) { lock_block<mt_policy> lock(this); _connection4<desttype, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* conn = new _connection4<desttype, arg1_type, a发表评论
-
Berkeley DB 使用经验总结
2012-08-27 14:41 3087作者:陈磊 NoSQL是现在互联网Web2.0时代备受 ... -
嵌入式数据库系统Berkeley DB
2012-08-27 14:37 1534前言 UNIX/LINUX平台下的数据库种类非常多 ... -
C语言中标准输入流、标准输出流、标准错误输出流
2011-06-13 14:32 9295C语言中标准输入流、标准输出流、标准错误输出流 在 ... -
Rsync 实现原理
2011-05-12 20:06 8323Rsync 实现原理 前言 关于rsync的原始文档 ... -
c++简单的虚函数测试
2011-04-27 14:25 1022#include <iostream> u ... -
C++文件行查找
2011-04-26 14:10 1409#include <iostream> # ... -
c++偏特化简单示例
2011-04-13 11:17 2157c++偏特化 // temp1.c ... -
GDB调试精粹及使用实例
2011-03-16 14:06 1142GDB调试精粹及使用实例 一:列文件清单 1. ... -
简单的ini文件解析
2011-02-12 16:36 1624int GetKeyVal(const string s ... -
scanf族函数高级用法
2011-01-25 16:00 2563如何解释 fscanf(fd,&quo ... -
使用scons替代makefile(1)
2011-01-25 11:58 3735早在多年前我刚开始接触linux下的C程序时,经常被makef ... -
使用scons替代makefile(2)
2011-01-25 11:57 3585本篇文章接着上一篇进一步介绍scons的使用方法,主要介绍静态 ... -
使用scons替代makefile(3)
2011-01-25 11:55 4822在上两篇文章中已经简单介绍了用scons编译库文件,可执行程序 ... -
C 支持动态添加测试数据的测试代码
2011-01-13 17:22 1121/下面的定义为了支持可扩增。 //当需要增加一个新的测试用列 ... -
Linux下Makefile的automake生成
2010-12-28 16:55 1103******************helloworld.c* ... -
SCons笔记(详细版)
2010-12-23 16:11 105461. 基本使用 SConstruct文件就功能而言相当于Ma ... -
scons 学习
2010-12-23 11:14 2185scons 学习 作者:Sam(甄峰) sam_code@h ... -
scons随笔
2010-12-22 20:20 4709scons随笔 Scons是新一代的软件构件工具,或者说ma ... -
Scons在linux下的安装和使用
2010-12-21 11:59 3289因为正在用的一个开源软件需要的Developm ... -
排列组合的实现
2010-12-20 12:41 1066简单算法: 从前往后(或者从后往前)每次交换一个位置。当存在 ...
相关推荐
Sigslot的简单应用,vc6.0实现 sigslot的出现为我们提供了一种解决问题的思想,它用“信号”的概念实现不同模块之间的传输问题,sigslot本身类似于一条通讯电缆,两端提供发送器和接收器,只要把两个模块用这条电缆...
本篇将详细介绍`sigslot`库的使用,包括其基本概念、API使用、示例代码和官方英文文档。 **一、`sigslot`基本概念** 1. **信号(Signal)**:信号是对象发出的一种通知,表示某种事件的发生。当信号被触发时,它会...
Sigslot是C++中一种实现信号(signals)与槽(slots)机制的库,它提供了一种方便的方式来处理对象间的通信。在C++的世界里,信号与槽是一种事件驱动编程模型,广泛应用于GUI编程和多线程环境中。下面将详细阐述这个...
五、示例 ```cpp #include "sigslot.h" class MyClass { public: sigslot::signal1, std::string> mySignal; void emitSignal(int value, std::string message) { mySignal.emit(value, message); } void ...
Sigslot 是一个小型但功能强大的 C++ 开源库,专门用于实现信号(signals)和槽(slots)机制。这个库的特色在于它只有一个头文件 `sigslot.h`,因此非常便于集成到任何项目中,无需额外的编译步骤或依赖。在 C++ 中...
2. 可能的示例代码或者测试用例,帮助用户了解如何使用这个库。 3. 构建脚本或Makefile,用于编译和链接sigslot库。 4. 可能的文档,如README文件,说明如何安装和使用这个库。 在使用这个库时,开发者需要了解以下...
sigslot的头文件,sigslot.h 包含了sigslot的实现
sigslot的出现为我们提供了一种解决问题的思想,它用“信号”的概念实现不同模块之间的传输问题,sigslot本身类似于一条通讯电缆,两端提供发送器和接收器,只要把两个模块用这条电缆连接起来就可以实现接口调用,而...
sigslot是一个用标准C++语法实现的信号与槽机制的函数库,简单到只有一个头文件 sigslot.h
原头文件在gcc编译中会出现问题,这是修改过去掉模板的资源,linux下随意使用。 sig---信号 slot---插槽 信号.connect(&插槽对象,&插槽类::插槽类成员函数)
很好用,可以用在多线程里面,跨平台,类型安全,线程安全 只有一个头文件。 google的libjingle里面用到了
### sigslot库详解 #### 一、引言与概述 sigslot是一个强大的C++库,它为开发人员提供了一个线程安全且类型安全的信号(signal)与槽(slot)机制实现。这种机制允许对象之间在不知道对方具体细节的情况下进行通信...
4. **示例应用** - 假设我们有一个`Window`类,当窗口大小改变时会触发`size_changed`信号,而一个`StatusBar`类有更新状态栏的`updateStatusBar`槽函数。我们可以连接这两个,当窗口大小改变时自动更新状态栏。 5...
- `实例`:实际的C++代码示例,展示了如何声明和使用信号和插槽,以及如何进行连接和断开操作。 通过这个实例,你可以学习如何在自己的项目中使用`sigslot`库来实现组件间的异步通信,提高代码的模块化和可维护性。...
Simple signal slot implementation. As simple as a single header file.
回调函数(callback)和信号槽(sigslot)是软件设计模式中的两种常见机制,它们用于在对象之间建立通信,实现事件驱动或者异步处理。在C++编程中,回调和信号槽尤其受到重视,因为它们可以增强代码的灵活性和可扩展...
一个非常精简的signal & slot 实现库,整个库只有一个<< sigslot.h >>文件。
这里,我们讨论的是一个纯C++实现的SignalSlot机制,参考自`sigslot.h`库。 **描述:** 这个SignalSlot实现支持最多10个参数的传递,这意味着你可以将多个数据值随信号一起发送,并在槽函数中进行处理。此外,该...
【Qt信号与槽机制详解】 Qt库是C++中用于构建图形用户界面(GUI)的开源框架,由Trolltech公司开发,现由The Qt Company维护。Qt的一大特色就是其强大的信号与槽(Signal & Slot)机制,它提供了一种在对象间通信的...
这种机制常被用于GUI编程,例如Qt库中,但也有独立实现,如本示例中的"Signal.rar"。这个压缩包包含了一个使用 sigslot 库实现的信号槽机制的例子,适用于Linux环境。 `sigslot.h` 是一个头文件,它定义了信号和槽...