From 6ec490fef6d30271980fa9f1aa6de45a6cdc7780 Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Wed, 15 Feb 2012 17:20:00 +0200 Subject: Remove _signal_baseN classes and move functionality to signalN classes --- sigslot.h | 2092 ++++++++++++++++++++++++++++--------------------------------- 1 file changed, 944 insertions(+), 1148 deletions(-) diff --git a/sigslot.h b/sigslot.h index 5d9db9d..8d6423d 100644 --- a/sigslot.h +++ b/sigslot.h @@ -485,465 +485,485 @@ namespace sigslot { sender_set m_senders; }; - template - class _signal_base0 : public _signal_base + + + template + class _connection0 : public _connection_base0 { public: - typedef std::list<_connection_base0 *> connections_list; - - _signal_base0() + _connection0() { - ; + m_pobject = NULL; + m_pmemfun = NULL; } - _signal_base0(const _signal_base0& s) - : _signal_base(s) + _connection0(dest_type* pobject, void (dest_type::*pmemfun)()) { - lock_block lock(this); - typename connections_list::const_iterator it = s.m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); + m_pobject = pobject; + m_pmemfun = pmemfun; + } - while(it != itEnd) - { - (*it)->getdest()->signal_connect(this); - m_connected_slots.push_back((*it)->clone()); + virtual ~_connection0() + { + } - ++it; - } + virtual _connection_base0* clone() + { + return new _connection0(*this); } - ~_signal_base0() + virtual _connection_base0* duplicate(has_slots* pnewdest) { - disconnect_all(); + return new _connection0((dest_type *)pnewdest, m_pmemfun); } - bool is_empty() + virtual void SIGSLOT_EMIT() { - lock_block lock(this); - typename connections_list::const_iterator it = m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = m_connected_slots.end(); - return it == itEnd; + (m_pobject->*m_pmemfun)(); } - void disconnect_all() + virtual has_slots* getdest() const { - lock_block 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; + return m_pobject; + } - ++it; - } + private: + dest_type* m_pobject; + void (dest_type::* m_pmemfun)(); + }; - m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + template + class _connection1 : public _connection_base1 + { + public: + _connection1() + { + m_pobject = NULL; + m_pmemfun = NULL; } -#ifdef _DEBUG - bool connected(has_slots* pclass) + _connection1(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type)) { - lock_block 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; + m_pobject = pobject; + m_pmemfun = pmemfun; } -#endif - void disconnect(has_slots* pclass) + virtual ~_connection1() { - lock_block 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; - } + virtual _connection_base1* clone() + { + return new _connection1(*this); } - void slot_disconnect(has_slots* pslot) + virtual _connection_base1* duplicate(has_slots* pnewdest) { - lock_block 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) - { - delete *it; - m_connected_slots.erase(it); - } - - it = itNext; - } + return new _connection1((dest_type *)pnewdest, m_pmemfun); } - void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + virtual void SIGSLOT_EMIT(arg1_type a1) { - lock_block 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)); - } + (m_pobject->*m_pmemfun)(a1); + } - ++it; - } + virtual has_slots* getdest() const + { + return m_pobject; } - protected: - connections_list m_connected_slots; + private: + dest_type* m_pobject; + void (dest_type::* m_pmemfun)(arg1_type); }; - template - class _signal_base1 : public _signal_base + template + class _connection2 : public _connection_base2 { public: - typedef std::list<_connection_base1 *> connections_list; - - _signal_base1() + _connection2() { - ; + m_pobject = NULL; + m_pmemfun = NULL; } - _signal_base1(const _signal_base1& s) - : _signal_base(s) + _connection2(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, + arg2_type)) { - lock_block 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; - } + m_pobject = pobject; + m_pmemfun = pmemfun; } - void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + virtual ~_connection2() { - lock_block 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; - } + virtual _connection_base2* clone() + { + return new _connection2(*this); } - ~_signal_base1() + virtual _connection_base2* duplicate(has_slots* pnewdest) { - disconnect_all(); + return new _connection2((dest_type *)pnewdest, m_pmemfun); } - bool is_empty() + virtual void SIGSLOT_EMIT(arg1_type a1, arg2_type a2) { - lock_block lock(this); - typename connections_list::const_iterator it = m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = m_connected_slots.end(); - return it == itEnd; + (m_pobject->*m_pmemfun)(a1, a2); } - void disconnect_all() + virtual has_slots* getdest() const { - lock_block 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; + return m_pobject; + } - ++it; - } + private: + dest_type* m_pobject; + void (dest_type::* m_pmemfun)(arg1_type, arg2_type); + }; - m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + template + class _connection3 : public _connection_base3 + { + public: + _connection3() + { + m_pobject = NULL; + m_pmemfun = NULL; } -#ifdef _DEBUG - bool connected(has_slots* pclass) + _connection3(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, + arg2_type, arg3_type)) { - lock_block 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; + m_pobject = pobject; + m_pmemfun = pmemfun; } -#endif - void disconnect(has_slots* pclass) + virtual ~_connection3() { - lock_block 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; - } + virtual _connection_base3* clone() + { + return new _connection3(*this); } - void slot_disconnect(has_slots* pslot) + virtual _connection_base3* duplicate(has_slots* pnewdest) { - lock_block 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) - { - delete *it; - m_connected_slots.erase(it); - } + return new _connection3((dest_type *)pnewdest, m_pmemfun); + } - it = itNext; - } + virtual void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3) + { + (m_pobject->*m_pmemfun)(a1, a2, a3); } + virtual has_slots* getdest() const + { + return m_pobject; + } - protected: - connections_list m_connected_slots; + private: + dest_type* m_pobject; + void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); }; - template - class _signal_base2 : public _signal_base + template + class _connection4 : public _connection_base4 { public: - typedef std::list<_connection_base2 *> - connections_list; - - _signal_base2() + _connection4() { - ; + m_pobject = NULL; + m_pmemfun = NULL; } - _signal_base2(const _signal_base2& s) - : _signal_base(s) + _connection4(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, + arg2_type, arg3_type, arg4_type)) { - lock_block 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; - } + m_pobject = pobject; + m_pmemfun = pmemfun; } - void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + virtual ~_connection4() { - lock_block 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; - } + virtual _connection_base4* clone() + { + return new _connection4(*this); } - ~_signal_base2() + virtual _connection_base4* duplicate(has_slots* pnewdest) { - disconnect_all(); + return new _connection4((dest_type *)pnewdest, m_pmemfun); } - bool is_empty() + virtual void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, + arg4_type a4) { - lock_block lock(this); - typename connections_list::const_iterator it = m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = m_connected_slots.end(); - return it == itEnd; + (m_pobject->*m_pmemfun)(a1, a2, a3, a4); } - void disconnect_all() + virtual has_slots* getdest() const { - lock_block 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; + return m_pobject; + } - ++it; - } + private: + dest_type* m_pobject; + void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, + arg4_type); + }; - m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + template + class _connection5 : public _connection_base5 + { + public: + _connection5() + { + m_pobject = NULL; + m_pmemfun = NULL; } -#ifdef _DEBUG - bool connected(has_slots* pclass) + _connection5(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, + arg2_type, arg3_type, arg4_type, arg5_type)) { - lock_block 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; + m_pobject = pobject; + m_pmemfun = pmemfun; } -#endif - void disconnect(has_slots* pclass) + virtual ~_connection5() { - lock_block 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; - } + virtual _connection_base5* clone() + { + return new _connection5(*this); } - void slot_disconnect(has_slots* pslot) + virtual _connection_base5* duplicate(has_slots* pnewdest) { - lock_block 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; + return new _connection5((dest_type *)pnewdest, m_pmemfun); + } - if((*it)->getdest() == pslot) - { - delete *it; - m_connected_slots.erase(it); - } + virtual void SIGSLOT_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); + } - it = itNext; - } + virtual has_slots* getdest() const + { + return m_pobject; } - protected: - connections_list m_connected_slots; + private: + dest_type* m_pobject; + void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type, + arg5_type); }; - template - class _signal_base3 : public _signal_base + template + class _connection6 : public _connection_base6 { public: - typedef std::list<_connection_base3 *> - connections_list; - - _signal_base3() + _connection6() { - ; + m_pobject = NULL; + m_pmemfun = NULL; } - _signal_base3(const _signal_base3& s) - : _signal_base(s) + _connection6(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type, + arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) { - lock_block lock(this); - typename connections_list::const_iterator it = s.m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); + m_pobject = pobject; + m_pmemfun = pmemfun; + } - while(it != itEnd) - { - (*it)->getdest()->signal_connect(this); - m_connected_slots.push_back((*it)->clone()); + virtual ~_connection6() + { + } - ++it; - } + virtual _connection_base6* clone() + { + return new _connection6(*this); } - void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + virtual _connection_base6* duplicate(has_slots* pnewdest) { - lock_block lock(this); - typename connections_list::iterator it = m_connected_slots.begin(); - typename connections_list::iterator itEnd = m_connected_slots.end(); + return new _connection6((dest_type *)pnewdest, m_pmemfun); + } - while(it != itEnd) - { - if((*it)->getdest() == oldtarget) - { - m_connected_slots.push_back((*it)->duplicate(newtarget)); - } + virtual void SIGSLOT_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* 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 _connection7 : public _connection_base7 + { + 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 ~_connection7() + { + } + + virtual _connection_base7* clone() + { + return new _connection7(*this); + } + + virtual _connection_base7* duplicate(has_slots* pnewdest) + { + return new _connection7((dest_type *)pnewdest, m_pmemfun); + } + + virtual void SIGSLOT_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* 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 _connection8 : public _connection_base8 + { + 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 ~_connection8() + { + } + + virtual _connection_base8* clone() + { + return new _connection8(*this); + } + + virtual _connection_base8* duplicate(has_slots* pnewdest) + { + return new _connection8((dest_type *)pnewdest, m_pmemfun); + } + + virtual void SIGSLOT_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* 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 signal0 : public _signal_base + { + public: + + typedef std::list<_connection_base0 *> connections_list; + + signal0() + {} + + signal0(const signal0& s) + : _signal_base(s) + { + lock_block 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_base3() + ~signal0() { disconnect_all(); } @@ -1032,23 +1052,71 @@ namespace sigslot { } } + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + { + lock_block 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; + } + } + + template + void connect(desttype* pclass, void (desttype::*pmemfun)()) + { + lock_block lock(this); + _connection0* conn = + new _connection0(pclass, pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); + } + + void SIGSLOT_EMIT() + { + lock_block 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)->SIGSLOT_EMIT(); + + it = itNext; + } + } + + void operator()() + { + SIGSLOT_EMIT(); + } + protected: + connections_list m_connected_slots; }; - template - class _signal_base4 : public _signal_base + template + class signal1 : public _signal_base { public: - typedef std::list<_connection_base4 *> connections_list; - _signal_base4() - { - ; - } + typedef std::list<_connection_base1 *> connections_list; + + signal1() + {} - _signal_base4(const _signal_base4& s) + signal1(const signal1& s) : _signal_base(s) { lock_block lock(this); @@ -1062,7 +1130,12 @@ namespace sigslot { ++it; } - } + } + + ~signal1() + { + disconnect_all(); + } void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { @@ -1081,11 +1154,6 @@ namespace sigslot { } } - ~_signal_base4() - { - disconnect_all(); - } - bool is_empty() { lock_block lock(this); @@ -1170,62 +1238,94 @@ namespace sigslot { } } - protected: - connections_list m_connected_slots; - }; - - template - class _signal_base5 : public _signal_base - { - public: - typedef std::list<_connection_base5 *> connections_list; - - _signal_base5() + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type)) { - ; + lock_block lock(this); + _connection1* conn = + new _connection1(pclass, pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); } - _signal_base5(const _signal_base5& s) - : _signal_base(s) + void SIGSLOT_EMIT(arg1_type a1) { lock_block lock(this); - typename connections_list::const_iterator it = s.m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = s.m_connected_slots.end(); + typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); + typename connections_list::const_iterator itEnd = m_connected_slots.end(); while(it != itEnd) { - (*it)->getdest()->signal_connect(this); - m_connected_slots.push_back((*it)->clone()); + itNext = it; + ++itNext; - ++it; + (*it)->SIGSLOT_EMIT(a1); + + it = itNext; } } - void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + void operator()(arg1_type a1) { - lock_block lock(this); - typename connections_list::iterator it = m_connected_slots.begin(); - typename connections_list::iterator itEnd = m_connected_slots.end(); + SIGSLOT_EMIT(a1); + } + + protected: + + connections_list m_connected_slots; + }; + + template + class signal2 : public _signal_base + { + public: + + typedef std::list<_connection_base2 *> + connections_list; + + signal2() + { + ; + } + + signal2(const signal2& s) + : _signal_base(s) + { + lock_block 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) { - if((*it)->getdest() == oldtarget) - { - m_connected_slots.push_back((*it)->duplicate(newtarget)); - } + (*it)->getdest()->signal_connect(this); + m_connected_slots.push_back((*it)->clone()); ++it; } } - ~_signal_base5() + ~signal2() { disconnect_all(); } + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + { + lock_block 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; + } + } + bool is_empty() { lock_block lock(this); @@ -1310,25 +1410,54 @@ namespace sigslot { } } + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type)) + { + lock_block lock(this); + _connection2* conn = new + _connection2(pclass, pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); + } + + void SIGSLOT_EMIT(arg1_type a1, arg2_type a2) + { + lock_block 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)->SIGSLOT_EMIT(a1, a2); + + it = itNext; + } + } + + void operator()(arg1_type a1, arg2_type a2) + { + SIGSLOT_EMIT(a1, a2); + } + protected: connections_list m_connected_slots; }; - template - class _signal_base6 : public _signal_base + template + class signal3 : public _signal_base { public: - typedef std::list<_connection_base6 *> connections_list; + typedef std::list<_connection_base3 *> + connections_list; - _signal_base6() - { - ; - } + signal3() + {} - _signal_base6(const _signal_base6& s) + signal3(const signal3& s) : _signal_base(s) { lock_block lock(this); @@ -1344,6 +1473,11 @@ namespace sigslot { } } + ~signal3() + { + disconnect_all(); + } + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { lock_block lock(this); @@ -1361,11 +1495,6 @@ namespace sigslot { } } - ~_signal_base6() - { - disconnect_all(); - } - bool is_empty() { lock_block lock(this); @@ -1450,25 +1579,56 @@ namespace sigslot { } } + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type, arg3_type)) + { + lock_block lock(this); + _connection3* conn = + new _connection3(pclass, + pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); + } + + void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3) + { + lock_block 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)->SIGSLOT_EMIT(a1, a2, a3); + + it = itNext; + } + } + + void operator()(arg1_type a1, arg2_type a2, arg3_type a3) + { + SIGSLOT_EMIT(a1, a2, a3); + } + protected: + connections_list m_connected_slots; }; - template - class _signal_base7 : public _signal_base + template + class signal4 : public _signal_base { public: - typedef std::list<_connection_base7 *> connections_list; + typedef std::list<_connection_base4 *> connections_list; - _signal_base7() - { - ; - } + signal4() + {} - _signal_base7(const _signal_base7& s) + signal4(const signal4& s) : _signal_base(s) { lock_block lock(this); @@ -1484,6 +1644,11 @@ namespace sigslot { } } + ~signal4() + { + disconnect_all(); + } + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { lock_block lock(this); @@ -1501,11 +1666,6 @@ namespace sigslot { } } - ~_signal_base7() - { - disconnect_all(); - } - bool is_empty() { lock_block lock(this); @@ -1590,26 +1750,58 @@ namespace sigslot { } } + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type, arg3_type, arg4_type)) + { + lock_block lock(this); + _connection4* + conn = new _connection4(pclass, pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); + } + + void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) + { + lock_block 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)->SIGSLOT_EMIT(a1, a2, a3, a4); + + it = itNext; + } + } + + void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) + { + SIGSLOT_EMIT(a1, a2, a3, a4); + } + protected: + connections_list m_connected_slots; }; template - class _signal_base8 : public _signal_base + class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> + class signal5 : public _signal_base { public: - typedef std::list<_connection_base8 *> - connections_list; + typedef std::list<_connection_base5 *> connections_list; - _signal_base8() - { - ; - } + signal5() + {} - _signal_base8(const _signal_base8& s) + signal5(const signal5& s) : _signal_base(s) { lock_block lock(this); @@ -1625,6 +1817,11 @@ namespace sigslot { } } + ~signal5() + { + disconnect_all(); + } + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { lock_block lock(this); @@ -1642,11 +1839,6 @@ namespace sigslot { } } - ~_signal_base8() - { - disconnect_all(); - } - bool is_empty() { lock_block lock(this); @@ -1725,497 +1917,26 @@ namespace sigslot { { delete *it; m_connected_slots.erase(it); - } - - it = itNext; - } - } - - protected: - connections_list m_connected_slots; - }; - - - template - class _connection0 : public _connection_base0 - { - public: - _connection0() - { - m_pobject = NULL; - m_pmemfun = NULL; - } - - _connection0(dest_type* pobject, void (dest_type::*pmemfun)()) - { - m_pobject = pobject; - m_pmemfun = pmemfun; - } - - virtual ~_connection0() - { - } - - virtual _connection_base0* clone() - { - return new _connection0(*this); - } - - virtual _connection_base0* duplicate(has_slots* pnewdest) - { - return new _connection0((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_EMIT() - { - (m_pobject->*m_pmemfun)(); - } - - virtual has_slots* getdest() const - { - return m_pobject; - } - - private: - dest_type* m_pobject; - void (dest_type::* m_pmemfun)(); - }; - - template - class _connection1 : public _connection_base1 - { - 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 ~_connection1() - { - } - - virtual _connection_base1* clone() - { - return new _connection1(*this); - } - - virtual _connection_base1* duplicate(has_slots* pnewdest) - { - return new _connection1((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_EMIT(arg1_type a1) - { - (m_pobject->*m_pmemfun)(a1); - } - - virtual has_slots* getdest() const - { - return m_pobject; - } - - private: - dest_type* m_pobject; - void (dest_type::* m_pmemfun)(arg1_type); - }; - - template - class _connection2 : public _connection_base2 - { - 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 ~_connection2() - { - } - - virtual _connection_base2* clone() - { - return new _connection2(*this); - } - - virtual _connection_base2* duplicate(has_slots* pnewdest) - { - return new _connection2((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_EMIT(arg1_type a1, arg2_type a2) - { - (m_pobject->*m_pmemfun)(a1, a2); - } - - virtual has_slots* getdest() const - { - return m_pobject; - } - - private: - dest_type* m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type); - }; - - template - class _connection3 : public _connection_base3 - { - 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 ~_connection3() - { - } - - virtual _connection_base3* clone() - { - return new _connection3(*this); - } - - virtual _connection_base3* duplicate(has_slots* pnewdest) - { - return new _connection3((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3) - { - (m_pobject->*m_pmemfun)(a1, a2, a3); - } - - virtual has_slots* getdest() const - { - return m_pobject; - } - - private: - dest_type* m_pobject; - void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); - }; - - template - class _connection4 : public _connection_base4 - { - 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 ~_connection4() - { - } - - virtual _connection_base4* clone() - { - return new _connection4(*this); - } - - virtual _connection_base4* duplicate(has_slots* pnewdest) - { - return new _connection4((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, - arg4_type a4) - { - (m_pobject->*m_pmemfun)(a1, a2, a3, a4); - } - - virtual has_slots* 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 _connection5 : public _connection_base5 - { - 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 ~_connection5() - { - } - - virtual _connection_base5* clone() - { - return new _connection5(*this); - } - - virtual _connection_base5* duplicate(has_slots* pnewdest) - { - return new _connection5((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_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* 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 _connection6 : public _connection_base6 - { - 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 ~_connection6() - { - } - - virtual _connection_base6* clone() - { - return new _connection6(*this); - } - - virtual _connection_base6* duplicate(has_slots* pnewdest) - { - return new _connection6((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_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* 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 _connection7 : public _connection_base7 - { - 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 ~_connection7() - { - } - - virtual _connection_base7* clone() - { - return new _connection7(*this); - } - - virtual _connection_base7* duplicate(has_slots* pnewdest) - { - return new _connection7((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_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* 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 _connection8 : public _connection_base8 - { - 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 ~_connection8() - { - } - - virtual _connection_base8* clone() - { - return new _connection8(*this); - } - - virtual _connection_base8* duplicate(has_slots* pnewdest) - { - return new _connection8((dest_type *)pnewdest, m_pmemfun); - } - - virtual void SIGSLOT_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* 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 signal0 : public _signal_base0 - { - public: - typedef _signal_base0 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; - - signal0() - { - ; - } - - signal0(const signal0& s) - : _signal_base0(s) - { - ; + } + + it = itNext; + } } template - void connect(desttype* pclass, void (desttype::*pmemfun)()) + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type, arg3_type, arg4_type, arg5_type)) { lock_block lock(this); - _connection0* conn = - new _connection0(pclass, pmemfun); + _connection5* conn = new _connection5(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } - void SIGSLOT_EMIT() + void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, + arg5_type a5) { lock_block lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); @@ -2226,101 +1947,173 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(); + (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5); it = itNext; } } - void operator()() + void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, + arg5_type a5) { - SIGSLOT_EMIT(); + SIGSLOT_EMIT(a1, a2, a3, a4, a5); } + + protected: + + connections_list m_connected_slots; }; - template - class signal1 : public _signal_base1 + + template + class signal6 : public _signal_base { public: - typedef _signal_base1 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; + typedef std::list<_connection_base6 *> connections_list; - signal1() + signal6() + {} + + signal6(const signal6& s) + : _signal_base(s) { - ; + lock_block 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; + } } - signal1(const signal1& s) - : _signal_base1(s) + ~signal6() { - ; + disconnect_all(); } - template - void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type)) + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { lock_block lock(this); - _connection1* conn = - new _connection1(pclass, pmemfun); - m_connected_slots.push_back(conn); - pclass->signal_connect(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; + } } - void SIGSLOT_EMIT(arg1_type a1) + bool is_empty() { lock_block lock(this); - typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); + typename connections_list::const_iterator it = m_connected_slots.begin(); + typename connections_list::const_iterator itEnd = m_connected_slots.end(); + return it == itEnd; + } + + void disconnect_all() + { + lock_block 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) { - itNext = it; - ++itNext; + (*it)->getdest()->signal_disconnect(this); + delete *it; - (*it)->SIGSLOT_EMIT(a1); + ++it; + } + + m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + } +#ifdef _DEBUG + bool connected(has_slots* pclass) + { + lock_block 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 operator()(arg1_type a1) + void disconnect(has_slots* pclass) { - SIGSLOT_EMIT(a1); - } - }; + lock_block lock(this); + typename connections_list::iterator it = m_connected_slots.begin(); + typename connections_list::iterator itEnd = m_connected_slots.end(); - template - class signal2 : public _signal_base2 - { - public: - typedef _signal_base2 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; + while(it != itEnd) + { + if((*it)->getdest() == pclass) + { + delete *it; + m_connected_slots.erase(it); + pclass->signal_disconnect(this); + return; + } - signal2() - { - ; + ++it; + } } - signal2(const signal2& s) - : _signal_base2(s) + void slot_disconnect(has_slots* pslot) { - ; + lock_block 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) + { + delete *it; + m_connected_slots.erase(it); + } + + it = itNext; + } } template void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type)) + arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) { lock_block lock(this); - _connection2* conn = new - _connection2(pclass, pmemfun); + _connection6* conn = + new _connection6(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } - void SIGSLOT_EMIT(arg1_type a1, arg2_type a2) + void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, + arg5_type a5, arg6_type a6) { lock_block lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); @@ -2331,164 +2124,173 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(a1, a2); + (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); it = itNext; } } - void operator()(arg1_type a1, arg2_type a2) + void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, + arg5_type a5, arg6_type a6) { - SIGSLOT_EMIT(a1, a2); + SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); } + + protected: + + connections_list m_connected_slots; }; - template - class signal3 : public _signal_base3 + template + class signal7 : public _signal_base { public: - typedef _signal_base3 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; + typedef std::list<_connection_base7 *> connections_list; - signal3() - { - ; - } + signal7() + {} - signal3(const signal3& s) - : _signal_base3(s) + signal7(const signal7& s) + : _signal_base(s) { - ; + lock_block 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; + } } - template - void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type)) + ~signal7() { - lock_block lock(this); - _connection3* conn = - new _connection3(pclass, - pmemfun); - m_connected_slots.push_back(conn); - pclass->signal_connect(this); + disconnect_all(); } - void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3) + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { lock_block lock(this); - typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = m_connected_slots.end(); + typename connections_list::iterator it = m_connected_slots.begin(); + typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { - itNext = it; - ++itNext; - - (*it)->SIGSLOT_EMIT(a1, a2, a3); + if((*it)->getdest() == oldtarget) + { + m_connected_slots.push_back((*it)->duplicate(newtarget)); + } - it = itNext; + ++it; } } - void operator()(arg1_type a1, arg2_type a2, arg3_type a3) + bool is_empty() { - SIGSLOT_EMIT(a1, a2, a3); + lock_block lock(this); + typename connections_list::const_iterator it = m_connected_slots.begin(); + typename connections_list::const_iterator itEnd = m_connected_slots.end(); + return it == itEnd; } - }; - - template - class signal4 : public _signal_base4 - { - public: - typedef _signal_base4 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; - signal4() + void disconnect_all() { - ; - } + lock_block lock(this); + typename connections_list::const_iterator it = m_connected_slots.begin(); + typename connections_list::const_iterator itEnd = m_connected_slots.end(); - signal4(const signal4& s) - : _signal_base4(s) - { - ; - } + while(it != itEnd) + { + (*it)->getdest()->signal_disconnect(this); + delete *it; + + ++it; + } - template - void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type, arg4_type)) - { - lock_block lock(this); - _connection4* - conn = new _connection4(pclass, pmemfun); - m_connected_slots.push_back(conn); - pclass->signal_connect(this); + m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); } - void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) +#ifdef _DEBUG + bool connected(has_slots* pclass) { lock_block 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)->SIGSLOT_EMIT(a1, a2, a3, a4); - + if ((*it)->getdest() == pclass) + return true; it = itNext; } + return false; } +#endif - void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) + void disconnect(has_slots* pclass) { - SIGSLOT_EMIT(a1, a2, a3, a4); - } - }; + lock_block lock(this); + typename connections_list::iterator it = m_connected_slots.begin(); + typename connections_list::iterator itEnd = m_connected_slots.end(); - template - class signal5 : public _signal_base5 - { - public: - typedef _signal_base5 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; + while(it != itEnd) + { + if((*it)->getdest() == pclass) + { + delete *it; + m_connected_slots.erase(it); + pclass->signal_disconnect(this); + return; + } - signal5() - { - ; + ++it; + } } - signal5(const signal5& s) - : _signal_base5(s) + void slot_disconnect(has_slots* pslot) { - ; + lock_block 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) + { + delete *it; + m_connected_slots.erase(it); + } + + it = itNext; + } } template void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type, arg4_type, arg5_type)) + arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, + arg7_type)) { lock_block lock(this); - _connection5* conn = new _connection5(pclass, pmemfun); + _connection7* conn = + new _connection7(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5) + arg5_type a5, arg6_type a6, arg7_type a7) { lock_block lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); @@ -2499,166 +2301,157 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5); + (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5) + arg5_type a5, arg6_type a6, arg7_type a7) { - SIGSLOT_EMIT(a1, a2, a3, a4, a5); + SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7); } - }; + protected: + + connections_list m_connected_slots; + }; template - class signal6 : public _signal_base6 + class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> + class signal8 : public _signal_base { public: - typedef _signal_base6 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; - signal6() - { - ; - } + typedef std::list<_connection_base8 *> + connections_list; - signal6(const signal6& s) - : _signal_base6(s) - { - ; - } + signal8() + {} - template - void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) + signal8(const signal8& s) + : _signal_base(s) { lock_block lock(this); - _connection6* conn = - new _connection6(pclass, pmemfun); - m_connected_slots.push_back(conn); - pclass->signal_connect(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 SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5, arg6_type a6) + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) { lock_block lock(this); - typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); - typename connections_list::const_iterator itEnd = m_connected_slots.end(); + typename connections_list::iterator it = m_connected_slots.begin(); + typename connections_list::iterator itEnd = m_connected_slots.end(); while(it != itEnd) { - itNext = it; - ++itNext; - - (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); + if((*it)->getdest() == oldtarget) + { + m_connected_slots.push_back((*it)->duplicate(newtarget)); + } - it = itNext; + ++it; } } - void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5, arg6_type a6) - { - SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); - } - }; - - template - class signal7 : public _signal_base7 - { - public: - typedef _signal_base7 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; - - signal7() + ~signal8() { - ; + disconnect_all(); } - signal7(const signal7& s) - : _signal_base7(s) + bool is_empty() { - ; + lock_block lock(this); + typename connections_list::const_iterator it = m_connected_slots.begin(); + typename connections_list::const_iterator itEnd = m_connected_slots.end(); + return it == itEnd; } - template - void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, - arg7_type)) + void disconnect_all() { lock_block lock(this); - _connection7* conn = - new _connection7(pclass, pmemfun); - m_connected_slots.push_back(conn); - pclass->signal_connect(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()); } - void SIGSLOT_EMIT(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5, arg6_type a6, arg7_type a7) +#ifdef _DEBUG + bool connected(has_slots* pclass) { lock_block 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)->SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7); - + if ((*it)->getdest() == pclass) + return true; it = itNext; } + return false; } +#endif - void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5, arg6_type a6, arg7_type a7) + void disconnect(has_slots* pclass) { - SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7); - } - }; + lock_block lock(this); + typename connections_list::iterator it = m_connected_slots.begin(); + typename connections_list::iterator itEnd = m_connected_slots.end(); - template - class signal8 : public _signal_base8 - { - public: - typedef _signal_base8 base; - typedef typename base::connections_list connections_list; - using base::m_connected_slots; + while(it != itEnd) + { + if((*it)->getdest() == pclass) + { + delete *it; + m_connected_slots.erase(it); + pclass->signal_disconnect(this); + return; + } - signal8() - { - ; + ++it; + } } - signal8(const signal8& s) - : _signal_base8(s) + void slot_disconnect(has_slots* pslot) { - ; + lock_block 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) + { + delete *it; + m_connected_slots.erase(it); + } + + it = itNext; + } } template @@ -2699,6 +2492,9 @@ namespace sigslot { { SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7, a8); } + + protected: + connections_list m_connected_slots; }; namespace impl -- cgit v1.2.3