From ca05d27cecc3837ff41964548337e26fa687c92f Mon Sep 17 00:00:00 2001 From: Oskari Timperi Date: Wed, 15 Feb 2012 18:34:22 +0200 Subject: Add _signal_base_middle that implements the common methods for signalN classes --- sigslot.h | 1605 ++++++++++++++----------------------------------------------- 1 file changed, 365 insertions(+), 1240 deletions(-) diff --git a/sigslot.h b/sigslot.h index 8d6423d..019d754 100644 --- a/sigslot.h +++ b/sigslot.h @@ -421,6 +421,152 @@ namespace sigslot { virtual void slot_duplicate(const has_slots* poldslot, has_slots* pnewslot) = 0; }; + // Implements common functionality of signalN classes. signalN classes + // derive from this class. + template + class _signal_base_middle: public _signal_base + { + public: + + typedef ConnList connections_list; + typedef typename ConnList::iterator iterator; + typedef typename ConnList::const_iterator const_iterator; + + _signal_base_middle() {} + + _signal_base_middle(const _signal_base_middle &s) + : _signal_base(s) + { + lock_block lock(this); + + const_iterator it = s.m_connected_slots.begin(); + const_iterator itEnd = s.m_connected_slots.end(); + + while(it != itEnd) + { + (*it)->getdest()->signal_connect(this); + m_connected_slots.push_back((*it)->clone()); + ++it; + } + } + + virtual ~_signal_base_middle() {} + + void disconnect_all() + { + lock_block lock(this); + + const_iterator it = m_connected_slots.begin(); + 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()); + } + + bool is_empty() + { + lock_block lock(this); + + const_iterator it = m_connected_slots.begin(); + const_iterator itEnd = m_connected_slots.end(); + + return it == itEnd; + } + +#ifdef _DEBUG + bool connected(has_slots* pclass) + { + lock_block lock(this); + + const_iterator itNext, it = m_connected_slots.begin(); + 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* pclass) + { + lock_block lock(this); + + iterator it = m_connected_slots.begin(); + 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* pslot) + { + lock_block lock(this); + + iterator it = m_connected_slots.begin(); + iterator itEnd = m_connected_slots.end(); + + while(it != itEnd) + { + iterator itNext = it; + ++itNext; + + if((*it)->getdest() == pslot) + { + delete *it; + m_connected_slots.erase(it); + } + + it = itNext; + } + } + + void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + { + lock_block lock(this); + + iterator it = m_connected_slots.begin(); + 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 has_slots : public mt_policy { @@ -938,148 +1084,98 @@ namespace sigslot { }; template - class signal0 : public _signal_base + class signal0 : public _signal_base_middle*>, mt_policy> { public: - typedef std::list<_connection_base0 *> connections_list; + typedef signal0 this_type; + typedef std::list<_connection_base0*> connections_list; + typedef _signal_base_middle base_type; + + using base_type::m_connected_slots; 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; - } - } + signal0(const this_type& s) + : base_type(s) + {} ~signal0() { - disconnect_all(); - } - - 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; + base_type::disconnect_all(); } - void disconnect_all() + template + void connect(desttype* pclass, void (desttype::*pmemfun)()) { 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; - ++it; - } + _connection0* conn = + new _connection0(pclass, pmemfun); - m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); } -#ifdef _DEBUG - bool connected(has_slots* pclass) + 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; - if ((*it)->getdest() == pclass) - return true; - it = itNext; - } - return false; - } -#endif - - void disconnect(has_slots* pclass) - { - 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)->SIGSLOT_EMIT(); - ++it; + it = itNext; } } - void slot_disconnect(has_slots* pslot) + void operator()() { - lock_block lock(this); - typename connections_list::iterator it = m_connected_slots.begin(); - typename connections_list::iterator itEnd = m_connected_slots.end(); + SIGSLOT_EMIT(); + } + }; - while(it != itEnd) - { - typename connections_list::iterator itNext = it; - ++itNext; + template + class signal1 : public _signal_base_middle*>, mt_policy> + { + public: - if((*it)->getdest() == pslot) - { - delete *it; - m_connected_slots.erase(it); - } + typedef signal1 this_type; + typedef std::list<_connection_base1*> connections_list; + typedef _signal_base_middle base_type; - it = itNext; - } - } + using base_type::m_connected_slots; - 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(); + signal1() + {} - while(it != itEnd) - { - if((*it)->getdest() == oldtarget) - { - m_connected_slots.push_back((*it)->duplicate(newtarget)); - } + signal1(const this_type& s) + : base_type(s) + {} - ++it; - } - } + ~signal1() + { + base_type::disconnect_all(); + } template - void connect(desttype* pclass, void (desttype::*pmemfun)()) + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type)) { lock_block lock(this); - _connection0* conn = - new _connection0(pclass, pmemfun); + _connection1* conn = + new _connection1(pclass, pmemfun); m_connected_slots.push_back(conn); pclass->signal_connect(this); } - void SIGSLOT_EMIT() + void SIGSLOT_EMIT(arg1_type a1) { lock_block lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); @@ -1090,679 +1186,53 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(); + (*it)->SIGSLOT_EMIT(a1); it = itNext; } } - void operator()() + void operator()(arg1_type a1) { - SIGSLOT_EMIT(); + SIGSLOT_EMIT(a1); } - - protected: - - connections_list m_connected_slots; }; - template - class signal1 : public _signal_base + template + class signal2 : public _signal_base_middle*>, mt_policy> { public: - typedef std::list<_connection_base1 *> connections_list; - - signal1() - {} + typedef signal2 this_type; + typedef std::list<_connection_base2*> connections_list; + typedef _signal_base_middle base_type; - signal1(const signal1& 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(); + using base_type::m_connected_slots; - while(it != itEnd) - { - (*it)->getdest()->signal_connect(this); - m_connected_slots.push_back((*it)->clone()); + signal2() + {} - ++it; - } - } + signal2(const this_type& s) + : base_type(s) + {} - ~signal1() + ~signal2() { - disconnect_all(); + base_type::disconnect_all(); } - void slot_duplicate(const has_slots* oldtarget, has_slots* newtarget) + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type)) { 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); - 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) - { - (*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* 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 disconnect(has_slots* pclass) - { - 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; - } - } - - 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)) - { - lock_block lock(this); - _connection1* conn = - new _connection1(pclass, pmemfun); - m_connected_slots.push_back(conn); - pclass->signal_connect(this); - } - - void SIGSLOT_EMIT(arg1_type a1) - { - 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); - - it = itNext; - } - } - - void operator()(arg1_type a1) - { - 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) - { - (*it)->getdest()->signal_connect(this); - m_connected_slots.push_back((*it)->clone()); - - ++it; - } - } - - ~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); - 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) - { - (*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* 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 disconnect(has_slots* pclass) - { - 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; - } - } - - 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)) - { - 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 signal3 : public _signal_base - { - public: - typedef std::list<_connection_base3 *> - connections_list; - - signal3() - {} - - signal3(const signal3& 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; - } - } - - ~signal3() - { - 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); - 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) - { - (*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* 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 disconnect(has_slots* pclass) - { - 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; - } - } - - 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)) - { - 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 signal4 : public _signal_base - { - public: - typedef std::list<_connection_base4 *> connections_list; - - signal4() - {} - - signal4(const signal4& 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; - } - } - - ~signal4() - { - 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); - 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) - { - (*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* 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 disconnect(has_slots* pclass) - { - 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; - } - } - - 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)) - { - lock_block lock(this); - _connection4* - conn = new _connection4(pclass, pmemfun); + _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, arg3_type a3, arg4_type a4) + void SIGSLOT_EMIT(arg1_type a1, arg2_type a2) { lock_block lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); @@ -1773,170 +1243,112 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(a1, a2, a3, a4); + (*it)->SIGSLOT_EMIT(a1, a2); it = itNext; } } - void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) + void operator()(arg1_type a1, arg2_type a2) { - SIGSLOT_EMIT(a1, a2, a3, a4); + SIGSLOT_EMIT(a1, a2); } - - protected: - - connections_list m_connected_slots; }; - template - class signal5 : public _signal_base + template + class signal3 : public _signal_base_middle*>, mt_policy> { public: - typedef std::list<_connection_base5 *> connections_list; - - signal5() - {} - - signal5(const signal5& 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; - } - } - - ~signal5() - { - disconnect_all(); - } + typedef signal3 this_type; + typedef std::list<_connection_base3*> connections_list; + typedef _signal_base_middle base_type; - 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(); + using base_type::m_connected_slots; - while(it != itEnd) - { - if((*it)->getdest() == oldtarget) - { - m_connected_slots.push_back((*it)->duplicate(newtarget)); - } + signal3() + {} - ++it; - } - } + signal3(const this_type& s) + : base_type(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; - } + ~signal3() + { + base_type::disconnect_all(); + } - void disconnect_all() + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type, arg3_type)) { 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; - - ++it; - } - - m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + _connection3* conn = + new _connection3(pclass, + pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); } -#ifdef _DEBUG - bool connected(has_slots* pclass) + 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; - if ((*it)->getdest() == pclass) - return true; + + (*it)->SIGSLOT_EMIT(a1, a2, a3); + it = itNext; } - return false; } -#endif - void disconnect(has_slots* pclass) + void operator()(arg1_type a1, arg2_type a2, arg3_type a3) { - 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, a2, a3); + } + }; - while(it != itEnd) - { - if((*it)->getdest() == pclass) - { - delete *it; - m_connected_slots.erase(it); - pclass->signal_disconnect(this); - return; - } + template + class signal4 : public _signal_base_middle*>, mt_policy> + { + public: - ++it; - } - } + typedef signal4 this_type; + typedef std::list<_connection_base4*> connections_list; + typedef _signal_base_middle base_type; - 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(); + using base_type::m_connected_slots; - while(it != itEnd) - { - typename connections_list::iterator itNext = it; - ++itNext; + signal4() + {} - if((*it)->getdest() == pslot) - { - delete *it; - m_connected_slots.erase(it); - } + signal4(const this_type& s) + : base_type(s) + {} - it = itNext; - } - } + ~signal4() + { + base_type::disconnect_all(); + } template void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type, arg4_type, arg5_type)) + arg2_type, arg3_type, arg4_type)) { lock_block lock(this); - _connection5* conn = new _connection5(pclass, pmemfun); + _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, - arg5_type a5) + 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(); @@ -1947,173 +1359,56 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5); + (*it)->SIGSLOT_EMIT(a1, a2, a3, a4); it = itNext; } } - void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5) + void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) { - SIGSLOT_EMIT(a1, a2, a3, a4, a5); + SIGSLOT_EMIT(a1, a2, a3, a4); } - - protected: - - connections_list m_connected_slots; }; - template - class signal6 : public _signal_base + class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> + class signal5 : public _signal_base_middle*>, mt_policy> { public: - typedef std::list<_connection_base6 *> connections_list; - - 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; - } - } - - ~signal6() - { - 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); - 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) - { - (*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* 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 disconnect(has_slots* pclass) - { - 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; - } - } - 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(); + typedef signal5 this_type; + typedef std::list<_connection_base5*> connections_list; + typedef _signal_base_middle base_type; - while(it != itEnd) - { - typename connections_list::iterator itNext = it; - ++itNext; + using base_type::m_connected_slots; - if((*it)->getdest() == pslot) - { - delete *it; - m_connected_slots.erase(it); - } + signal5() + {} - it = itNext; - } - } + signal5(const this_type& s) + : base_type(s) + {} + + ~signal5() + { + base_type::disconnect_all(); + } template void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, - arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) + arg2_type, arg3_type, arg4_type, arg5_type)) { lock_block lock(this); - _connection6* conn = - new _connection6(pclass, pmemfun); + _connection5* conn = new _connection5(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, arg6_type a6) + arg5_type a5) { lock_block lock(this); typename connections_list::const_iterator itNext, it = m_connected_slots.begin(); @@ -2124,156 +1419,105 @@ namespace sigslot { itNext = it; ++itNext; - (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); + (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5); it = itNext; } } void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, - arg5_type a5, arg6_type a6) + arg5_type a5) { - SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); + SIGSLOT_EMIT(a1, a2, a3, a4, a5); } - - protected: - - connections_list m_connected_slots; }; + template - class signal7 : public _signal_base + class arg5_type, class arg6_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> + class signal6 : public _signal_base_middle*>, mt_policy> { public: - typedef std::list<_connection_base7 *> connections_list; - - signal7() - {} - - 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; - } - } - ~signal7() - { - disconnect_all(); - } + typedef signal6 this_type; + typedef std::list<_connection_base6*> connections_list; + typedef _signal_base_middle base_type; - 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(); + using base_type::m_connected_slots; - while(it != itEnd) - { - if((*it)->getdest() == oldtarget) - { - m_connected_slots.push_back((*it)->duplicate(newtarget)); - } + signal6() + {} - ++it; - } - } + signal6(const this_type& s) + : base_type(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; - } + ~signal6() + { + base_type::disconnect_all(); + } - void disconnect_all() + template + void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, + arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) { 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; - - ++it; - } - - m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end()); + _connection6* conn = + new _connection6(pclass, pmemfun); + m_connected_slots.push_back(conn); + pclass->signal_connect(this); } -#ifdef _DEBUG - bool connected(has_slots* pclass) + 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(); typename connections_list::const_iterator itEnd = m_connected_slots.end(); + while(it != itEnd) { itNext = it; ++itNext; - if ((*it)->getdest() == pclass) - return true; + + (*it)->SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); + it = itNext; } - return false; } -#endif - void disconnect(has_slots* pclass) + void operator()(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::iterator it = m_connected_slots.begin(); - typename connections_list::iterator itEnd = m_connected_slots.end(); + SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6); + } + }; - while(it != itEnd) - { - if((*it)->getdest() == pclass) - { - delete *it; - m_connected_slots.erase(it); - pclass->signal_disconnect(this); - return; - } + template + class signal7 : public _signal_base_middle*>, mt_policy> + { + public: - ++it; - } - } + typedef signal7 this_type; + typedef std::list<_connection_base7*> connections_list; + typedef _signal_base_middle base_type; - 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(); + using base_type::m_connected_slots; - while(it != itEnd) - { - typename connections_list::iterator itNext = it; - ++itNext; + signal7() + {} - if((*it)->getdest() == pslot) - { - delete *it; - m_connected_slots.erase(it); - } + signal7(const this_type& s) + : base_type(s) + {} - it = itNext; - } - } + ~signal7() + { + base_type::disconnect_all(); + } template void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, @@ -2312,147 +1556,31 @@ namespace sigslot { { SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7); } - - protected: - - connections_list m_connected_slots; }; template - class signal8 : public _signal_base + class signal8 : public _signal_base_middle*>, mt_policy> { public: - typedef std::list<_connection_base8 *> - connections_list; + typedef signal8 this_type; + typedef std::list<_connection_base8*> connections_list; + typedef _signal_base_middle base_type; + + using base_type::m_connected_slots; signal8() {} - signal8(const signal8& 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; - } - } - - 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; - } - } - - ~signal8() - { - disconnect_all(); - } - - 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; - } - - 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) - { - (*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* 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 disconnect(has_slots* pclass) - { - 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; - } - } - - 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); - } + signal8(const this_type& s) + : base_type(s) + {} - it = itNext; - } - } + ~signal8() + { + base_type::disconnect_all(); + } template void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type, @@ -2492,9 +1620,6 @@ namespace sigslot { { SIGSLOT_EMIT(a1, a2, a3, a4, a5, a6, a7, a8); } - - protected: - connections_list m_connected_slots; }; namespace impl -- cgit v1.2.3