84 #if defined(SIGSLOT_PURE_ISO) || (!defined(WIN32) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS))
85 # define _SIGSLOT_SINGLE_THREADED
87 # define _SIGSLOT_HAS_WIN32_THREADS
89 #elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS)
90 # define _SIGSLOT_HAS_POSIX_THREADS
93 # define _SIGSLOT_SINGLE_THREADED
96 #ifndef SIGSLOT_DEFAULT_MT_POLICY
97 # ifdef _SIGSLOT_SINGLE_THREADED
98 # define SIGSLOT_DEFAULT_MT_POLICY single_threaded
100 # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local
131 #ifdef _SIGSLOT_HAS_WIN32_THREADS
133 class multi_threaded_global
136 multi_threaded_global()
138 static bool isinitialised =
false;
142 InitializeCriticalSection(get_critsec());
143 isinitialised =
true;
147 multi_threaded_global(
const multi_threaded_global&)
152 virtual ~multi_threaded_global()
159 EnterCriticalSection(get_critsec());
164 LeaveCriticalSection(get_critsec());
168 CRITICAL_SECTION* get_critsec()
170 static CRITICAL_SECTION g_critsec;
180 InitializeCriticalSection(&m_critsec);
185 InitializeCriticalSection(&m_critsec);
190 DeleteCriticalSection(&m_critsec);
195 EnterCriticalSection(&m_critsec);
200 LeaveCriticalSection(&m_critsec);
204 CRITICAL_SECTION m_critsec;
206 #endif // _SIGSLOT_HAS_WIN32_THREADS
208 #ifdef _SIGSLOT_HAS_POSIX_THREADS
210 class multi_threaded_global
213 multi_threaded_global()
215 pthread_mutex_init(get_mutex(), NULL);
218 multi_threaded_global(
const multi_threaded_global&)
223 virtual ~multi_threaded_global()
230 pthread_mutex_lock(get_mutex());
235 pthread_mutex_unlock(get_mutex());
239 pthread_mutex_t* get_mutex()
241 static pthread_mutex_t g_mutex;
251 pthread_mutex_init(&m_mutex, NULL);
256 pthread_mutex_init(&m_mutex, NULL);
261 pthread_mutex_destroy(&m_mutex);
266 pthread_mutex_lock(&m_mutex);
271 pthread_mutex_unlock(&m_mutex);
275 pthread_mutex_t m_mutex;
277 #endif // _SIGSLOT_HAS_POSIX_THREADS
279 template<
class mt_policy>
297 template<
class mt_policy>
300 template<
class mt_policy>
306 virtual void emit() = 0;
311 template<
class arg1_type,
class mt_policy>
317 virtual void emit(arg1_type) = 0;
322 template<
class arg1_type,
class arg2_type,
class mt_policy>
328 virtual void emit(arg1_type, arg2_type) = 0;
333 template<
class arg1_type,
class arg2_type,
class arg3_type,
class mt_policy>
339 virtual void emit(arg1_type, arg2_type, arg3_type) = 0;
344 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
class mt_policy>
350 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) = 0;
355 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
356 class arg5_type,
class mt_policy>
362 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type,
365 arg5_type, mt_policy>*
clone() = 0;
370 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
371 class arg5_type,
class arg6_type,
class mt_policy>
377 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
380 arg5_type, arg6_type, mt_policy>*
clone() = 0;
385 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
386 class arg5_type,
class arg6_type,
class arg7_type,
class mt_policy>
392 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
393 arg6_type, arg7_type) = 0;
395 arg5_type, arg6_type, arg7_type, mt_policy>*
clone() = 0;
400 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
401 class arg5_type,
class arg6_type,
class arg7_type,
class arg8_type,
class mt_policy>
407 virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
408 arg6_type, arg7_type, arg8_type) = 0;
410 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>*
clone() = 0;
415 template<
class mt_policy>
423 template<
class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
427 typedef typename std::set<_signal_base<mt_policy> *>
sender_set;
445 (*it)->slot_duplicate(&hs,
this);
476 (*it)->slot_disconnect(
this);
487 template<
class mt_policy>
493 typedef typename connections_list::iterator
iterator;
509 (*it)->getdest()->signal_connect(
this);
529 (*it)->getdest()->signal_disconnect(
this);
546 if((*it)->getdest() == pclass)
569 if((*it)->getdest() == pslot)
587 if((*it)->getdest() == oldtarget)
600 template<
class arg1_type,
class mt_policy>
606 typedef typename connections_list::iterator
iterator;
622 (*it)->getdest()->signal_connect(
this);
637 if((*it)->getdest() == oldtarget)
659 (*it)->getdest()->signal_disconnect(
this);
676 if((*it)->getdest() == pclass)
699 if((*it)->getdest() == pslot)
714 template<
class arg1_type,
class arg2_type,
class mt_policy>
718 typedef typename std::list<_connection_base2<arg1_type, arg2_type, mt_policy> *>
721 typedef typename connections_list::iterator
iterator;
737 (*it)->getdest()->signal_connect(
this);
752 if((*it)->getdest() == oldtarget)
774 (*it)->getdest()->signal_disconnect(
this);
791 if((*it)->getdest() == pclass)
814 if((*it)->getdest() == pslot)
828 template<
class arg1_type,
class arg2_type,
class arg3_type,
class mt_policy>
832 typedef std::list<_connection_base3<arg1_type, arg2_type, arg3_type, mt_policy> *>
836 typedef typename connections_list::iterator
iterator;
851 (*it)->getdest()->signal_connect(
this);
866 if((*it)->getdest() == oldtarget)
888 (*it)->getdest()->signal_disconnect(
this);
905 if((*it)->getdest() == pclass)
928 if((*it)->getdest() == pslot)
942 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
class mt_policy>
949 typedef typename connections_list::iterator
iterator;
965 (*it)->getdest()->signal_connect(
this);
980 if((*it)->getdest() == oldtarget)
1002 (*it)->getdest()->signal_disconnect(
this);
1019 if((*it)->getdest() == pclass)
1042 if((*it)->getdest() == pslot)
1056 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
1057 class arg5_type,
class mt_policy>
1072 arg5_type, mt_policy>&
s)
1081 (*it)->getdest()->signal_connect(
this);
1096 if((*it)->getdest() == oldtarget)
1118 (*it)->getdest()->signal_disconnect(
this);
1135 if((*it)->getdest() == pclass)
1158 if((*it)->getdest() == pslot)
1172 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
1173 class arg5_type,
class arg6_type,
class mt_policy>
1188 arg5_type, arg6_type, mt_policy>&
s)
1197 (*it)->getdest()->signal_connect(
this);
1212 if((*it)->getdest() == oldtarget)
1234 (*it)->getdest()->signal_disconnect(
this);
1251 if((*it)->getdest() == pclass)
1274 if((*it)->getdest() == pslot)
1288 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
1289 class arg5_type,
class arg6_type,
class arg7_type,
class mt_policy>
1304 arg5_type, arg6_type, arg7_type, mt_policy>&
s)
1313 (*it)->getdest()->signal_connect(
this);
1328 if((*it)->getdest() == oldtarget)
1350 (*it)->getdest()->signal_disconnect(
this);
1367 if((*it)->getdest() == pclass)
1390 if((*it)->getdest() == pslot)
1404 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
1405 class arg5_type,
class arg6_type,
class arg7_type,
class arg8_type,
class mt_policy>
1410 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> *>
1421 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>&
s)
1430 (*it)->getdest()->signal_connect(
this);
1445 if((*it)->getdest() == oldtarget)
1467 (*it)->getdest()->signal_disconnect(
this);
1484 if((*it)->getdest() == pclass)
1507 if((*it)->getdest() == pslot)
1522 template<
class dest_type,
class mt_policy>
1528 this->pobject = NULL;
1529 this->pmemfun = NULL;
1563 template<
class dest_type,
class arg1_type,
class mt_policy>
1569 this->pobject = NULL;
1570 this->pmemfun = NULL;
1604 template<
class dest_type,
class arg1_type,
class arg2_type,
class mt_policy>
1610 this->pobject = NULL;
1611 this->pmemfun = NULL;
1631 virtual void emit(arg1_type a1, arg2_type
a2)
1646 template<
class dest_type,
class arg1_type,
class arg2_type,
class arg3_type,
class mt_policy>
1652 this->pobject = NULL;
1653 this->pmemfun = NULL;
1657 arg2_type, arg3_type))
1673 virtual void emit(arg1_type a1, arg2_type
a2, arg3_type a3)
1685 void (dest_type::*
m_pmemfun)(arg1_type, arg2_type, arg3_type);
1688 template<
class dest_type,
class arg1_type,
class arg2_type,
class arg3_type,
1689 class arg4_type,
class mt_policy>
1691 arg3_type, arg4_type, mt_policy>
1696 this->pobject = NULL;
1697 this->pmemfun = NULL;
1701 arg2_type, arg3_type, arg4_type))
1717 virtual void emit(arg1_type a1, arg2_type
a2, arg3_type a3,
1730 void (dest_type::*
m_pmemfun)(arg1_type, arg2_type, arg3_type,
1734 template<
class dest_type,
class arg1_type,
class arg2_type,
class arg3_type,
1735 class arg4_type,
class arg5_type,
class mt_policy>
1737 arg3_type, arg4_type, arg5_type, mt_policy>
1742 this->pobject = NULL;
1743 this->pmemfun = NULL;
1747 arg2_type, arg3_type, arg4_type, arg5_type))
1756 return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1757 arg5_type, mt_policy>(*this);
1763 return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1764 arg5_type, mt_policy>((dest_type *)pnewdest,
m_pmemfun);
1767 virtual void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
1780 void (dest_type::*
m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
1784 template<
class dest_type,
class arg1_type,
class arg2_type,
class arg3_type,
1785 class arg4_type,
class arg5_type,
class arg6_type,
class mt_policy>
1787 arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>
1792 this->pobject = NULL;
1793 this->pmemfun = NULL;
1797 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type))
1804 arg5_type, arg6_type, mt_policy>*
clone()
1806 return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1807 arg5_type, arg6_type, mt_policy>(*this);
1813 return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1814 arg5_type, arg6_type, mt_policy>((dest_type *)pnewdest,
m_pmemfun);
1817 virtual void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
1818 arg5_type a5, arg6_type a6)
1830 void (dest_type::*
m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
1831 arg5_type, arg6_type);
1834 template<
class dest_type,
class arg1_type,
class arg2_type,
class arg3_type,
1835 class arg4_type,
class arg5_type,
class arg6_type,
class arg7_type,
class mt_policy>
1837 arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>
1842 this->pobject = NULL;
1843 this->pmemfun = NULL;
1847 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type))
1854 arg5_type, arg6_type, arg7_type, mt_policy>*
clone()
1856 return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1857 arg5_type, arg6_type, arg7_type, mt_policy>(*this);
1863 return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1864 arg5_type, arg6_type, arg7_type, mt_policy>((dest_type *)pnewdest,
m_pmemfun);
1867 virtual void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
1868 arg5_type a5, arg6_type a6, arg7_type a7)
1880 void (dest_type::*
m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
1881 arg5_type, arg6_type, arg7_type);
1884 template<
class dest_type,
class arg1_type,
class arg2_type,
class arg3_type,
1885 class arg4_type,
class arg5_type,
class arg6_type,
class arg7_type,
1886 class arg8_type,
class mt_policy>
1888 arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>
1893 this->pobject = NULL;
1894 this->pmemfun = NULL;
1898 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
1899 arg7_type, arg8_type))
1906 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>*
clone()
1908 return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1909 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(*this);
1915 return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
1916 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>((dest_type *)pnewdest,
m_pmemfun);
1919 virtual void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
1920 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
1932 void (dest_type::*
m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
1933 arg5_type, arg6_type, arg7_type, arg8_type);
1936 template<
class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
1952 template<
class desttype>
1953 void connect(desttype* pclass,
void (desttype::*pmemfun)())
1959 pclass->signal_connect(
this);
1997 template<
class arg1_type,
class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2013 template<
class desttype>
2014 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type))
2020 pclass->signal_connect(
this);
2058 template<
class arg1_type,
typename arg2_type,
typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2074 template<
class desttype>
2075 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2082 pclass->signal_connect(
this);
2096 (*it)->emit(a1, a2);
2113 (*it)->emit(a1, a2);
2120 template<
class arg1_type,
typename arg2_type,
typename arg3_type,
typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2131 :
_signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>(s)
2136 template<
class desttype>
2137 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2138 arg2_type, arg3_type))
2145 pclass->signal_connect(
this);
2148 void emit(arg1_type a1, arg2_type
a2, arg3_type a3)
2159 (*it)->emit(a1, a2, a3);
2176 (*it)->emit(a1, a2, a3);
2183 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
2185 arg4_type, mt_policy>
2195 :
_signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(s)
2200 template<
class desttype>
2201 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2202 arg2_type, arg3_type, arg4_type))
2206 conn =
new _connection4<desttype, arg1_type, arg2_type, arg3_type,
2207 arg4_type, mt_policy>(pclass, pmemfun);
2209 pclass->signal_connect(
this);
2212 void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4)
2223 (*it)->emit(a1, a2, a3, a4);
2240 (*it)->emit(a1, a2, a3, a4);
2247 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
2250 arg4_type, arg5_type, mt_policy>
2260 arg5_type, mt_policy>&
s)
2262 arg5_type, mt_policy>(
s)
2267 template<
class desttype>
2268 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2269 arg2_type, arg3_type, arg4_type, arg5_type))
2272 _connection5<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2273 arg5_type, mt_policy>* conn =
new _connection5<desttype, arg1_type, arg2_type,
2274 arg3_type, arg4_type, arg5_type, mt_policy>(pclass, pmemfun);
2276 pclass->signal_connect(
this);
2279 void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
2291 (*it)->emit(a1, a2, a3, a4, a5);
2309 (*it)->emit(a1, a2, a3, a4, a5);
2317 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
2320 arg4_type, arg5_type, arg6_type, mt_policy>
2323 typedef typename _signal_base6<arg1_type, arg2_type, arg3_type,
2324 arg4_type, arg5_type, arg6_type, mt_policy>::connections_list::const_iterator
const_iterator;
2331 arg5_type, arg6_type, mt_policy>&
s)
2333 arg5_type, arg6_type, mt_policy>(
s)
2338 template<
class desttype>
2339 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2340 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type))
2343 _connection6<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2344 arg5_type, arg6_type, mt_policy>* conn =
2345 new _connection6<desttype, arg1_type, arg2_type, arg3_type,
2346 arg4_type, arg5_type, arg6_type, mt_policy>(pclass, pmemfun);
2348 pclass->signal_connect(
this);
2351 void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
2352 arg5_type a5, arg6_type a6)
2363 (*it)->emit(a1, a2, a3, a4, a5, a6);
2370 arg5_type a5, arg6_type a6)
2381 (*it)->emit(a1, a2, a3, a4, a5, a6);
2388 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
2391 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>
2394 typedef typename _signal_base7<arg1_type, arg2_type, arg3_type,
2395 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>::connections_list::const_iterator
const_iterator;
2402 arg5_type, arg6_type, arg7_type, mt_policy>&
s)
2404 arg5_type, arg6_type, arg7_type, mt_policy>(
s)
2409 template<
class desttype>
2410 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2411 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
2415 _connection7<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2416 arg5_type, arg6_type, arg7_type, mt_policy>* conn =
2417 new _connection7<desttype, arg1_type, arg2_type, arg3_type,
2418 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>(pclass, pmemfun);
2420 pclass->signal_connect(
this);
2423 void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
2424 arg5_type a5, arg6_type a6, arg7_type a7)
2435 (*it)->emit(a1, a2, a3, a4, a5, a6, a7);
2442 arg5_type a5, arg6_type a6, arg7_type a7)
2453 (*it)->emit(a1, a2, a3, a4, a5, a6, a7);
2460 template<
class arg1_type,
class arg2_type,
class arg3_type,
class arg4_type,
2463 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>
2466 typedef typename _signal_base8<arg1_type, arg2_type, arg3_type,
2467 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>::connections_list::const_iterator
const_iterator;
2474 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>&
s)
2476 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(
s)
2481 template<
class desttype>
2482 void connect(desttype* pclass,
void (desttype::*pmemfun)(arg1_type,
2483 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
2484 arg7_type, arg8_type))
2487 _connection8<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
2488 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* conn =
2489 new _connection8<desttype, arg1_type, arg2_type, arg3_type,
2490 arg4_type, arg5_type, arg6_type, arg7_type,
2491 arg8_type, mt_policy>(pclass, pmemfun);
2493 pclass->signal_connect(
this);
2496 void emit(arg1_type a1, arg2_type
a2, arg3_type a3, arg4_type a4,
2497 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
2508 (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8);
2515 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
2526 (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8);
2535 #endif // SIGSLOT_H__