sigslot.h 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499
  1. // sigslot.h: Signal/Slot classes
  2. //
  3. // Written by Sarah Thompson (sarah@telergy.com) 2002.
  4. //
  5. // License: Public domain. You are free to use this code however you like, with the proviso that
  6. // the author takes on no responsibility or liability for any use.
  7. //
  8. // QUICK DOCUMENTATION
  9. //
  10. // (see also the full documentation at http://sigslot.sourceforge.net/)
  11. //
  12. // #define switches
  13. // SIGSLOT_PURE_ISO - Define this to force ISO C++ compliance. This also disables
  14. // all of the thread safety support on platforms where it is
  15. // available.
  16. //
  17. // SIGSLOT_USE_POSIX_THREADS - Force use of Posix threads when using a C++ compiler other than
  18. // gcc on a platform that supports Posix threads. (When using gcc,
  19. // this is the default - use SIGSLOT_PURE_ISO to disable this if
  20. // necessary)
  21. //
  22. // SIGSLOT_DEFAULT_MT_POLICY - Where thread support is enabled, this defaults to multi_threaded_global.
  23. // Otherwise, the default is single_threaded. #define this yourself to
  24. // override the default. In pure ISO mode, anything other than
  25. // single_threaded will cause a compiler error.
  26. //
  27. // PLATFORM NOTES
  28. //
  29. // Win32 - On Win32, the WIN32 symbol must be #defined. Most mainstream
  30. // compilers do this by default, but you may need to define it
  31. // yourself if your build environment is less standard. This causes
  32. // the Win32 thread support to be compiled in and used automatically.
  33. //
  34. // Unix/Linux/BSD, etc. - If you're using gcc, it is assumed that you have Posix threads
  35. // available, so they are used automatically. You can override this
  36. // (as under Windows) with the SIGSLOT_PURE_ISO switch. If you're using
  37. // something other than gcc but still want to use Posix threads, you
  38. // need to #define SIGSLOT_USE_POSIX_THREADS.
  39. //
  40. // ISO C++ - If none of the supported platforms are detected, or if
  41. // SIGSLOT_PURE_ISO is defined, all multithreading support is turned off,
  42. // along with any code that might cause a pure ISO C++ environment to
  43. // complain. Before you ask, gcc -ansi -pedantic won't compile this
  44. // library, but gcc -ansi is fine. Pedantic mode seems to throw a lot of
  45. // errors that aren't really there. If you feel like investigating this,
  46. // please contact the author.
  47. //
  48. //
  49. // THREADING MODES
  50. //
  51. // single_threaded - Your program is assumed to be single threaded from the point of view
  52. // of signal/slot usage (i.e. all objects using signals and slots are
  53. // created and destroyed from a single thread). Behaviour if objects are
  54. // destroyed concurrently is undefined (i.e. you'll get the occasional
  55. // segmentation fault/memory exception).
  56. //
  57. // multi_threaded_global - Your program is assumed to be multi threaded. Objects using signals and
  58. // slots can be safely created and destroyed from any thread, even when
  59. // connections exist. In multi_threaded_global mode, this is achieved by a
  60. // single global mutex (actually a critical section on Windows because they
  61. // are faster). This option uses less OS resources, but results in more
  62. // opportunities for contention, possibly resulting in more context switches
  63. // than are strictly necessary.
  64. //
  65. // multi_threaded_local - Behaviour in this mode is essentially the same as multi_threaded_global,
  66. // except that each signal, and each object that inherits has_slots, all
  67. // have their own mutex/critical section. In practice, this means that
  68. // mutex collisions (and hence context switches) only happen if they are
  69. // absolutely essential. However, on some platforms, creating a lot of
  70. // mutexes can slow down the whole OS, so use this option with care.
  71. //
  72. // USING THE LIBRARY
  73. //
  74. // See the full documentation at http://sigslot.sourceforge.net/
  75. //
  76. //
  77. // https://www.cnblogs.com/swarmbees/p/10828138.html
  78. #ifndef SIGSLOT_H__
  79. #define SIGSLOT_H__
  80. #include <set>
  81. #include <list>
  82. #if defined(SIGSLOT_PURE_ISO) || (!defined(WIN32) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS))
  83. # define _SIGSLOT_SINGLE_THREADED
  84. #elif defined(WIN32)
  85. # define _SIGSLOT_HAS_WIN32_THREADS
  86. # include <windows.h>
  87. #elif defined(__GNUG__) || defined(SIGSLOT_USE_POSIX_THREADS)
  88. # define _SIGSLOT_HAS_POSIX_THREADS
  89. # include <pthread.h>
  90. #else
  91. # define _SIGSLOT_SINGLE_THREADED
  92. #endif
  93. #ifndef SIGSLOT_DEFAULT_MT_POLICY
  94. # ifdef _SIGSLOT_SINGLE_THREADED
  95. # define SIGSLOT_DEFAULT_MT_POLICY single_threaded
  96. # else
  97. # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local
  98. # endif
  99. #endif
  100. namespace sigslot {
  101. class single_threaded
  102. {
  103. public:
  104. single_threaded()
  105. {
  106. ;
  107. }
  108. virtual ~single_threaded()
  109. {
  110. ;
  111. }
  112. virtual void lock()
  113. {
  114. ;
  115. }
  116. virtual void unlock()
  117. {
  118. ;
  119. }
  120. };
  121. #ifdef _SIGSLOT_HAS_WIN32_THREADS
  122. // The multi threading policies only get compiled in if they are enabled.
  123. class multi_threaded_global
  124. {
  125. public:
  126. multi_threaded_global()
  127. {
  128. static bool isinitialised = false;
  129. if(!isinitialised)
  130. {
  131. InitializeCriticalSection(get_critsec());
  132. isinitialised = true;
  133. }
  134. }
  135. multi_threaded_global(const multi_threaded_global&)
  136. {
  137. ;
  138. }
  139. virtual ~multi_threaded_global()
  140. {
  141. ;
  142. }
  143. virtual void lock()
  144. {
  145. EnterCriticalSection(get_critsec());
  146. }
  147. virtual void unlock()
  148. {
  149. LeaveCriticalSection(get_critsec());
  150. }
  151. private:
  152. CRITICAL_SECTION* get_critsec()
  153. {
  154. static CRITICAL_SECTION g_critsec;
  155. return &g_critsec;
  156. }
  157. };
  158. class multi_threaded_local
  159. {
  160. public:
  161. multi_threaded_local()
  162. {
  163. InitializeCriticalSection(&m_critsec);
  164. }
  165. multi_threaded_local(const multi_threaded_local&)
  166. {
  167. InitializeCriticalSection(&m_critsec);
  168. }
  169. virtual ~multi_threaded_local()
  170. {
  171. DeleteCriticalSection(&m_critsec);
  172. }
  173. virtual void lock()
  174. {
  175. EnterCriticalSection(&m_critsec);
  176. }
  177. virtual void unlock()
  178. {
  179. LeaveCriticalSection(&m_critsec);
  180. }
  181. private:
  182. CRITICAL_SECTION m_critsec;
  183. };
  184. #endif // _SIGSLOT_HAS_WIN32_THREADS
  185. #ifdef _SIGSLOT_HAS_POSIX_THREADS
  186. // The multi threading policies only get compiled in if they are enabled.
  187. class multi_threaded_global
  188. {
  189. public:
  190. multi_threaded_global()
  191. {
  192. pthread_mutex_init(get_mutex(), NULL);
  193. }
  194. multi_threaded_global(const multi_threaded_global&)
  195. {
  196. ;
  197. }
  198. virtual ~multi_threaded_global()
  199. {
  200. ;
  201. }
  202. virtual void lock()
  203. {
  204. pthread_mutex_lock(get_mutex());
  205. }
  206. virtual void unlock()
  207. {
  208. pthread_mutex_unlock(get_mutex());
  209. }
  210. private:
  211. pthread_mutex_t* get_mutex()
  212. {
  213. static pthread_mutex_t g_mutex;
  214. return &g_mutex;
  215. }
  216. };
  217. class multi_threaded_local
  218. {
  219. public:
  220. multi_threaded_local()
  221. {
  222. pthread_mutex_init(&m_mutex, NULL);
  223. }
  224. multi_threaded_local(const multi_threaded_local&)
  225. {
  226. pthread_mutex_init(&m_mutex, NULL);
  227. }
  228. virtual ~multi_threaded_local()
  229. {
  230. pthread_mutex_destroy(&m_mutex);
  231. }
  232. virtual void lock()
  233. {
  234. pthread_mutex_lock(&m_mutex);
  235. }
  236. virtual void unlock()
  237. {
  238. pthread_mutex_unlock(&m_mutex);
  239. }
  240. private:
  241. pthread_mutex_t m_mutex;
  242. };
  243. #endif // _SIGSLOT_HAS_POSIX_THREADS
  244. template<class mt_policy>
  245. class lock_block
  246. {
  247. public:
  248. mt_policy *m_mutex;
  249. lock_block(mt_policy *mtx)
  250. : m_mutex(mtx)
  251. {
  252. m_mutex->lock();
  253. }
  254. ~lock_block()
  255. {
  256. m_mutex->unlock();
  257. }
  258. };
  259. template<class mt_policy>
  260. class has_slots;
  261. template<class mt_policy>
  262. class _connection_base0
  263. {
  264. public:
  265. virtual has_slots<mt_policy>* getdest() const = 0;
  266. virtual void emit() = 0;
  267. virtual _connection_base0* clone() = 0;
  268. virtual _connection_base0* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  269. };
  270. template<class arg1_type, class mt_policy>
  271. class _connection_base1
  272. {
  273. public:
  274. virtual has_slots<mt_policy>* getdest() const = 0;
  275. virtual void emit(arg1_type) = 0;
  276. virtual _connection_base1<arg1_type, mt_policy>* clone() = 0;
  277. virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  278. };
  279. template<class arg1_type, class arg2_type, class mt_policy>
  280. class _connection_base2
  281. {
  282. public:
  283. virtual has_slots<mt_policy>* getdest() const = 0;
  284. virtual void emit(arg1_type, arg2_type) = 0;
  285. virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone() = 0;
  286. virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  287. };
  288. template<class arg1_type, class arg2_type, class arg3_type, class mt_policy>
  289. class _connection_base3
  290. {
  291. public:
  292. virtual has_slots<mt_policy>* getdest() const = 0;
  293. virtual void emit(arg1_type, arg2_type, arg3_type) = 0;
  294. virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone() = 0;
  295. virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  296. };
  297. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy>
  298. class _connection_base4
  299. {
  300. public:
  301. virtual has_slots<mt_policy>* getdest() const = 0;
  302. virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) = 0;
  303. virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone() = 0;
  304. virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  305. };
  306. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  307. class arg5_type, class mt_policy>
  308. class _connection_base5
  309. {
  310. public:
  311. virtual has_slots<mt_policy>* getdest() const = 0;
  312. virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type,
  313. arg5_type) = 0;
  314. virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
  315. arg5_type, mt_policy>* clone() = 0;
  316. virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
  317. arg5_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  318. };
  319. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  320. class arg5_type, class arg6_type, class mt_policy>
  321. class _connection_base6
  322. {
  323. public:
  324. virtual has_slots<mt_policy>* getdest() const = 0;
  325. virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
  326. arg6_type) = 0;
  327. virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
  328. arg5_type, arg6_type, mt_policy>* clone() = 0;
  329. virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
  330. arg5_type, arg6_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  331. };
  332. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  333. class arg5_type, class arg6_type, class arg7_type, class mt_policy>
  334. class _connection_base7
  335. {
  336. public:
  337. virtual has_slots<mt_policy>* getdest() const = 0;
  338. virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
  339. arg6_type, arg7_type) = 0;
  340. virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
  341. arg5_type, arg6_type, arg7_type, mt_policy>* clone() = 0;
  342. virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
  343. arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  344. };
  345. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  346. class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy>
  347. class _connection_base8
  348. {
  349. public:
  350. virtual has_slots<mt_policy>* getdest() const = 0;
  351. virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, arg5_type,
  352. arg6_type, arg7_type, arg8_type) = 0;
  353. virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
  354. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone() = 0;
  355. virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
  356. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest) = 0;
  357. };
  358. template<class mt_policy>
  359. class _signal_base : public mt_policy
  360. {
  361. public:
  362. virtual void slot_disconnect(has_slots<mt_policy>* pslot) = 0;
  363. virtual void slot_duplicate(const has_slots<mt_policy>* poldslot, has_slots<mt_policy>* pnewslot) = 0;
  364. };
  365. template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  366. class has_slots : public mt_policy
  367. {
  368. private:
  369. typedef std::set<_signal_base<mt_policy> *> sender_set;
  370. typedef sender_set::const_iterator const_iterator;
  371. public:
  372. has_slots()
  373. {
  374. ;
  375. }
  376. has_slots(const has_slots& hs)
  377. : mt_policy(hs)
  378. {
  379. lock_block<mt_policy> lock(this);
  380. const_iterator it = hs.m_senders.begin();
  381. const_iterator itEnd = hs.m_senders.end();
  382. while(it != itEnd)
  383. {
  384. (*it)->slot_duplicate(&hs, this);
  385. m_senders.insert(*it);
  386. ++it;
  387. }
  388. }
  389. void signal_connect(_signal_base<mt_policy>* sender)
  390. {
  391. lock_block<mt_policy> lock(this);
  392. m_senders.insert(sender);
  393. }
  394. void signal_disconnect(_signal_base<mt_policy>* sender)
  395. {
  396. lock_block<mt_policy> lock(this);
  397. m_senders.erase(sender);
  398. }
  399. virtual ~has_slots()
  400. {
  401. disconnect_all();
  402. }
  403. void disconnect_all()
  404. {
  405. lock_block<mt_policy> lock(this);
  406. const_iterator it = m_senders.begin();
  407. const_iterator itEnd = m_senders.end();
  408. while(it != itEnd)
  409. {
  410. (*it)->slot_disconnect(this);
  411. ++it;
  412. }
  413. m_senders.erase(m_senders.begin(), m_senders.end());
  414. }
  415. private:
  416. sender_set m_senders;
  417. };
  418. template<class mt_policy>
  419. class _signal_base0 : public _signal_base<mt_policy>
  420. {
  421. public:
  422. typedef std::list<_connection_base0<mt_policy> *> connections_list;
  423. _signal_base0()
  424. {
  425. ;
  426. }
  427. _signal_base0(const _signal_base0& s)
  428. : _signal_base<mt_policy>(s)
  429. {
  430. lock_block<mt_policy> lock(this);
  431. connections_list::const_iterator it = s.m_connected_slots.begin();
  432. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  433. while(it != itEnd)
  434. {
  435. (*it)->getdest()->signal_connect(this);
  436. m_connected_slots.push_back((*it)->clone());
  437. ++it;
  438. }
  439. }
  440. ~_signal_base0()
  441. {
  442. disconnect_all();
  443. }
  444. void disconnect_all()
  445. {
  446. lock_block<mt_policy> lock(this);
  447. connections_list::const_iterator it = m_connected_slots.begin();
  448. connections_list::const_iterator itEnd = m_connected_slots.end();
  449. while(it != itEnd)
  450. {
  451. (*it)->getdest()->signal_disconnect(this);
  452. delete *it;
  453. ++it;
  454. }
  455. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  456. }
  457. void disconnect(has_slots<mt_policy>* pclass)
  458. {
  459. lock_block<mt_policy> lock(this);
  460. connections_list::iterator it = m_connected_slots.begin();
  461. connections_list::iterator itEnd = m_connected_slots.end();
  462. while(it != itEnd)
  463. {
  464. if((*it)->getdest() == pclass)
  465. {
  466. delete *it;
  467. m_connected_slots.erase(it);
  468. pclass->signal_disconnect(this);
  469. return;
  470. }
  471. ++it;
  472. }
  473. }
  474. void slot_disconnect(has_slots<mt_policy>* pslot)
  475. {
  476. lock_block<mt_policy> lock(this);
  477. connections_list::iterator it = m_connected_slots.begin();
  478. connections_list::iterator itEnd = m_connected_slots.end();
  479. while(it != itEnd)
  480. {
  481. connections_list::iterator itNext = it;
  482. ++itNext;
  483. if((*it)->getdest() == pslot)
  484. {
  485. m_connected_slots.erase(it);
  486. // delete *it;
  487. }
  488. it = itNext;
  489. }
  490. }
  491. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  492. {
  493. lock_block<mt_policy> lock(this);
  494. connections_list::iterator it = m_connected_slots.begin();
  495. connections_list::iterator itEnd = m_connected_slots.end();
  496. while(it != itEnd)
  497. {
  498. if((*it)->getdest() == oldtarget)
  499. {
  500. m_connected_slots.push_back((*it)->duplicate(newtarget));
  501. }
  502. ++it;
  503. }
  504. }
  505. protected:
  506. connections_list m_connected_slots;
  507. };
  508. template<class arg1_type, class mt_policy>
  509. class _signal_base1 : public _signal_base<mt_policy>
  510. {
  511. public:
  512. typedef std::list<_connection_base1<arg1_type, mt_policy> *> connections_list;
  513. _signal_base1()
  514. {
  515. ;
  516. }
  517. _signal_base1(const _signal_base1<arg1_type, mt_policy>& s)
  518. : _signal_base<mt_policy>(s)
  519. {
  520. lock_block<mt_policy> lock(this);
  521. connections_list::const_iterator it = s.m_connected_slots.begin();
  522. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  523. while(it != itEnd)
  524. {
  525. (*it)->getdest()->signal_connect(this);
  526. m_connected_slots.push_back((*it)->clone());
  527. ++it;
  528. }
  529. }
  530. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  531. {
  532. lock_block<mt_policy> lock(this);
  533. connections_list::iterator it = m_connected_slots.begin();
  534. connections_list::iterator itEnd = m_connected_slots.end();
  535. while(it != itEnd)
  536. {
  537. if((*it)->getdest() == oldtarget)
  538. {
  539. m_connected_slots.push_back((*it)->duplicate(newtarget));
  540. }
  541. ++it;
  542. }
  543. }
  544. ~_signal_base1()
  545. {
  546. disconnect_all();
  547. }
  548. void disconnect_all()
  549. {
  550. lock_block<mt_policy> lock(this);
  551. connections_list::const_iterator it = m_connected_slots.begin();
  552. connections_list::const_iterator itEnd = m_connected_slots.end();
  553. while(it != itEnd)
  554. {
  555. (*it)->getdest()->signal_disconnect(this);
  556. delete *it;
  557. ++it;
  558. }
  559. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  560. }
  561. void disconnect(has_slots<mt_policy>* pclass)
  562. {
  563. lock_block<mt_policy> lock(this);
  564. connections_list::iterator it = m_connected_slots.begin();
  565. connections_list::iterator itEnd = m_connected_slots.end();
  566. while(it != itEnd)
  567. {
  568. if((*it)->getdest() == pclass)
  569. {
  570. delete *it;
  571. m_connected_slots.erase(it);
  572. pclass->signal_disconnect(this);
  573. return;
  574. }
  575. ++it;
  576. }
  577. }
  578. void slot_disconnect(has_slots<mt_policy>* pslot)
  579. {
  580. lock_block<mt_policy> lock(this);
  581. connections_list::iterator it = m_connected_slots.begin();
  582. connections_list::iterator itEnd = m_connected_slots.end();
  583. while(it != itEnd)
  584. {
  585. connections_list::iterator itNext = it;
  586. ++itNext;
  587. if((*it)->getdest() == pslot)
  588. {
  589. m_connected_slots.erase(it);
  590. // delete *it;
  591. }
  592. it = itNext;
  593. }
  594. }
  595. protected:
  596. connections_list m_connected_slots;
  597. };
  598. template<class arg1_type, class arg2_type, class mt_policy>
  599. class _signal_base2 : public _signal_base<mt_policy>
  600. {
  601. public:
  602. typedef std::list<_connection_base2<arg1_type, arg2_type, mt_policy> *>
  603. connections_list;
  604. _signal_base2()
  605. {
  606. ;
  607. }
  608. _signal_base2(const _signal_base2<arg1_type, arg2_type, mt_policy>& s)
  609. : _signal_base<mt_policy>(s)
  610. {
  611. lock_block<mt_policy> lock(this);
  612. connections_list::const_iterator it = s.m_connected_slots.begin();
  613. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  614. while(it != itEnd)
  615. {
  616. (*it)->getdest()->signal_connect(this);
  617. m_connected_slots.push_back((*it)->clone());
  618. ++it;
  619. }
  620. }
  621. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  622. {
  623. lock_block<mt_policy> lock(this);
  624. connections_list::iterator it = m_connected_slots.begin();
  625. connections_list::iterator itEnd = m_connected_slots.end();
  626. while(it != itEnd)
  627. {
  628. if((*it)->getdest() == oldtarget)
  629. {
  630. m_connected_slots.push_back((*it)->duplicate(newtarget));
  631. }
  632. ++it;
  633. }
  634. }
  635. ~_signal_base2()
  636. {
  637. disconnect_all();
  638. }
  639. void disconnect_all()
  640. {
  641. lock_block<mt_policy> lock(this);
  642. connections_list::const_iterator it = m_connected_slots.begin();
  643. connections_list::const_iterator itEnd = m_connected_slots.end();
  644. while(it != itEnd)
  645. {
  646. (*it)->getdest()->signal_disconnect(this);
  647. delete *it;
  648. ++it;
  649. }
  650. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  651. }
  652. void disconnect(has_slots<mt_policy>* pclass)
  653. {
  654. lock_block<mt_policy> lock(this);
  655. connections_list::iterator it = m_connected_slots.begin();
  656. connections_list::iterator itEnd = m_connected_slots.end();
  657. while(it != itEnd)
  658. {
  659. if((*it)->getdest() == pclass)
  660. {
  661. delete *it;
  662. m_connected_slots.erase(it);
  663. pclass->signal_disconnect(this);
  664. return;
  665. }
  666. ++it;
  667. }
  668. }
  669. void slot_disconnect(has_slots<mt_policy>* pslot)
  670. {
  671. lock_block<mt_policy> lock(this);
  672. connections_list::iterator it = m_connected_slots.begin();
  673. connections_list::iterator itEnd = m_connected_slots.end();
  674. while(it != itEnd)
  675. {
  676. connections_list::iterator itNext = it;
  677. ++itNext;
  678. if((*it)->getdest() == pslot)
  679. {
  680. m_connected_slots.erase(it);
  681. // delete *it;
  682. }
  683. it = itNext;
  684. }
  685. }
  686. protected:
  687. connections_list m_connected_slots;
  688. };
  689. template<class arg1_type, class arg2_type, class arg3_type, class mt_policy>
  690. class _signal_base3 : public _signal_base<mt_policy>
  691. {
  692. public:
  693. typedef std::list<_connection_base3<arg1_type, arg2_type, arg3_type, mt_policy> *>
  694. connections_list;
  695. _signal_base3()
  696. {
  697. ;
  698. }
  699. _signal_base3(const _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>& s)
  700. : _signal_base<mt_policy>(s)
  701. {
  702. lock_block<mt_policy> lock(this);
  703. connections_list::const_iterator it = s.m_connected_slots.begin();
  704. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  705. while(it != itEnd)
  706. {
  707. (*it)->getdest()->signal_connect(this);
  708. m_connected_slots.push_back((*it)->clone());
  709. ++it;
  710. }
  711. }
  712. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  713. {
  714. lock_block<mt_policy> lock(this);
  715. connections_list::iterator it = m_connected_slots.begin();
  716. connections_list::iterator itEnd = m_connected_slots.end();
  717. while(it != itEnd)
  718. {
  719. if((*it)->getdest() == oldtarget)
  720. {
  721. m_connected_slots.push_back((*it)->duplicate(newtarget));
  722. }
  723. ++it;
  724. }
  725. }
  726. ~_signal_base3()
  727. {
  728. disconnect_all();
  729. }
  730. void disconnect_all()
  731. {
  732. lock_block<mt_policy> lock(this);
  733. connections_list::const_iterator it = m_connected_slots.begin();
  734. connections_list::const_iterator itEnd = m_connected_slots.end();
  735. while(it != itEnd)
  736. {
  737. (*it)->getdest()->signal_disconnect(this);
  738. delete *it;
  739. ++it;
  740. }
  741. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  742. }
  743. void disconnect(has_slots<mt_policy>* pclass)
  744. {
  745. lock_block<mt_policy> lock(this);
  746. connections_list::iterator it = m_connected_slots.begin();
  747. connections_list::iterator itEnd = m_connected_slots.end();
  748. while(it != itEnd)
  749. {
  750. if((*it)->getdest() == pclass)
  751. {
  752. delete *it;
  753. m_connected_slots.erase(it);
  754. pclass->signal_disconnect(this);
  755. return;
  756. }
  757. ++it;
  758. }
  759. }
  760. void slot_disconnect(has_slots<mt_policy>* pslot)
  761. {
  762. lock_block<mt_policy> lock(this);
  763. connections_list::iterator it = m_connected_slots.begin();
  764. connections_list::iterator itEnd = m_connected_slots.end();
  765. while(it != itEnd)
  766. {
  767. connections_list::iterator itNext = it;
  768. ++itNext;
  769. if((*it)->getdest() == pslot)
  770. {
  771. m_connected_slots.erase(it);
  772. // delete *it;
  773. }
  774. it = itNext;
  775. }
  776. }
  777. protected:
  778. connections_list m_connected_slots;
  779. };
  780. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy>
  781. class _signal_base4 : public _signal_base<mt_policy>
  782. {
  783. public:
  784. typedef std::list<_connection_base4<arg1_type, arg2_type, arg3_type,
  785. arg4_type, mt_policy> *> connections_list;
  786. _signal_base4()
  787. {
  788. ;
  789. }
  790. _signal_base4(const _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s)
  791. : _signal_base<mt_policy>(s)
  792. {
  793. lock_block<mt_policy> lock(this);
  794. connections_list::const_iterator it = s.m_connected_slots.begin();
  795. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  796. while(it != itEnd)
  797. {
  798. (*it)->getdest()->signal_connect(this);
  799. m_connected_slots.push_back((*it)->clone());
  800. ++it;
  801. }
  802. }
  803. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  804. {
  805. lock_block<mt_policy> lock(this);
  806. connections_list::iterator it = m_connected_slots.begin();
  807. connections_list::iterator itEnd = m_connected_slots.end();
  808. while(it != itEnd)
  809. {
  810. if((*it)->getdest() == oldtarget)
  811. {
  812. m_connected_slots.push_back((*it)->duplicate(newtarget));
  813. }
  814. ++it;
  815. }
  816. }
  817. ~_signal_base4()
  818. {
  819. disconnect_all();
  820. }
  821. void disconnect_all()
  822. {
  823. lock_block<mt_policy> lock(this);
  824. connections_list::const_iterator it = m_connected_slots.begin();
  825. connections_list::const_iterator itEnd = m_connected_slots.end();
  826. while(it != itEnd)
  827. {
  828. (*it)->getdest()->signal_disconnect(this);
  829. delete *it;
  830. ++it;
  831. }
  832. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  833. }
  834. void disconnect(has_slots<mt_policy>* pclass)
  835. {
  836. lock_block<mt_policy> lock(this);
  837. connections_list::iterator it = m_connected_slots.begin();
  838. connections_list::iterator itEnd = m_connected_slots.end();
  839. while(it != itEnd)
  840. {
  841. if((*it)->getdest() == pclass)
  842. {
  843. delete *it;
  844. m_connected_slots.erase(it);
  845. pclass->signal_disconnect(this);
  846. return;
  847. }
  848. ++it;
  849. }
  850. }
  851. void slot_disconnect(has_slots<mt_policy>* pslot)
  852. {
  853. lock_block<mt_policy> lock(this);
  854. connections_list::iterator it = m_connected_slots.begin();
  855. connections_list::iterator itEnd = m_connected_slots.end();
  856. while(it != itEnd)
  857. {
  858. connections_list::iterator itNext = it;
  859. ++itNext;
  860. if((*it)->getdest() == pslot)
  861. {
  862. m_connected_slots.erase(it);
  863. // delete *it;
  864. }
  865. it = itNext;
  866. }
  867. }
  868. protected:
  869. connections_list m_connected_slots;
  870. };
  871. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  872. class arg5_type, class mt_policy>
  873. class _signal_base5 : public _signal_base<mt_policy>
  874. {
  875. public:
  876. typedef std::list<_connection_base5<arg1_type, arg2_type, arg3_type,
  877. arg4_type, arg5_type, mt_policy> *> connections_list;
  878. _signal_base5()
  879. {
  880. ;
  881. }
  882. _signal_base5(const _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type,
  883. arg5_type, mt_policy>& s)
  884. : _signal_base<mt_policy>(s)
  885. {
  886. lock_block<mt_policy> lock(this);
  887. connections_list::const_iterator it = s.m_connected_slots.begin();
  888. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  889. while(it != itEnd)
  890. {
  891. (*it)->getdest()->signal_connect(this);
  892. m_connected_slots.push_back((*it)->clone());
  893. ++it;
  894. }
  895. }
  896. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  897. {
  898. lock_block<mt_policy> lock(this);
  899. connections_list::iterator it = m_connected_slots.begin();
  900. connections_list::iterator itEnd = m_connected_slots.end();
  901. while(it != itEnd)
  902. {
  903. if((*it)->getdest() == oldtarget)
  904. {
  905. m_connected_slots.push_back((*it)->duplicate(newtarget));
  906. }
  907. ++it;
  908. }
  909. }
  910. ~_signal_base5()
  911. {
  912. disconnect_all();
  913. }
  914. void disconnect_all()
  915. {
  916. lock_block<mt_policy> lock(this);
  917. connections_list::const_iterator it = m_connected_slots.begin();
  918. connections_list::const_iterator itEnd = m_connected_slots.end();
  919. while(it != itEnd)
  920. {
  921. (*it)->getdest()->signal_disconnect(this);
  922. delete *it;
  923. ++it;
  924. }
  925. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  926. }
  927. void disconnect(has_slots<mt_policy>* pclass)
  928. {
  929. lock_block<mt_policy> lock(this);
  930. connections_list::iterator it = m_connected_slots.begin();
  931. connections_list::iterator itEnd = m_connected_slots.end();
  932. while(it != itEnd)
  933. {
  934. if((*it)->getdest() == pclass)
  935. {
  936. delete *it;
  937. m_connected_slots.erase(it);
  938. pclass->signal_disconnect(this);
  939. return;
  940. }
  941. ++it;
  942. }
  943. }
  944. void slot_disconnect(has_slots<mt_policy>* pslot)
  945. {
  946. lock_block<mt_policy> lock(this);
  947. connections_list::iterator it = m_connected_slots.begin();
  948. connections_list::iterator itEnd = m_connected_slots.end();
  949. while(it != itEnd)
  950. {
  951. connections_list::iterator itNext = it;
  952. ++itNext;
  953. if((*it)->getdest() == pslot)
  954. {
  955. m_connected_slots.erase(it);
  956. // delete *it;
  957. }
  958. it = itNext;
  959. }
  960. }
  961. protected:
  962. connections_list m_connected_slots;
  963. };
  964. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  965. class arg5_type, class arg6_type, class mt_policy>
  966. class _signal_base6 : public _signal_base<mt_policy>
  967. {
  968. public:
  969. typedef std::list<_connection_base6<arg1_type, arg2_type, arg3_type,
  970. arg4_type, arg5_type, arg6_type, mt_policy> *> connections_list;
  971. _signal_base6()
  972. {
  973. ;
  974. }
  975. _signal_base6(const _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type,
  976. arg5_type, arg6_type, mt_policy>& s)
  977. : _signal_base<mt_policy>(s)
  978. {
  979. lock_block<mt_policy> lock(this);
  980. connections_list::const_iterator it = s.m_connected_slots.begin();
  981. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  982. while(it != itEnd)
  983. {
  984. (*it)->getdest()->signal_connect(this);
  985. m_connected_slots.push_back((*it)->clone());
  986. ++it;
  987. }
  988. }
  989. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  990. {
  991. lock_block<mt_policy> lock(this);
  992. connections_list::iterator it = m_connected_slots.begin();
  993. connections_list::iterator itEnd = m_connected_slots.end();
  994. while(it != itEnd)
  995. {
  996. if((*it)->getdest() == oldtarget)
  997. {
  998. m_connected_slots.push_back((*it)->duplicate(newtarget));
  999. }
  1000. ++it;
  1001. }
  1002. }
  1003. ~_signal_base6()
  1004. {
  1005. disconnect_all();
  1006. }
  1007. void disconnect_all()
  1008. {
  1009. lock_block<mt_policy> lock(this);
  1010. connections_list::const_iterator it = m_connected_slots.begin();
  1011. connections_list::const_iterator itEnd = m_connected_slots.end();
  1012. while(it != itEnd)
  1013. {
  1014. (*it)->getdest()->signal_disconnect(this);
  1015. delete *it;
  1016. ++it;
  1017. }
  1018. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  1019. }
  1020. void disconnect(has_slots<mt_policy>* pclass)
  1021. {
  1022. lock_block<mt_policy> lock(this);
  1023. connections_list::iterator it = m_connected_slots.begin();
  1024. connections_list::iterator itEnd = m_connected_slots.end();
  1025. while(it != itEnd)
  1026. {
  1027. if((*it)->getdest() == pclass)
  1028. {
  1029. delete *it;
  1030. m_connected_slots.erase(it);
  1031. pclass->signal_disconnect(this);
  1032. return;
  1033. }
  1034. ++it;
  1035. }
  1036. }
  1037. void slot_disconnect(has_slots<mt_policy>* pslot)
  1038. {
  1039. lock_block<mt_policy> lock(this);
  1040. connections_list::iterator it = m_connected_slots.begin();
  1041. connections_list::iterator itEnd = m_connected_slots.end();
  1042. while(it != itEnd)
  1043. {
  1044. connections_list::iterator itNext = it;
  1045. ++itNext;
  1046. if((*it)->getdest() == pslot)
  1047. {
  1048. m_connected_slots.erase(it);
  1049. // delete *it;
  1050. }
  1051. it = itNext;
  1052. }
  1053. }
  1054. protected:
  1055. connections_list m_connected_slots;
  1056. };
  1057. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  1058. class arg5_type, class arg6_type, class arg7_type, class mt_policy>
  1059. class _signal_base7 : public _signal_base<mt_policy>
  1060. {
  1061. public:
  1062. typedef std::list<_connection_base7<arg1_type, arg2_type, arg3_type,
  1063. arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> *> connections_list;
  1064. _signal_base7()
  1065. {
  1066. ;
  1067. }
  1068. _signal_base7(const _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type,
  1069. arg5_type, arg6_type, arg7_type, mt_policy>& s)
  1070. : _signal_base<mt_policy>(s)
  1071. {
  1072. lock_block<mt_policy> lock(this);
  1073. connections_list::const_iterator it = s.m_connected_slots.begin();
  1074. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  1075. while(it != itEnd)
  1076. {
  1077. (*it)->getdest()->signal_connect(this);
  1078. m_connected_slots.push_back((*it)->clone());
  1079. ++it;
  1080. }
  1081. }
  1082. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  1083. {
  1084. lock_block<mt_policy> lock(this);
  1085. connections_list::iterator it = m_connected_slots.begin();
  1086. connections_list::iterator itEnd = m_connected_slots.end();
  1087. while(it != itEnd)
  1088. {
  1089. if((*it)->getdest() == oldtarget)
  1090. {
  1091. m_connected_slots.push_back((*it)->duplicate(newtarget));
  1092. }
  1093. ++it;
  1094. }
  1095. }
  1096. ~_signal_base7()
  1097. {
  1098. disconnect_all();
  1099. }
  1100. void disconnect_all()
  1101. {
  1102. lock_block<mt_policy> lock(this);
  1103. connections_list::const_iterator it = m_connected_slots.begin();
  1104. connections_list::const_iterator itEnd = m_connected_slots.end();
  1105. while(it != itEnd)
  1106. {
  1107. (*it)->getdest()->signal_disconnect(this);
  1108. delete *it;
  1109. ++it;
  1110. }
  1111. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  1112. }
  1113. void disconnect(has_slots<mt_policy>* pclass)
  1114. {
  1115. lock_block<mt_policy> lock(this);
  1116. connections_list::iterator it = m_connected_slots.begin();
  1117. connections_list::iterator itEnd = m_connected_slots.end();
  1118. while(it != itEnd)
  1119. {
  1120. if((*it)->getdest() == pclass)
  1121. {
  1122. delete *it;
  1123. m_connected_slots.erase(it);
  1124. pclass->signal_disconnect(this);
  1125. return;
  1126. }
  1127. ++it;
  1128. }
  1129. }
  1130. void slot_disconnect(has_slots<mt_policy>* pslot)
  1131. {
  1132. lock_block<mt_policy> lock(this);
  1133. connections_list::iterator it = m_connected_slots.begin();
  1134. connections_list::iterator itEnd = m_connected_slots.end();
  1135. while(it != itEnd)
  1136. {
  1137. connections_list::iterator itNext = it;
  1138. ++itNext;
  1139. if((*it)->getdest() == pslot)
  1140. {
  1141. m_connected_slots.erase(it);
  1142. // delete *it;
  1143. }
  1144. it = itNext;
  1145. }
  1146. }
  1147. protected:
  1148. connections_list m_connected_slots;
  1149. };
  1150. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  1151. class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy>
  1152. class _signal_base8 : public _signal_base<mt_policy>
  1153. {
  1154. public:
  1155. typedef std::list<_connection_base8<arg1_type, arg2_type, arg3_type,
  1156. arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> *>
  1157. connections_list;
  1158. _signal_base8()
  1159. {
  1160. ;
  1161. }
  1162. _signal_base8(const _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type,
  1163. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>& s)
  1164. : _signal_base<mt_policy>(s)
  1165. {
  1166. lock_block<mt_policy> lock(this);
  1167. connections_list::const_iterator it = s.m_connected_slots.begin();
  1168. connections_list::const_iterator itEnd = s.m_connected_slots.end();
  1169. while(it != itEnd)
  1170. {
  1171. (*it)->getdest()->signal_connect(this);
  1172. m_connected_slots.push_back((*it)->clone());
  1173. ++it;
  1174. }
  1175. }
  1176. void slot_duplicate(const has_slots<mt_policy>* oldtarget, has_slots<mt_policy>* newtarget)
  1177. {
  1178. lock_block<mt_policy> lock(this);
  1179. connections_list::iterator it = m_connected_slots.begin();
  1180. connections_list::iterator itEnd = m_connected_slots.end();
  1181. while(it != itEnd)
  1182. {
  1183. if((*it)->getdest() == oldtarget)
  1184. {
  1185. m_connected_slots.push_back((*it)->duplicate(newtarget));
  1186. }
  1187. ++it;
  1188. }
  1189. }
  1190. ~_signal_base8()
  1191. {
  1192. disconnect_all();
  1193. }
  1194. void disconnect_all()
  1195. {
  1196. lock_block<mt_policy> lock(this);
  1197. connections_list::const_iterator it = m_connected_slots.begin();
  1198. connections_list::const_iterator itEnd = m_connected_slots.end();
  1199. while(it != itEnd)
  1200. {
  1201. (*it)->getdest()->signal_disconnect(this);
  1202. delete *it;
  1203. ++it;
  1204. }
  1205. m_connected_slots.erase(m_connected_slots.begin(), m_connected_slots.end());
  1206. }
  1207. void disconnect(has_slots<mt_policy>* pclass)
  1208. {
  1209. lock_block<mt_policy> lock(this);
  1210. connections_list::iterator it = m_connected_slots.begin();
  1211. connections_list::iterator itEnd = m_connected_slots.end();
  1212. while(it != itEnd)
  1213. {
  1214. if((*it)->getdest() == pclass)
  1215. {
  1216. delete *it;
  1217. m_connected_slots.erase(it);
  1218. pclass->signal_disconnect(this);
  1219. return;
  1220. }
  1221. ++it;
  1222. }
  1223. }
  1224. void slot_disconnect(has_slots<mt_policy>* pslot)
  1225. {
  1226. lock_block<mt_policy> lock(this);
  1227. connections_list::iterator it = m_connected_slots.begin();
  1228. connections_list::iterator itEnd = m_connected_slots.end();
  1229. while(it != itEnd)
  1230. {
  1231. connections_list::iterator itNext = it;
  1232. ++itNext;
  1233. if((*it)->getdest() == pslot)
  1234. {
  1235. m_connected_slots.erase(it);
  1236. // delete *it;
  1237. }
  1238. it = itNext;
  1239. }
  1240. }
  1241. protected:
  1242. connections_list m_connected_slots;
  1243. };
  1244. template<class dest_type, class mt_policy>
  1245. class _connection0 : public _connection_base0<mt_policy>
  1246. {
  1247. public:
  1248. _connection0()
  1249. {
  1250. pobject = NULL;
  1251. pmemfun = NULL;
  1252. }
  1253. _connection0(dest_type* pobject, void (dest_type::*pmemfun)())
  1254. {
  1255. m_pobject = pobject;
  1256. m_pmemfun = pmemfun;
  1257. }
  1258. virtual _connection_base0<mt_policy>* clone()
  1259. {
  1260. return new _connection0<dest_type, mt_policy>(*this);
  1261. }
  1262. virtual _connection_base0<mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1263. {
  1264. return new _connection0<dest_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1265. }
  1266. virtual void emit()
  1267. {
  1268. (m_pobject->*m_pmemfun)();
  1269. }
  1270. virtual has_slots<mt_policy>* getdest() const
  1271. {
  1272. return m_pobject;
  1273. }
  1274. private:
  1275. dest_type* m_pobject;
  1276. void (dest_type::* m_pmemfun)();
  1277. };
  1278. template<class dest_type, class arg1_type, class mt_policy>
  1279. class _connection1 : public _connection_base1<arg1_type, mt_policy>
  1280. {
  1281. public:
  1282. _connection1()
  1283. {
  1284. pobject = NULL;
  1285. pmemfun = NULL;
  1286. }
  1287. _connection1(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type))
  1288. {
  1289. m_pobject = pobject;
  1290. m_pmemfun = pmemfun;
  1291. }
  1292. virtual _connection_base1<arg1_type, mt_policy>* clone()
  1293. {
  1294. return new _connection1<dest_type, arg1_type, mt_policy>(*this);
  1295. }
  1296. virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1297. {
  1298. return new _connection1<dest_type, arg1_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1299. }
  1300. virtual void emit(arg1_type a1)
  1301. {
  1302. (m_pobject->*m_pmemfun)(a1);
  1303. }
  1304. virtual has_slots<mt_policy>* getdest() const
  1305. {
  1306. return m_pobject;
  1307. }
  1308. private:
  1309. dest_type* m_pobject;
  1310. void (dest_type::* m_pmemfun)(arg1_type);
  1311. };
  1312. template<class dest_type, class arg1_type, class arg2_type, class mt_policy>
  1313. class _connection2 : public _connection_base2<arg1_type, arg2_type, mt_policy>
  1314. {
  1315. public:
  1316. _connection2()
  1317. {
  1318. pobject = NULL;
  1319. pmemfun = NULL;
  1320. }
  1321. _connection2(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1322. arg2_type))
  1323. {
  1324. m_pobject = pobject;
  1325. m_pmemfun = pmemfun;
  1326. }
  1327. virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clone()
  1328. {
  1329. return new _connection2<dest_type, arg1_type, arg2_type, mt_policy>(*this);
  1330. }
  1331. virtual _connection_base2<arg1_type, arg2_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1332. {
  1333. return new _connection2<dest_type, arg1_type, arg2_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1334. }
  1335. virtual void emit(arg1_type a1, arg2_type a2)
  1336. {
  1337. (m_pobject->*m_pmemfun)(a1, a2);
  1338. }
  1339. virtual has_slots<mt_policy>* getdest() const
  1340. {
  1341. return m_pobject;
  1342. }
  1343. private:
  1344. dest_type* m_pobject;
  1345. void (dest_type::* m_pmemfun)(arg1_type, arg2_type);
  1346. };
  1347. template<class dest_type, class arg1_type, class arg2_type, class arg3_type, class mt_policy>
  1348. class _connection3 : public _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>
  1349. {
  1350. public:
  1351. _connection3()
  1352. {
  1353. pobject = NULL;
  1354. pmemfun = NULL;
  1355. }
  1356. _connection3(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1357. arg2_type, arg3_type))
  1358. {
  1359. m_pobject = pobject;
  1360. m_pmemfun = pmemfun;
  1361. }
  1362. virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* clone()
  1363. {
  1364. return new _connection3<dest_type, arg1_type, arg2_type, arg3_type, mt_policy>(*this);
  1365. }
  1366. virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1367. {
  1368. return new _connection3<dest_type, arg1_type, arg2_type, arg3_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1369. }
  1370. virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3)
  1371. {
  1372. (m_pobject->*m_pmemfun)(a1, a2, a3);
  1373. }
  1374. virtual has_slots<mt_policy>* getdest() const
  1375. {
  1376. return m_pobject;
  1377. }
  1378. private:
  1379. dest_type* m_pobject;
  1380. void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type);
  1381. };
  1382. template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
  1383. class arg4_type, class mt_policy>
  1384. class _connection4 : public _connection_base4<arg1_type, arg2_type,
  1385. arg3_type, arg4_type, mt_policy>
  1386. {
  1387. public:
  1388. _connection4()
  1389. {
  1390. pobject = NULL;
  1391. pmemfun = NULL;
  1392. }
  1393. _connection4(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1394. arg2_type, arg3_type, arg4_type))
  1395. {
  1396. m_pobject = pobject;
  1397. m_pmemfun = pmemfun;
  1398. }
  1399. virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* clone()
  1400. {
  1401. return new _connection4<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(*this);
  1402. }
  1403. virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1404. {
  1405. return new _connection4<dest_type, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1406. }
  1407. virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3,
  1408. arg4_type a4)
  1409. {
  1410. (m_pobject->*m_pmemfun)(a1, a2, a3, a4);
  1411. }
  1412. virtual has_slots<mt_policy>* getdest() const
  1413. {
  1414. return m_pobject;
  1415. }
  1416. private:
  1417. dest_type* m_pobject;
  1418. void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type,
  1419. arg4_type);
  1420. };
  1421. template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
  1422. class arg4_type, class arg5_type, class mt_policy>
  1423. class _connection5 : public _connection_base5<arg1_type, arg2_type,
  1424. arg3_type, arg4_type, arg5_type, mt_policy>
  1425. {
  1426. public:
  1427. _connection5()
  1428. {
  1429. pobject = NULL;
  1430. pmemfun = NULL;
  1431. }
  1432. _connection5(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1433. arg2_type, arg3_type, arg4_type, arg5_type))
  1434. {
  1435. m_pobject = pobject;
  1436. m_pmemfun = pmemfun;
  1437. }
  1438. virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
  1439. arg5_type, mt_policy>* clone()
  1440. {
  1441. return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1442. arg5_type, mt_policy>(*this);
  1443. }
  1444. virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_type,
  1445. arg5_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1446. {
  1447. return new _connection5<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1448. arg5_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1449. }
  1450. virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1451. arg5_type a5)
  1452. {
  1453. (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5);
  1454. }
  1455. virtual has_slots<mt_policy>* getdest() const
  1456. {
  1457. return m_pobject;
  1458. }
  1459. private:
  1460. dest_type* m_pobject;
  1461. void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
  1462. arg5_type);
  1463. };
  1464. template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
  1465. class arg4_type, class arg5_type, class arg6_type, class mt_policy>
  1466. class _connection6 : public _connection_base6<arg1_type, arg2_type,
  1467. arg3_type, arg4_type, arg5_type, arg6_type, mt_policy>
  1468. {
  1469. public:
  1470. _connection6()
  1471. {
  1472. pobject = NULL;
  1473. pmemfun = NULL;
  1474. }
  1475. _connection6(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1476. arg2_type, arg3_type, arg4_type, arg5_type, arg6_type))
  1477. {
  1478. m_pobject = pobject;
  1479. m_pmemfun = pmemfun;
  1480. }
  1481. virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
  1482. arg5_type, arg6_type, mt_policy>* clone()
  1483. {
  1484. return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1485. arg5_type, arg6_type, mt_policy>(*this);
  1486. }
  1487. virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_type,
  1488. arg5_type, arg6_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1489. {
  1490. return new _connection6<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1491. arg5_type, arg6_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1492. }
  1493. virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1494. arg5_type a5, arg6_type a6)
  1495. {
  1496. (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6);
  1497. }
  1498. virtual has_slots<mt_policy>* getdest() const
  1499. {
  1500. return m_pobject;
  1501. }
  1502. private:
  1503. dest_type* m_pobject;
  1504. void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
  1505. arg5_type, arg6_type);
  1506. };
  1507. template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
  1508. class arg4_type, class arg5_type, class arg6_type, class arg7_type, class mt_policy>
  1509. class _connection7 : public _connection_base7<arg1_type, arg2_type,
  1510. arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>
  1511. {
  1512. public:
  1513. _connection7()
  1514. {
  1515. pobject = NULL;
  1516. pmemfun = NULL;
  1517. }
  1518. _connection7(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1519. arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, arg7_type))
  1520. {
  1521. m_pobject = pobject;
  1522. m_pmemfun = pmemfun;
  1523. }
  1524. virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
  1525. arg5_type, arg6_type, arg7_type, mt_policy>* clone()
  1526. {
  1527. return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1528. arg5_type, arg6_type, arg7_type, mt_policy>(*this);
  1529. }
  1530. virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_type,
  1531. arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1532. {
  1533. return new _connection7<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1534. arg5_type, arg6_type, arg7_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1535. }
  1536. virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1537. arg5_type a5, arg6_type a6, arg7_type a7)
  1538. {
  1539. (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7);
  1540. }
  1541. virtual has_slots<mt_policy>* getdest() const
  1542. {
  1543. return m_pobject;
  1544. }
  1545. private:
  1546. dest_type* m_pobject;
  1547. void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
  1548. arg5_type, arg6_type, arg7_type);
  1549. };
  1550. template<class dest_type, class arg1_type, class arg2_type, class arg3_type,
  1551. class arg4_type, class arg5_type, class arg6_type, class arg7_type,
  1552. class arg8_type, class mt_policy>
  1553. class _connection8 : public _connection_base8<arg1_type, arg2_type,
  1554. arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>
  1555. {
  1556. public:
  1557. _connection8()
  1558. {
  1559. pobject = NULL;
  1560. pmemfun = NULL;
  1561. }
  1562. _connection8(dest_type* pobject, void (dest_type::*pmemfun)(arg1_type,
  1563. arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
  1564. arg7_type, arg8_type))
  1565. {
  1566. m_pobject = pobject;
  1567. m_pmemfun = pmemfun;
  1568. }
  1569. virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
  1570. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* clone()
  1571. {
  1572. return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1573. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(*this);
  1574. }
  1575. virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_type,
  1576. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* duplicate(has_slots<mt_policy>* pnewdest)
  1577. {
  1578. return new _connection8<dest_type, arg1_type, arg2_type, arg3_type, arg4_type,
  1579. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>((dest_type *)pnewdest, m_pmemfun);
  1580. }
  1581. virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1582. arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
  1583. {
  1584. (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8);
  1585. }
  1586. virtual has_slots<mt_policy>* getdest() const
  1587. {
  1588. return m_pobject;
  1589. }
  1590. private:
  1591. dest_type* m_pobject;
  1592. void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, arg4_type,
  1593. arg5_type, arg6_type, arg7_type, arg8_type);
  1594. };
  1595. template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1596. class signal0 : public _signal_base0<mt_policy>
  1597. {
  1598. public:
  1599. signal0()
  1600. {
  1601. ;
  1602. }
  1603. signal0(const signal0<mt_policy>& s)
  1604. : _signal_base0<mt_policy>(s)
  1605. {
  1606. ;
  1607. }
  1608. template<class desttype>
  1609. void connect(desttype* pclass, void (desttype::*pmemfun)())
  1610. {
  1611. lock_block<mt_policy> lock(this);
  1612. _connection0<desttype, mt_policy>* conn =
  1613. new _connection0<desttype, mt_policy>(pclass, pmemfun);
  1614. m_connected_slots.push_back(conn);
  1615. pclass->signal_connect(this);
  1616. }
  1617. void emit()
  1618. {
  1619. lock_block<mt_policy> lock(this);
  1620. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1621. connections_list::const_iterator itEnd = m_connected_slots.end();
  1622. while(it != itEnd)
  1623. {
  1624. itNext = it;
  1625. ++itNext;
  1626. (*it)->emit();
  1627. it = itNext;
  1628. }
  1629. }
  1630. void operator()()
  1631. {
  1632. lock_block<mt_policy> lock(this);
  1633. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1634. connections_list::const_iterator itEnd = m_connected_slots.end();
  1635. while(it != itEnd)
  1636. {
  1637. itNext = it;
  1638. ++itNext;
  1639. (*it)->emit();
  1640. it = itNext;
  1641. }
  1642. }
  1643. };
  1644. template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1645. class signal1 : public _signal_base1<arg1_type, mt_policy>
  1646. {
  1647. public:
  1648. signal1()
  1649. {
  1650. ;
  1651. }
  1652. signal1(const signal1<arg1_type, mt_policy>& s)
  1653. : _signal_base1<arg1_type, mt_policy>(s)
  1654. {
  1655. ;
  1656. }
  1657. template<class desttype>
  1658. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type))
  1659. {
  1660. lock_block<mt_policy> lock(this);
  1661. _connection1<desttype, arg1_type, mt_policy>* conn =
  1662. new _connection1<desttype, arg1_type, mt_policy>(pclass, pmemfun);
  1663. m_connected_slots.push_back(conn);
  1664. pclass->signal_connect(this);
  1665. }
  1666. void emit(arg1_type a1)
  1667. {
  1668. lock_block<mt_policy> lock(this);
  1669. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1670. connections_list::const_iterator itEnd = m_connected_slots.end();
  1671. while(it != itEnd)
  1672. {
  1673. itNext = it;
  1674. ++itNext;
  1675. (*it)->emit(a1);
  1676. it = itNext;
  1677. }
  1678. }
  1679. void operator()(arg1_type a1)
  1680. {
  1681. lock_block<mt_policy> lock(this);
  1682. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1683. connections_list::const_iterator itEnd = m_connected_slots.end();
  1684. while(it != itEnd)
  1685. {
  1686. itNext = it;
  1687. ++itNext;
  1688. (*it)->emit(a1);
  1689. it = itNext;
  1690. }
  1691. }
  1692. };
  1693. template<class arg1_type, class arg2_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1694. class signal2 : public _signal_base2<arg1_type, arg2_type, mt_policy>
  1695. {
  1696. public:
  1697. signal2()
  1698. {
  1699. ;
  1700. }
  1701. signal2(const signal2<arg1_type, arg2_type, mt_policy>& s)
  1702. : _signal_base2<arg1_type, arg2_type, mt_policy>(s)
  1703. {
  1704. ;
  1705. }
  1706. template<class desttype>
  1707. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  1708. arg2_type))
  1709. {
  1710. lock_block<mt_policy> lock(this);
  1711. _connection2<desttype, arg1_type, arg2_type, mt_policy>* conn = new
  1712. _connection2<desttype, arg1_type, arg2_type, mt_policy>(pclass, pmemfun);
  1713. m_connected_slots.push_back(conn);
  1714. pclass->signal_connect(this);
  1715. }
  1716. void emit(arg1_type a1, arg2_type a2)
  1717. {
  1718. lock_block<mt_policy> lock(this);
  1719. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1720. connections_list::const_iterator itEnd = m_connected_slots.end();
  1721. while(it != itEnd)
  1722. {
  1723. itNext = it;
  1724. ++itNext;
  1725. (*it)->emit(a1, a2);
  1726. it = itNext;
  1727. }
  1728. }
  1729. void operator()(arg1_type a1, arg2_type a2)
  1730. {
  1731. lock_block<mt_policy> lock(this);
  1732. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1733. connections_list::const_iterator itEnd = m_connected_slots.end();
  1734. while(it != itEnd)
  1735. {
  1736. itNext = it;
  1737. ++itNext;
  1738. (*it)->emit(a1, a2);
  1739. it = itNext;
  1740. }
  1741. }
  1742. };
  1743. template<class arg1_type, class arg2_type, class arg3_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1744. class signal3 : public _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>
  1745. {
  1746. public:
  1747. signal3()
  1748. {
  1749. ;
  1750. }
  1751. signal3(const signal3<arg1_type, arg2_type, arg3_type, mt_policy>& s)
  1752. : _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy>(s)
  1753. {
  1754. ;
  1755. }
  1756. template<class desttype>
  1757. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  1758. arg2_type, arg3_type))
  1759. {
  1760. lock_block<mt_policy> lock(this);
  1761. _connection3<desttype, arg1_type, arg2_type, arg3_type, mt_policy>* conn =
  1762. new _connection3<desttype, arg1_type, arg2_type, arg3_type, mt_policy>(pclass,
  1763. pmemfun);
  1764. m_connected_slots.push_back(conn);
  1765. pclass->signal_connect(this);
  1766. }
  1767. void emit(arg1_type a1, arg2_type a2, arg3_type a3)
  1768. {
  1769. lock_block<mt_policy> lock(this);
  1770. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1771. connections_list::const_iterator itEnd = m_connected_slots.end();
  1772. while(it != itEnd)
  1773. {
  1774. itNext = it;
  1775. ++itNext;
  1776. (*it)->emit(a1, a2, a3);
  1777. it = itNext;
  1778. }
  1779. }
  1780. void operator()(arg1_type a1, arg2_type a2, arg3_type a3)
  1781. {
  1782. lock_block<mt_policy> lock(this);
  1783. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1784. connections_list::const_iterator itEnd = m_connected_slots.end();
  1785. while(it != itEnd)
  1786. {
  1787. itNext = it;
  1788. ++itNext;
  1789. (*it)->emit(a1, a2, a3);
  1790. it = itNext;
  1791. }
  1792. }
  1793. };
  1794. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1795. class signal4 : public _signal_base4<arg1_type, arg2_type, arg3_type,
  1796. arg4_type, mt_policy>
  1797. {
  1798. public:
  1799. signal4()
  1800. {
  1801. ;
  1802. }
  1803. signal4(const signal4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>& s)
  1804. : _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>(s)
  1805. {
  1806. ;
  1807. }
  1808. template<class desttype>
  1809. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  1810. arg2_type, arg3_type, arg4_type))
  1811. {
  1812. lock_block<mt_policy> lock(this);
  1813. _connection4<desttype, arg1_type, arg2_type, arg3_type, arg4_type, mt_policy>*
  1814. conn = new _connection4<desttype, arg1_type, arg2_type, arg3_type,
  1815. arg4_type, mt_policy>(pclass, pmemfun);
  1816. m_connected_slots.push_back(conn);
  1817. pclass->signal_connect(this);
  1818. }
  1819. void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
  1820. {
  1821. lock_block<mt_policy> lock(this);
  1822. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1823. connections_list::const_iterator itEnd = m_connected_slots.end();
  1824. while(it != itEnd)
  1825. {
  1826. itNext = it;
  1827. ++itNext;
  1828. (*it)->emit(a1, a2, a3, a4);
  1829. it = itNext;
  1830. }
  1831. }
  1832. void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
  1833. {
  1834. lock_block<mt_policy> lock(this);
  1835. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1836. connections_list::const_iterator itEnd = m_connected_slots.end();
  1837. while(it != itEnd)
  1838. {
  1839. itNext = it;
  1840. ++itNext;
  1841. (*it)->emit(a1, a2, a3, a4);
  1842. it = itNext;
  1843. }
  1844. }
  1845. };
  1846. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  1847. class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1848. class signal5 : public _signal_base5<arg1_type, arg2_type, arg3_type,
  1849. arg4_type, arg5_type, mt_policy>
  1850. {
  1851. public:
  1852. signal5()
  1853. {
  1854. ;
  1855. }
  1856. signal5(const signal5<arg1_type, arg2_type, arg3_type, arg4_type,
  1857. arg5_type, mt_policy>& s)
  1858. : _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type,
  1859. arg5_type, mt_policy>(s)
  1860. {
  1861. ;
  1862. }
  1863. template<class desttype>
  1864. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  1865. arg2_type, arg3_type, arg4_type, arg5_type))
  1866. {
  1867. lock_block<mt_policy> lock(this);
  1868. _connection5<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
  1869. arg5_type, mt_policy>* conn = new _connection5<desttype, arg1_type, arg2_type,
  1870. arg3_type, arg4_type, arg5_type, mt_policy>(pclass, pmemfun);
  1871. m_connected_slots.push_back(conn);
  1872. pclass->signal_connect(this);
  1873. }
  1874. void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1875. arg5_type a5)
  1876. {
  1877. lock_block<mt_policy> lock(this);
  1878. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1879. connections_list::const_iterator itEnd = m_connected_slots.end();
  1880. while(it != itEnd)
  1881. {
  1882. itNext = it;
  1883. ++itNext;
  1884. (*it)->emit(a1, a2, a3, a4, a5);
  1885. it = itNext;
  1886. }
  1887. }
  1888. void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1889. arg5_type a5)
  1890. {
  1891. lock_block<mt_policy> lock(this);
  1892. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1893. connections_list::const_iterator itEnd = m_connected_slots.end();
  1894. while(it != itEnd)
  1895. {
  1896. itNext = it;
  1897. ++itNext;
  1898. (*it)->emit(a1, a2, a3, a4, a5);
  1899. it = itNext;
  1900. }
  1901. }
  1902. };
  1903. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  1904. class arg5_type, class arg6_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1905. class signal6 : public _signal_base6<arg1_type, arg2_type, arg3_type,
  1906. arg4_type, arg5_type, arg6_type, mt_policy>
  1907. {
  1908. public:
  1909. signal6()
  1910. {
  1911. ;
  1912. }
  1913. signal6(const signal6<arg1_type, arg2_type, arg3_type, arg4_type,
  1914. arg5_type, arg6_type, mt_policy>& s)
  1915. : _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type,
  1916. arg5_type, arg6_type, mt_policy>(s)
  1917. {
  1918. ;
  1919. }
  1920. template<class desttype>
  1921. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  1922. arg2_type, arg3_type, arg4_type, arg5_type, arg6_type))
  1923. {
  1924. lock_block<mt_policy> lock(this);
  1925. _connection6<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
  1926. arg5_type, arg6_type, mt_policy>* conn =
  1927. new _connection6<desttype, arg1_type, arg2_type, arg3_type,
  1928. arg4_type, arg5_type, arg6_type, mt_policy>(pclass, pmemfun);
  1929. m_connected_slots.push_back(conn);
  1930. pclass->signal_connect(this);
  1931. }
  1932. void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1933. arg5_type a5, arg6_type a6)
  1934. {
  1935. lock_block<mt_policy> lock(this);
  1936. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1937. connections_list::const_iterator itEnd = m_connected_slots.end();
  1938. while(it != itEnd)
  1939. {
  1940. itNext = it;
  1941. ++itNext;
  1942. (*it)->emit(a1, a2, a3, a4, a5, a6);
  1943. it = itNext;
  1944. }
  1945. }
  1946. void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1947. arg5_type a5, arg6_type a6)
  1948. {
  1949. lock_block<mt_policy> lock(this);
  1950. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1951. connections_list::const_iterator itEnd = m_connected_slots.end();
  1952. while(it != itEnd)
  1953. {
  1954. itNext = it;
  1955. ++itNext;
  1956. (*it)->emit(a1, a2, a3, a4, a5, a6);
  1957. it = itNext;
  1958. }
  1959. }
  1960. };
  1961. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  1962. class arg5_type, class arg6_type, class arg7_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  1963. class signal7 : public _signal_base7<arg1_type, arg2_type, arg3_type,
  1964. arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>
  1965. {
  1966. public:
  1967. signal7()
  1968. {
  1969. ;
  1970. }
  1971. signal7(const signal7<arg1_type, arg2_type, arg3_type, arg4_type,
  1972. arg5_type, arg6_type, arg7_type, mt_policy>& s)
  1973. : _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type,
  1974. arg5_type, arg6_type, arg7_type, mt_policy>(s)
  1975. {
  1976. ;
  1977. }
  1978. template<class desttype>
  1979. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  1980. arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
  1981. arg7_type))
  1982. {
  1983. lock_block<mt_policy> lock(this);
  1984. _connection7<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
  1985. arg5_type, arg6_type, arg7_type, mt_policy>* conn =
  1986. new _connection7<desttype, arg1_type, arg2_type, arg3_type,
  1987. arg4_type, arg5_type, arg6_type, arg7_type, mt_policy>(pclass, pmemfun);
  1988. m_connected_slots.push_back(conn);
  1989. pclass->signal_connect(this);
  1990. }
  1991. void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  1992. arg5_type a5, arg6_type a6, arg7_type a7)
  1993. {
  1994. lock_block<mt_policy> lock(this);
  1995. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  1996. connections_list::const_iterator itEnd = m_connected_slots.end();
  1997. while(it != itEnd)
  1998. {
  1999. itNext = it;
  2000. ++itNext;
  2001. (*it)->emit(a1, a2, a3, a4, a5, a6, a7);
  2002. it = itNext;
  2003. }
  2004. }
  2005. void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  2006. arg5_type a5, arg6_type a6, arg7_type a7)
  2007. {
  2008. lock_block<mt_policy> lock(this);
  2009. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  2010. connections_list::const_iterator itEnd = m_connected_slots.end();
  2011. while(it != itEnd)
  2012. {
  2013. itNext = it;
  2014. ++itNext;
  2015. (*it)->emit(a1, a2, a3, a4, a5, a6, a7);
  2016. it = itNext;
  2017. }
  2018. }
  2019. };
  2020. template<class arg1_type, class arg2_type, class arg3_type, class arg4_type,
  2021. class arg5_type, class arg6_type, class arg7_type, class arg8_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
  2022. class signal8 : public _signal_base8<arg1_type, arg2_type, arg3_type,
  2023. arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>
  2024. {
  2025. public:
  2026. signal8()
  2027. {
  2028. ;
  2029. }
  2030. signal8(const signal8<arg1_type, arg2_type, arg3_type, arg4_type,
  2031. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>& s)
  2032. : _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type,
  2033. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(s)
  2034. {
  2035. ;
  2036. }
  2037. template<class desttype>
  2038. void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_type,
  2039. arg2_type, arg3_type, arg4_type, arg5_type, arg6_type,
  2040. arg7_type, arg8_type))
  2041. {
  2042. lock_block<mt_policy> lock(this);
  2043. _connection8<desttype, arg1_type, arg2_type, arg3_type, arg4_type,
  2044. arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>* conn =
  2045. new _connection8<desttype, arg1_type, arg2_type, arg3_type,
  2046. arg4_type, arg5_type, arg6_type, arg7_type,
  2047. arg8_type, mt_policy>(pclass, pmemfun);
  2048. m_connected_slots.push_back(conn);
  2049. pclass->signal_connect(this);
  2050. }
  2051. void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  2052. arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
  2053. {
  2054. lock_block<mt_policy> lock(this);
  2055. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  2056. connections_list::const_iterator itEnd = m_connected_slots.end();
  2057. while(it != itEnd)
  2058. {
  2059. itNext = it;
  2060. ++itNext;
  2061. (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8);
  2062. it = itNext;
  2063. }
  2064. }
  2065. void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4,
  2066. arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8)
  2067. {
  2068. lock_block<mt_policy> lock(this);
  2069. connections_list::const_iterator itNext, it = m_connected_slots.begin();
  2070. connections_list::const_iterator itEnd = m_connected_slots.end();
  2071. while(it != itEnd)
  2072. {
  2073. itNext = it;
  2074. ++itNext;
  2075. (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8);
  2076. it = itNext;
  2077. }
  2078. }
  2079. };
  2080. }; // namespace sigslot
  2081. #endif // SIGSLOT_H__