| OLD | NEW |
| 1 // sigslot.h: Signal/Slot classes | 1 // sigslot.h: Signal/Slot classes |
| 2 // | 2 // |
| 3 // Written by Sarah Thompson (sarah@telergy.com) 2002. | 3 // Written by Sarah Thompson (sarah@telergy.com) 2002. |
| 4 // | 4 // |
| 5 // License: Public domain. You are free to use this code however you like, with
the proviso that | 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. | 6 // the author takes on no responsibility or liability for any use. |
| 7 // | 7 // |
| 8 // QUICK DOCUMENTATION | 8 // QUICK DOCUMENTATION |
| 9 // | 9 // |
| 10 // (see also the full documentation at http://sigsl
ot.sourceforge.net/) | 10 // (see also the full documentation at http://sigsl
ot.sourceforge.net/) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local | 116 # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local |
| 117 # endif | 117 # endif |
| 118 #endif | 118 #endif |
| 119 | 119 |
| 120 // TODO: change this namespace to rtc? | 120 // TODO: change this namespace to rtc? |
| 121 namespace sigslot { | 121 namespace sigslot { |
| 122 | 122 |
| 123 class single_threaded | 123 class single_threaded |
| 124 { | 124 { |
| 125 public: | 125 public: |
| 126 » » single_threaded() | 126 » » void lock() {} |
| 127 » » { | 127 » » void unlock() {} |
| 128 » » » ; | 128 » }; |
| 129 » » } | |
| 130 | |
| 131 virtual ~single_threaded() {} | |
| 132 | |
| 133 virtual void lock() {} | |
| 134 | |
| 135 virtual void unlock() {} | |
| 136 }; | |
| 137 | 129 |
| 138 #ifdef _SIGSLOT_HAS_WIN32_THREADS | 130 #ifdef _SIGSLOT_HAS_WIN32_THREADS |
| 139 // The multi threading policies only get compiled in if they are enabled
. | 131 // The multi threading policies only get compiled in if they are enabled
. |
| 140 class multi_threaded_global | 132 class multi_threaded_global |
| 141 { | 133 { |
| 142 public: | 134 public: |
| 143 multi_threaded_global() | 135 multi_threaded_global() |
| 144 { | 136 { |
| 145 static bool isinitialised = false; | 137 static bool isinitialised = false; |
| 146 | 138 |
| 147 if(!isinitialised) | 139 if(!isinitialised) |
| 148 { | 140 { |
| 149 InitializeCriticalSection(get_critsec()); | 141 InitializeCriticalSection(get_critsec()); |
| 150 isinitialised = true; | 142 isinitialised = true; |
| 151 } | 143 } |
| 152 } | 144 } |
| 153 | 145 |
| 154 » » multi_threaded_global(const multi_threaded_global&) | 146 » » void lock() |
| 155 » » { | |
| 156 » » » ; | |
| 157 » » } | |
| 158 | |
| 159 » » virtual ~multi_threaded_global() | |
| 160 » » { | |
| 161 » » » ; | |
| 162 » » } | |
| 163 | |
| 164 » » virtual void lock() | |
| 165 { | 147 { |
| 166 EnterCriticalSection(get_critsec()); | 148 EnterCriticalSection(get_critsec()); |
| 167 } | 149 } |
| 168 | 150 |
| 169 » » virtual void unlock() | 151 » » void unlock() |
| 170 { | 152 { |
| 171 LeaveCriticalSection(get_critsec()); | 153 LeaveCriticalSection(get_critsec()); |
| 172 } | 154 } |
| 173 | 155 |
| 174 private: | 156 private: |
| 175 CRITICAL_SECTION* get_critsec() | 157 CRITICAL_SECTION* get_critsec() |
| 176 { | 158 { |
| 177 static CRITICAL_SECTION g_critsec; | 159 static CRITICAL_SECTION g_critsec; |
| 178 return &g_critsec; | 160 return &g_critsec; |
| 179 } | 161 } |
| 180 }; | 162 }; |
| 181 | 163 |
| 182 class multi_threaded_local | 164 class multi_threaded_local |
| 183 { | 165 { |
| 184 public: | 166 public: |
| 185 multi_threaded_local() | 167 multi_threaded_local() |
| 186 { | 168 { |
| 187 InitializeCriticalSection(&m_critsec); | 169 InitializeCriticalSection(&m_critsec); |
| 188 } | 170 } |
| 189 | 171 |
| 190 multi_threaded_local(const multi_threaded_local&) | 172 multi_threaded_local(const multi_threaded_local&) |
| 191 { | 173 { |
| 192 InitializeCriticalSection(&m_critsec); | 174 InitializeCriticalSection(&m_critsec); |
| 193 } | 175 } |
| 194 | 176 |
| 195 » » virtual ~multi_threaded_local() | 177 » » ~multi_threaded_local() |
| 196 { | 178 { |
| 197 DeleteCriticalSection(&m_critsec); | 179 DeleteCriticalSection(&m_critsec); |
| 198 } | 180 } |
| 199 | 181 |
| 200 » » virtual void lock() | 182 » » void lock() |
| 201 { | 183 { |
| 202 EnterCriticalSection(&m_critsec); | 184 EnterCriticalSection(&m_critsec); |
| 203 } | 185 } |
| 204 | 186 |
| 205 » » virtual void unlock() | 187 » » void unlock() |
| 206 { | 188 { |
| 207 LeaveCriticalSection(&m_critsec); | 189 LeaveCriticalSection(&m_critsec); |
| 208 } | 190 } |
| 209 | 191 |
| 210 private: | 192 private: |
| 211 CRITICAL_SECTION m_critsec; | 193 CRITICAL_SECTION m_critsec; |
| 212 }; | 194 }; |
| 213 #endif // _SIGSLOT_HAS_WIN32_THREADS | 195 #endif // _SIGSLOT_HAS_WIN32_THREADS |
| 214 | 196 |
| 215 #ifdef _SIGSLOT_HAS_POSIX_THREADS | 197 #ifdef _SIGSLOT_HAS_POSIX_THREADS |
| 216 // The multi threading policies only get compiled in if they are enabled
. | 198 // The multi threading policies only get compiled in if they are enabled
. |
| 217 class multi_threaded_global | 199 class multi_threaded_global |
| 218 { | 200 { |
| 219 public: | 201 public: |
| 220 multi_threaded_global(); | 202 » » void lock() |
| 221 multi_threaded_global(const multi_threaded_global&); | 203 » » { |
| 222 virtual ~multi_threaded_global(); | 204 » » » pthread_mutex_lock(&g_mutex); |
| 223 virtual void lock(); | 205 » » } |
| 224 virtual void unlock(); | 206 » » void unlock() |
| 207 » » { |
| 208 » » » pthread_mutex_unlock(&g_mutex); |
| 209 » » } |
| 225 | 210 |
| 226 private: | 211 » private: |
| 227 » » pthread_mutex_t* get_mutex() | 212 » » static pthread_mutex_t g_mutex; |
| 228 » » { | |
| 229 » » » static pthread_mutex_t g_mutex; | |
| 230 » » » return &g_mutex; | |
| 231 » » } | |
| 232 }; | 213 }; |
| 233 | 214 |
| 234 class multi_threaded_local | 215 class multi_threaded_local |
| 235 { | 216 { |
| 236 public: | 217 public: |
| 237 multi_threaded_local(); | 218 » » multi_threaded_local() |
| 238 multi_threaded_local(const multi_threaded_local&); | 219 » » { |
| 239 virtual ~multi_threaded_local(); | 220 » » » pthread_mutex_init(&m_mutex, NULL); |
| 240 virtual void lock(); | 221 » » } |
| 241 virtual void unlock(); | 222 » » multi_threaded_local(const multi_threaded_local&) |
| 223 » » { |
| 224 » » » pthread_mutex_init(&m_mutex, NULL); |
| 225 » » } |
| 226 » » ~multi_threaded_local() |
| 227 » » { |
| 228 » » » pthread_mutex_destroy(&m_mutex); |
| 229 » » } |
| 230 » » void lock() |
| 231 » » { |
| 232 » » » pthread_mutex_lock(&m_mutex); |
| 233 » » } |
| 234 » » void unlock() |
| 235 » » { |
| 236 » » » pthread_mutex_unlock(&m_mutex); |
| 237 » » } |
| 242 | 238 |
| 243 private: | 239 » private: |
| 244 pthread_mutex_t m_mutex; | 240 pthread_mutex_t m_mutex; |
| 245 }; | 241 }; |
| 246 #endif // _SIGSLOT_HAS_POSIX_THREADS | 242 #endif // _SIGSLOT_HAS_POSIX_THREADS |
| 247 | 243 |
| 248 template<class mt_policy> | 244 template<class mt_policy> |
| 249 class lock_block | 245 class lock_block |
| 250 { | 246 { |
| 251 public: | 247 public: |
| 252 mt_policy *m_mutex; | 248 mt_policy *m_mutex; |
| 253 | 249 |
| 254 lock_block(mt_policy *mtx) | 250 lock_block(mt_policy *mtx) |
| 255 : m_mutex(mtx) | 251 : m_mutex(mtx) |
| 256 { | 252 { |
| 257 m_mutex->lock(); | 253 m_mutex->lock(); |
| 258 } | 254 } |
| 259 | 255 |
| 260 ~lock_block() | 256 ~lock_block() |
| 261 { | 257 { |
| 262 m_mutex->unlock(); | 258 m_mutex->unlock(); |
| 263 } | 259 } |
| 264 }; | 260 }; |
| 265 | 261 |
| 266 » class has_slots_interface; | 262 » template< bool f > struct static_assertion_result; |
| 267 | 263 » template< > struct static_assertion_result< true > { enum { value = 1 };
}; |
| 268 » template<class mt_policy> | 264 |
| 269 » class _connection_base0 | 265 » class _signal_base_interface; |
| 270 » { | 266 |
| 271 » public: | 267 » class has_slots_interface |
| 272 » » virtual ~_connection_base0() {} | 268 » { |
| 273 » » virtual has_slots_interface* getdest() const = 0; | 269 » private: |
| 274 » » virtual void emit() = 0; | 270 » » typedef void (*signal_connect_t)(has_slots_interface* self, _sig
nal_base_interface* sender); |
| 275 » » virtual _connection_base0* clone() = 0; | 271 » » typedef void (*signal_disconnect_t)(has_slots_interface* self, _
signal_base_interface* sender); |
| 276 » » virtual _connection_base0* duplicate(has_slots_interface* pnewde
st) = 0; | 272 » » typedef void (*disconnect_all_t)(has_slots_interface* self); |
| 277 » }; | 273 |
| 278 | 274 » » const signal_connect_t m_signal_connect; |
| 279 » template<class arg1_type, class mt_policy> | 275 » » const signal_disconnect_t m_signal_disconnect; |
| 280 » class _connection_base1 | 276 » » const disconnect_all_t m_disconnect_all; |
| 281 » { | 277 |
| 282 » public: | 278 » protected: |
| 283 » » virtual ~_connection_base1() {} | 279 » » has_slots_interface(signal_connect_t conn, signal_disconnect_t d
isc, disconnect_all_t disc_all) : |
| 284 » » virtual has_slots_interface* getdest() const = 0; | 280 » » » m_signal_connect(conn), m_signal_disconnect(disc), m_dis
connect_all(disc_all) |
| 285 » » virtual void emit(arg1_type) = 0; | 281 » » { |
| 286 » » virtual _connection_base1<arg1_type, mt_policy>* clone() = 0; | 282 » » } |
| 287 » » virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_s
lots_interface* pnewdest) = 0; | 283 |
| 288 » }; | 284 » » ~has_slots_interface() {} |
| 289 | 285 |
| 290 » template<class arg1_type, class arg2_type, class mt_policy> | 286 » public: |
| 291 » class _connection_base2 | 287 » » void signal_connect(_signal_base_interface* sender) |
| 292 » { | 288 » » { |
| 293 » public: | 289 » » » m_signal_connect(this, sender); |
| 294 » » virtual ~_connection_base2() {} | 290 » » } |
| 295 » » virtual has_slots_interface* getdest() const = 0; | 291 |
| 296 » » virtual void emit(arg1_type, arg2_type) = 0; | 292 » » void signal_disconnect(_signal_base_interface* sender) |
| 297 » » virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clon
e() = 0; | 293 » » { |
| 298 » » virtual _connection_base2<arg1_type, arg2_type, mt_policy>* dupl
icate(has_slots_interface* pnewdest) = 0; | 294 » » » m_signal_disconnect(this, sender); |
| 299 » }; | 295 » » } |
| 300 | 296 |
| 301 » template<class arg1_type, class arg2_type, class arg3_type, class mt_pol
icy> | 297 » » void disconnect_all() |
| 302 » class _connection_base3 | 298 » » { |
| 303 » { | 299 » » » m_disconnect_all(this); |
| 304 » public: | 300 » » } |
| 305 » » virtual ~_connection_base3() {} | |
| 306 » » virtual has_slots_interface* getdest() const = 0; | |
| 307 » » virtual void emit(arg1_type, arg2_type, arg3_type) = 0; | |
| 308 » » virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_po
licy>* clone() = 0; | |
| 309 » » virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_po
licy>* duplicate(has_slots_interface* pnewdest) = 0; | |
| 310 » }; | |
| 311 | |
| 312 » template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, class mt_policy> | |
| 313 » class _connection_base4 | |
| 314 » { | |
| 315 » public: | |
| 316 » » virtual ~_connection_base4() {} | |
| 317 » » virtual has_slots_interface* getdest() const = 0; | |
| 318 » » virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type) =
0; | |
| 319 » » virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_
type, mt_policy>* clone() = 0; | |
| 320 » » virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_
type, mt_policy>* duplicate(has_slots_interface* pnewdest) = 0; | |
| 321 » }; | |
| 322 | |
| 323 » template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 324 » class arg5_type, class mt_policy> | |
| 325 » class _connection_base5 | |
| 326 » { | |
| 327 » public: | |
| 328 » » virtual ~_connection_base5() {} | |
| 329 » » virtual has_slots_interface* getdest() const = 0; | |
| 330 » » virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, | |
| 331 » » » arg5_type) = 0; | |
| 332 » » virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 333 » » » arg5_type, mt_policy>* clone() = 0; | |
| 334 » » virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 335 » » » arg5_type, mt_policy>* duplicate(has_slots_interface* pn
ewdest) = 0; | |
| 336 » }; | |
| 337 | |
| 338 » template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 339 » class arg5_type, class arg6_type, class mt_policy> | |
| 340 » class _connection_base6 | |
| 341 » { | |
| 342 » public: | |
| 343 » » virtual ~_connection_base6() {} | |
| 344 » » virtual has_slots_interface* getdest() const = 0; | |
| 345 » » virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, ar
g5_type, | |
| 346 » » » arg6_type) = 0; | |
| 347 » » virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 348 » » » arg5_type, arg6_type, mt_policy>* clone() = 0; | |
| 349 » » virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 350 » » » arg5_type, arg6_type, mt_policy>* duplicate(has_slots_in
terface* pnewdest) = 0; | |
| 351 » }; | |
| 352 | |
| 353 » template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 354 » class arg5_type, class arg6_type, class arg7_type, class mt_policy> | |
| 355 » class _connection_base7 | |
| 356 » { | |
| 357 » public: | |
| 358 » » virtual ~_connection_base7() {} | |
| 359 » » virtual has_slots_interface* getdest() const = 0; | |
| 360 » » virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, ar
g5_type, | |
| 361 » » » arg6_type, arg7_type) = 0; | |
| 362 » » virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 363 » » » arg5_type, arg6_type, arg7_type, mt_policy>* clone() = 0
; | |
| 364 » » virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 365 » » » arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(h
as_slots_interface* pnewdest) = 0; | |
| 366 » }; | |
| 367 | |
| 368 » template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 369 » class arg5_type, class arg6_type, class arg7_type, class arg8_type, clas
s mt_policy> | |
| 370 » class _connection_base8 | |
| 371 » { | |
| 372 » public: | |
| 373 » » virtual ~_connection_base8() {} | |
| 374 » » virtual has_slots_interface* getdest() const = 0; | |
| 375 » » virtual void emit(arg1_type, arg2_type, arg3_type, arg4_type, ar
g5_type, | |
| 376 » » » arg6_type, arg7_type, arg8_type) = 0; | |
| 377 » » virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 378 » » » arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>*
clone() = 0; | |
| 379 » » virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 380 » » » arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>*
duplicate(has_slots_interface* pnewdest) = 0; | |
| 381 }; | 301 }; |
| 382 | 302 |
| 383 class _signal_base_interface | 303 class _signal_base_interface |
| 384 { | 304 { |
| 385 public: | 305 private: |
| 386 virtual ~_signal_base_interface() {} | 306 typedef void (*slot_disconnect_t)(_signal_base_interface* self,
has_slots_interface* pslot); |
| 387 virtual void slot_disconnect(has_slots_interface* pslot) = 0; | 307 typedef void (*slot_duplicate_t)(_signal_base_interface* self, c
onst has_slots_interface* poldslot, has_slots_interface* pnewslot); |
| 388 virtual void slot_duplicate(const has_slots_interface* poldslot,
has_slots_interface* pnewslot) = 0; | 308 |
| 309 const slot_disconnect_t m_slot_disconnect; |
| 310 const slot_duplicate_t m_slot_duplicate; |
| 311 |
| 312 protected: |
| 313 _signal_base_interface(slot_disconnect_t disc, slot_duplicate_t
dupl) : |
| 314 m_slot_disconnect(disc), m_slot_duplicate(dupl) |
| 315 { |
| 316 } |
| 317 |
| 318 ~_signal_base_interface() {} |
| 319 |
| 320 public: |
| 321 void slot_disconnect(has_slots_interface* pslot) |
| 322 { |
| 323 m_slot_disconnect(this, pslot); |
| 324 } |
| 325 |
| 326 void slot_duplicate(const has_slots_interface* poldslot, has_slo
ts_interface* pnewslot) |
| 327 { |
| 328 m_slot_duplicate(this, poldslot, pnewslot); |
| 329 } |
| 330 }; |
| 331 |
| 332 class _opaque_connection |
| 333 { |
| 334 private: |
| 335 typedef void (_opaque_connection::*method_t)(); |
| 336 typedef void (*emit_t)(const _opaque_connection*); |
| 337 template< typename FromT, typename ToT > |
| 338 union union_caster |
| 339 { |
| 340 FromT from; |
| 341 ToT to; |
| 342 }; |
| 343 |
| 344 emit_t pemit; |
| 345 has_slots_interface* pdest; |
| 346 method_t pmethod; |
| 347 |
| 348 public: |
| 349 template< typename DestT > |
| 350 _opaque_connection(DestT* pd, void (DestT::*pm)()) : pdest(pd) |
| 351 { |
| 352 typedef void (DestT::*pm_t)(); |
| 353 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 354 |
| 355 union_caster< pm_t, method_t > caster; |
| 356 caster.from = pm; |
| 357 pmethod = caster.to; |
| 358 |
| 359 typedef void (*em_t)(const _opaque_connection* self); |
| 360 union_caster< em_t, emit_t > caster2; |
| 361 caster2.from = &_opaque_connection::emit0< DestT >; |
| 362 pemit = caster2.to; |
| 363 } |
| 364 |
| 365 template< typename DestT, typename T0 > |
| 366 _opaque_connection(DestT* pd, void (DestT::*pm)(T0)) : pdest(pd) |
| 367 { |
| 368 typedef void (DestT::*pm_t)(T0); |
| 369 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 370 |
| 371 union_caster< pm_t, method_t > caster; |
| 372 caster.from = pm; |
| 373 pmethod = caster.to; |
| 374 |
| 375 typedef void (*em_t)(const _opaque_connection* self, T0)
; |
| 376 union_caster< em_t, emit_t > caster2; |
| 377 caster2.from = &_opaque_connection::emit1< DestT, T0 >; |
| 378 pemit = caster2.to; |
| 379 } |
| 380 |
| 381 template< typename DestT, typename T0, typename T1 > |
| 382 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1)) : pdest
(pd) |
| 383 { |
| 384 typedef void (DestT::*pm_t)(T0, T1); |
| 385 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 386 |
| 387 union_caster< pm_t, method_t > caster; |
| 388 caster.from = pm; |
| 389 pmethod = caster.to; |
| 390 |
| 391 typedef void (*em_t)(const _opaque_connection* self, T0,
T1); |
| 392 union_caster< em_t, emit_t > caster2; |
| 393 caster2.from = &_opaque_connection::emit2< DestT, T0, T1
>; |
| 394 pemit = caster2.to; |
| 395 } |
| 396 |
| 397 template< typename DestT, typename T0, typename T1, typename T2
> |
| 398 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1, T2)) : p
dest(pd) |
| 399 { |
| 400 typedef void (DestT::*pm_t)(T0, T1, T2); |
| 401 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 402 |
| 403 union_caster< pm_t, method_t > caster; |
| 404 caster.from = pm; |
| 405 pmethod = caster.to; |
| 406 |
| 407 typedef void (*em_t)(const _opaque_connection* self, T0,
T1, T2); |
| 408 union_caster< em_t, emit_t > caster2; |
| 409 caster2.from = &_opaque_connection::emit3< DestT, T0, T1
, T2 >; |
| 410 pemit = caster2.to; |
| 411 } |
| 412 |
| 413 template< typename DestT, typename T0, typename T1, typename T2,
typename T3 > |
| 414 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1, T2, T3))
: pdest(pd) |
| 415 { |
| 416 typedef void (DestT::*pm_t)(T0, T1, T2, T3); |
| 417 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 418 |
| 419 union_caster< pm_t, method_t > caster; |
| 420 caster.from = pm; |
| 421 pmethod = caster.to; |
| 422 |
| 423 typedef void (*em_t)(const _opaque_connection* self, T0,
T1, T2, T3); |
| 424 union_caster< em_t, emit_t > caster2; |
| 425 caster2.from = &_opaque_connection::emit4< DestT, T0, T1
, T2, T3 >; |
| 426 pemit = caster2.to; |
| 427 } |
| 428 |
| 429 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4 > |
| 430 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1, T2, T3,
T4)) : pdest(pd) |
| 431 { |
| 432 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4); |
| 433 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 434 |
| 435 union_caster< pm_t, method_t > caster; |
| 436 caster.from = pm; |
| 437 pmethod = caster.to; |
| 438 |
| 439 typedef void (*em_t)(const _opaque_connection* self, T0,
T1, T2, T3, T4); |
| 440 union_caster< em_t, emit_t > caster2; |
| 441 caster2.from = &_opaque_connection::emit5< DestT, T0, T1
, T2, T3, T4 >; |
| 442 pemit = caster2.to; |
| 443 } |
| 444 |
| 445 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4, typename T5 > |
| 446 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1, T2, T3,
T4, T5)) : pdest(pd) |
| 447 { |
| 448 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4, T5); |
| 449 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 450 |
| 451 union_caster< pm_t, method_t > caster; |
| 452 caster.from = pm; |
| 453 pmethod = caster.to; |
| 454 |
| 455 typedef void (*em_t)(const _opaque_connection* self, T0,
T1, T2, T3, T4, T5); |
| 456 union_caster< em_t, emit_t > caster2; |
| 457 caster2.from = &_opaque_connection::emit6< DestT, T0, T1
, T2, T3, T4, T5 >; |
| 458 pemit = caster2.to; |
| 459 } |
| 460 |
| 461 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4, typename T5, typename T6 > |
| 462 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1, T2, T3,
T4, T5, T6)) : pdest(pd) |
| 463 { |
| 464 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4, T5, T6); |
| 465 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 466 |
| 467 union_caster< pm_t, method_t > caster; |
| 468 caster.from = pm; |
| 469 pmethod = caster.to; |
| 470 |
| 471 typedef void (*em_t)(const _opaque_connection* self, T0,
T1, T2, T3, T4, T5, T6); |
| 472 union_caster< em_t, emit_t > caster2; |
| 473 caster2.from = &_opaque_connection::emit7< DestT, T0, T1
, T2, T3, T4, T5, T6 >; |
| 474 pemit = caster2.to; |
| 475 } |
| 476 |
| 477 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4, typename T5, typename T6, typename T7 > |
| 478 _opaque_connection(DestT* pd, void (DestT::*pm)(T0, T1, T2, T3,
T4, T5, T6, T7)) : pdest(pd) |
| 479 { |
| 480 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4, T5, T6,
T7); |
| 481 enum { test = static_assertion_result< sizeof(pm_t) == s
izeof(method_t) >::value }; |
| 482 |
| 483 union_caster< pm_t, method_t > caster; |
| 484 caster.from = pm; |
| 485 pmethod = caster.to; |
| 486 |
| 487 typedef void (*em_t)(const _opaque_connection* self, T0,
T1, T2, T3, T4, T5, T6, T7); |
| 488 union_caster< em_t, emit_t > caster2; |
| 489 caster2.from = &_opaque_connection::emit8< DestT, T0, T1
, T2, T3, T4, T5, T6, T7 >; |
| 490 pemit = caster2.to; |
| 491 } |
| 492 |
| 493 has_slots_interface* getdest() const { return pdest; } |
| 494 |
| 495 _opaque_connection duplicate(has_slots_interface* newtarget) con
st |
| 496 { |
| 497 _opaque_connection res = *this; |
| 498 res.pdest = newtarget; |
| 499 return res; |
| 500 } |
| 501 |
| 502 void emit() const |
| 503 { |
| 504 typedef void (*em_t)(const _opaque_connection*); |
| 505 union_caster< emit_t, em_t > caster; |
| 506 caster.from = pemit; |
| 507 (caster.to)(this); |
| 508 } |
| 509 |
| 510 template< typename T0 > |
| 511 void emit(T0 arg0) const |
| 512 { |
| 513 typedef void (*em_t)(const _opaque_connection*, T0); |
| 514 union_caster< emit_t, em_t > caster; |
| 515 caster.from = pemit; |
| 516 (caster.to)(this, arg0); |
| 517 } |
| 518 |
| 519 template< typename T0, typename T1 > |
| 520 void emit(T0 arg0, T1 arg1) const |
| 521 { |
| 522 typedef void (*em_t)(const _opaque_connection*, T0, T1); |
| 523 union_caster< emit_t, em_t > caster; |
| 524 caster.from = pemit; |
| 525 (caster.to)(this, arg0, arg1); |
| 526 } |
| 527 |
| 528 template< typename T0, typename T1, typename T2 > |
| 529 void emit(T0 arg0, T1 arg1, T2 arg2) const |
| 530 { |
| 531 typedef void (*em_t)(const _opaque_connection*, T0, T1,
T2); |
| 532 union_caster< emit_t, em_t > caster; |
| 533 caster.from = pemit; |
| 534 (caster.to)(this, arg0, arg1, arg2); |
| 535 } |
| 536 |
| 537 template< typename T0, typename T1, typename T2, typename T3 > |
| 538 void emit(T0 arg0, T1 arg1, T2 arg2, T3 arg3) const |
| 539 { |
| 540 typedef void (*em_t)(const _opaque_connection*, T0, T1,
T2, T3); |
| 541 union_caster< emit_t, em_t > caster; |
| 542 caster.from = pemit; |
| 543 (caster.to)(this, arg0, arg1, arg2, arg3); |
| 544 } |
| 545 |
| 546 template< typename T0, typename T1, typename T2, typename T3, ty
pename T4 > |
| 547 void emit(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) const |
| 548 { |
| 549 typedef void (*em_t)(const _opaque_connection*, T0, T1,
T2, T3, T4); |
| 550 union_caster< emit_t, em_t > caster; |
| 551 caster.from = pemit; |
| 552 (caster.to)(this, arg0, arg1, arg2, arg3, arg4); |
| 553 } |
| 554 |
| 555 template< typename T0, typename T1, typename T2, typename T3, ty
pename T4, typename T5 > |
| 556 void emit(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
const |
| 557 { |
| 558 typedef void (*em_t)(const _opaque_connection*, T0, T1,
T2, T3, T4, T5); |
| 559 union_caster< emit_t, em_t > caster; |
| 560 caster.from = pemit; |
| 561 (caster.to)(this, arg0, arg1, arg2, arg3, arg4, arg5); |
| 562 } |
| 563 |
| 564 template< typename T0, typename T1, typename T2, typename T3, ty
pename T4, typename T5, typename T6 > |
| 565 void emit(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5,
T6 arg6) const |
| 566 { |
| 567 typedef void (*em_t)(const _opaque_connection*, T0, T1,
T2, T3, T4, T5, T6); |
| 568 union_caster< emit_t, em_t > caster; |
| 569 caster.from = pemit; |
| 570 (caster.to)(this, arg0, arg1, arg2, arg3, arg4, arg5, ar
g6); |
| 571 } |
| 572 |
| 573 template< typename T0, typename T1, typename T2, typename T3, ty
pename T4, typename T5, typename T6, typename T7 > |
| 574 void emit(T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5,
T6 arg6, T7 arg7) const |
| 575 { |
| 576 typedef void (*em_t)(const _opaque_connection*, T0, T1,
T2, T3, T4, T5, T6, T7); |
| 577 union_caster< emit_t, em_t > caster; |
| 578 caster.from = pemit; |
| 579 (caster.to)(this, arg0, arg1, arg2, arg3, arg4, arg5, ar
g6, arg7); |
| 580 } |
| 581 |
| 582 private: |
| 583 template< typename DestT > |
| 584 static void emit0(const _opaque_connection* self) |
| 585 { |
| 586 typedef void (DestT::*pm_t)(); |
| 587 union_caster< method_t, pm_t > caster; |
| 588 caster.from = self->pmethod; |
| 589 (static_cast< DestT* >(self->pdest)->*(caster.to))(); |
| 590 } |
| 591 |
| 592 template< typename DestT, typename T0 > |
| 593 static void emit1(const _opaque_connection* self, T0 arg0) |
| 594 { |
| 595 typedef void (DestT::*pm_t)(T0); |
| 596 union_caster< method_t, pm_t > caster; |
| 597 caster.from = self->pmethod; |
| 598 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0)
; |
| 599 } |
| 600 |
| 601 template< typename DestT, typename T0, typename T1 > |
| 602 static void emit2(const _opaque_connection* self, T0 arg0, T1 ar
g1) |
| 603 { |
| 604 typedef void (DestT::*pm_t)(T0, T1); |
| 605 union_caster< method_t, pm_t > caster; |
| 606 caster.from = self->pmethod; |
| 607 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1); |
| 608 } |
| 609 |
| 610 template< typename DestT, typename T0, typename T1, typename T2
> |
| 611 static void emit3(const _opaque_connection* self, T0 arg0, T1 ar
g1, T2 arg2) |
| 612 { |
| 613 typedef void (DestT::*pm_t)(T0, T1, T2); |
| 614 union_caster< method_t, pm_t > caster; |
| 615 caster.from = self->pmethod; |
| 616 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1, arg2); |
| 617 } |
| 618 |
| 619 template< typename DestT, typename T0, typename T1, typename T2,
typename T3 > |
| 620 static void emit4(const _opaque_connection* self, T0 arg0, T1 ar
g1, T2 arg2, T3 arg3) |
| 621 { |
| 622 typedef void (DestT::*pm_t)(T0, T1, T2, T3); |
| 623 union_caster< method_t, pm_t > caster; |
| 624 caster.from = self->pmethod; |
| 625 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1, arg2, arg3); |
| 626 } |
| 627 |
| 628 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4 > |
| 629 static void emit5(const _opaque_connection* self, T0 arg0, T1 ar
g1, T2 arg2, T3 arg3, T4 arg4) |
| 630 { |
| 631 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4); |
| 632 union_caster< method_t, pm_t > caster; |
| 633 caster.from = self->pmethod; |
| 634 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1, arg2, arg3, arg4); |
| 635 } |
| 636 |
| 637 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4, typename T5 > |
| 638 static void emit6(const _opaque_connection* self, T0 arg0, T1 ar
g1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) |
| 639 { |
| 640 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4, T5); |
| 641 union_caster< method_t, pm_t > caster; |
| 642 caster.from = self->pmethod; |
| 643 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1, arg2, arg3, arg4, arg5); |
| 644 } |
| 645 |
| 646 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4, typename T5, typename T6 > |
| 647 static void emit7(const _opaque_connection* self, T0 arg0, T1 ar
g1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) |
| 648 { |
| 649 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4, T5, T6); |
| 650 union_caster< method_t, pm_t > caster; |
| 651 caster.from = self->pmethod; |
| 652 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1, arg2, arg3, arg4, arg5, arg6); |
| 653 } |
| 654 |
| 655 template< typename DestT, typename T0, typename T1, typename T2,
typename T3, typename T4, typename T5, typename T6, typename T7 > |
| 656 static void emit8(const _opaque_connection* self, T0 arg0, T1 ar
g1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) |
| 657 { |
| 658 typedef void (DestT::*pm_t)(T0, T1, T2, T3, T4, T5, T6,
T7); |
| 659 union_caster< method_t, pm_t > caster; |
| 660 caster.from = self->pmethod; |
| 661 (static_cast< DestT* >(self->pdest)->*(caster.to))(arg0,
arg1, arg2, arg3, arg4, arg5, arg6, arg7); |
| 662 } |
| 389 }; | 663 }; |
| 390 | 664 |
| 391 template<class mt_policy> | 665 template<class mt_policy> |
| 392 class _signal_base : public _signal_base_interface, public mt_policy | 666 class _signal_base : public _signal_base_interface, public mt_policy |
| 393 { | 667 { |
| 394 » }; | 668 » protected: |
| 395 | 669 » » typedef std::list< _opaque_connection > connections_list; |
| 396 » class has_slots_interface | 670 |
| 397 » { | 671 » » _signal_base() : _signal_base_interface(&_signal_base::do_slot_d
isconnect, &_signal_base::do_slot_duplicate) |
| 398 » public: | 672 » » { |
| 399 » » has_slots_interface() | 673 » » } |
| 400 » » { | 674 |
| 401 » » » ; | 675 » » ~_signal_base() |
| 402 » » } | 676 » » { |
| 403 | 677 » » » disconnect_all(); |
| 404 » » virtual void signal_connect(_signal_base_interface* sender) = 0; | 678 » » } |
| 405 | 679 |
| 406 » » virtual void signal_disconnect(_signal_base_interface* sender) =
0; | 680 » private: |
| 407 | 681 » » _signal_base(const _signal_base& s); |
| 408 » » virtual ~has_slots_interface() | 682 » » _signal_base& operator= (_signal_base const& that); |
| 409 » » { | 683 |
| 410 » » } | 684 » public: |
| 411 | 685 » » bool is_empty() |
| 412 » » virtual void disconnect_all() = 0; | 686 » » { |
| 687 » » » lock_block<mt_policy> lock(this); |
| 688 » » » return m_connected_slots.empty(); |
| 689 » » } |
| 690 |
| 691 » » void disconnect_all() |
| 692 » » { |
| 693 » » » lock_block<mt_policy> lock(this); |
| 694 |
| 695 » » » while(!m_connected_slots.empty()) |
| 696 » » » { |
| 697 » » » » has_slots_interface* pdest = m_connected_slots.f
ront().getdest(); |
| 698 » » » » m_connected_slots.pop_front(); |
| 699 » » » » pdest->signal_disconnect(static_cast< _signal_ba
se_interface* >(this)); |
| 700 » » » } |
| 701 » » } |
| 702 |
| 703 #if !defined(NDEBUG) |
| 704 » » bool connected(has_slots_interface* pclass) |
| 705 » » { |
| 706 » » » lock_block<mt_policy> lock(this); |
| 707 » » » connections_list::const_iterator it = m_connected_slots.
begin(); |
| 708 » » » connections_list::const_iterator itEnd = m_connected_slo
ts.end(); |
| 709 » » » while(it != itEnd) |
| 710 » » » { |
| 711 » » » » if (it->getdest() == pclass) |
| 712 » » » » » return true; |
| 713 » » » » ++it; |
| 714 » » » } |
| 715 » » » return false; |
| 716 » » } |
| 717 #endif |
| 718 |
| 719 » » void disconnect(has_slots_interface* pclass) |
| 720 » » { |
| 721 » » » lock_block<mt_policy> lock(this); |
| 722 » » » connections_list::iterator it = m_connected_slots.begin(
); |
| 723 » » » connections_list::iterator itEnd = m_connected_slots.end
(); |
| 724 |
| 725 » » » while(it != itEnd) |
| 726 » » » { |
| 727 » » » » if(it->getdest() == pclass) |
| 728 » » » » { |
| 729 » » » » » m_connected_slots.erase(it); |
| 730 » » » » » pclass->signal_disconnect(static_cast< _
signal_base_interface* >(this)); |
| 731 » » » » » return; |
| 732 » » » » } |
| 733 |
| 734 » » » » ++it; |
| 735 » » » } |
| 736 » » } |
| 737 |
| 738 » private: |
| 739 » » static void do_slot_disconnect(_signal_base_interface* p, has_sl
ots_interface* pslot) |
| 740 » » { |
| 741 » » » _signal_base* const self = static_cast< _signal_base* >(
p); |
| 742 » » » lock_block<mt_policy> lock(self); |
| 743 » » » connections_list::iterator it = self->m_connected_slots.
begin(); |
| 744 » » » connections_list::iterator itEnd = self->m_connected_slo
ts.end(); |
| 745 |
| 746 » » » while(it != itEnd) |
| 747 » » » { |
| 748 » » » » connections_list::iterator itNext = it; |
| 749 » » » » ++itNext; |
| 750 |
| 751 » » » » if(it->getdest() == pslot) |
| 752 » » » » { |
| 753 » » » » » self->m_connected_slots.erase(it); |
| 754 » » » » } |
| 755 |
| 756 » » » » it = itNext; |
| 757 » » » } |
| 758 » » } |
| 759 |
| 760 » » static void do_slot_duplicate(_signal_base_interface* p, const h
as_slots_interface* oldtarget, has_slots_interface* newtarget) |
| 761 » » { |
| 762 » » » _signal_base* const self = static_cast< _signal_base* >(
p); |
| 763 » » » lock_block<mt_policy> lock(self); |
| 764 » » » connections_list::iterator it = self->m_connected_slots.
begin(); |
| 765 » » » connections_list::iterator itEnd = self->m_connected_slo
ts.end(); |
| 766 |
| 767 » » » while(it != itEnd) |
| 768 » » » { |
| 769 » » » » if(it->getdest() == oldtarget) |
| 770 » » » » { |
| 771 » » » » » self->m_connected_slots.push_back(it->du
plicate(newtarget)); |
| 772 » » » » } |
| 773 |
| 774 » » » » ++it; |
| 775 » » » } |
| 776 » » } |
| 777 |
| 778 » protected: |
| 779 » » connections_list m_connected_slots; |
| 413 }; | 780 }; |
| 414 | 781 |
| 415 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | 782 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 416 class has_slots : public has_slots_interface, public mt_policy | 783 class has_slots : public has_slots_interface, public mt_policy |
| 417 { | 784 { |
| 418 private: | 785 private: |
| 419 » » typedef std::set<_signal_base_interface*> sender_set; | 786 » » typedef std::set< _signal_base_interface* > sender_set; |
| 420 typedef sender_set::const_iterator const_iterator; | 787 typedef sender_set::const_iterator const_iterator; |
| 421 | 788 |
| 422 public: | 789 public: |
| 423 » » has_slots() | 790 » » has_slots() : has_slots_interface(&has_slots::do_signal_connect,
&has_slots::do_signal_disconnect, &has_slots::do_disconnect_all) |
| 424 » » { | 791 » » { |
| 425 » » » ; | 792 » » } |
| 426 » » } | 793 |
| 427 | 794 » » ~has_slots() |
| 428 » » has_slots(const has_slots& hs) | 795 » » { |
| 429 » » { | 796 » » » this->disconnect_all(); |
| 430 » » » lock_block<mt_policy> lock(this); | 797 » » } |
| 431 » » » const_iterator it = hs.m_senders.begin(); | 798 |
| 432 » » » const_iterator itEnd = hs.m_senders.end(); | 799 » private: |
| 433 | 800 » » has_slots(has_slots const&); |
| 434 » » » while(it != itEnd) | 801 » » has_slots& operator= (has_slots const&); |
| 435 » » » { | 802 |
| 436 » » » » (*it)->slot_duplicate(&hs, this); | 803 » » static void do_signal_connect(has_slots_interface* p, _signal_ba
se_interface* sender) |
| 437 » » » » m_senders.insert(*it); | 804 » » { |
| 438 » » » » ++it; | 805 » » » has_slots* const self = static_cast< has_slots* >(p); |
| 439 » » » } | 806 » » » lock_block<mt_policy> lock(self); |
| 440 » » } | 807 » » » self->m_senders.insert(sender); |
| 441 | 808 » » } |
| 442 » » void signal_connect(_signal_base_interface* sender) | 809 |
| 443 » » { | 810 » » static void do_signal_disconnect(has_slots_interface* p, _signal
_base_interface* sender) |
| 444 » » » lock_block<mt_policy> lock(this); | 811 » » { |
| 445 » » » m_senders.insert(sender); | 812 » » » has_slots* const self = static_cast< has_slots* >(p); |
| 446 » » } | 813 » » » lock_block<mt_policy> lock(self); |
| 447 | 814 » » » self->m_senders.erase(sender); |
| 448 » » void signal_disconnect(_signal_base_interface* sender) | 815 » » } |
| 449 » » { | 816 |
| 450 » » » lock_block<mt_policy> lock(this); | 817 » » static void do_disconnect_all(has_slots_interface* p) |
| 451 » » » m_senders.erase(sender); | 818 » » { |
| 452 » » } | 819 » » » has_slots* const self = static_cast< has_slots* >(p); |
| 453 | 820 » » » lock_block<mt_policy> lock(self); |
| 454 » » virtual ~has_slots() | 821 » » » while (!self->m_senders.empty()) |
| 455 » » { | 822 » » » { |
| 456 » » » disconnect_all(); | 823 » » » » std::set< _signal_base_interface* > senders; |
| 457 » » } | 824 » » » » senders.swap(self->m_senders); |
| 458 | 825 » » » » const_iterator it = senders.begin(); |
| 459 » » void disconnect_all() | 826 » » » » const_iterator itEnd = senders.end(); |
| 460 » » { | 827 |
| 461 » » » lock_block<mt_policy> lock(this); | 828 » » » » while(it != itEnd) |
| 462 » » » const_iterator it = m_senders.begin(); | 829 » » » » { |
| 463 » » » const_iterator itEnd = m_senders.end(); | 830 » » » » » _signal_base_interface* s = *it; |
| 464 | 831 » » » » » ++it; |
| 465 » » » while(it != itEnd) | 832 » » » » » s->slot_disconnect(p); |
| 466 » » » { | 833 » » » » } |
| 467 » » » » (*it)->slot_disconnect(this); | 834 » » » } |
| 468 » » » » ++it; | |
| 469 » » » } | |
| 470 | |
| 471 » » » m_senders.erase(m_senders.begin(), m_senders.end()); | |
| 472 } | 835 } |
| 473 | 836 |
| 474 private: | 837 private: |
| 475 sender_set m_senders; | 838 sender_set m_senders; |
| 476 }; | 839 }; |
| 477 | 840 |
| 478 template<class mt_policy> | 841 |
| 479 class _signal_base0 : public _signal_base<mt_policy> | 842 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 480 { | 843 class signal0 : public _signal_base<mt_policy> |
| 481 public: | 844 { |
| 482 typedef std::list<_connection_base0<mt_policy> *> connections_l
ist; | 845 private: |
| 483 | 846 typedef _signal_base<mt_policy> base; |
| 484 _signal_base0() | 847 |
| 485 { | 848 protected: |
| 486 ; | 849 typedef typename base::connections_list connections_list; |
| 487 } | 850 |
| 488 | 851 public: |
| 489 _signal_base0(const _signal_base0& s) | 852 signal0() |
| 490 : _signal_base<mt_policy>(s) | 853 { |
| 491 { | 854 } |
| 492 lock_block<mt_policy> lock(this); | 855 |
| 493 typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | 856 template<class desttype> |
| 494 typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | 857 void connect(desttype* pclass, void (desttype::*pmemfun)()) |
| 495 | 858 { |
| 496 while(it != itEnd) | 859 lock_block<mt_policy> lock(this); |
| 497 { | 860 this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 498 (*it)->getdest()->signal_connect(this); | 861 pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 499 m_connected_slots.push_back((*it)->clone()); | 862 } |
| 500 | 863 |
| 501 ++it; | 864 void emit() |
| 502 } | 865 { |
| 503 } | 866 lock_block<mt_policy> lock(this); |
| 504 | 867 typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 505 ~_signal_base0() | 868 typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 506 { | 869 |
| 507 disconnect_all(); | 870 while(it != itEnd) |
| 508 } | 871 { |
| 509 | 872 _opaque_connection const& conn = *it; |
| 510 bool is_empty() | 873 ++it; |
| 511 { | 874 |
| 512 lock_block<mt_policy> lock(this); | 875 conn.emit(); |
| 513 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | 876 } |
| 514 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 877 } |
| 515 return it == itEnd; | 878 |
| 516 } | 879 void operator()() |
| 517 | 880 { |
| 518 void disconnect_all() | 881 emit(); |
| 519 { | 882 } |
| 520 lock_block<mt_policy> lock(this); | 883 }; |
| 521 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | 884 |
| 522 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 885 template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 523 | 886 class signal1 : public _signal_base<mt_policy> |
| 524 while(it != itEnd) | 887 { |
| 525 { | 888 private: |
| 526 (*it)->getdest()->signal_disconnect(this); | 889 typedef _signal_base<mt_policy> base; |
| 527 delete *it; | 890 |
| 528 | 891 protected: |
| 529 ++it; | 892 typedef typename base::connections_list connections_list; |
| 530 } | 893 |
| 531 | 894 public: |
| 532 m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | 895 signal1() |
| 533 } | 896 { |
| 534 | 897 } |
| 535 #if !defined(NDEBUG) | 898 |
| 536 bool connected(has_slots_interface* pclass) | 899 template<class desttype> |
| 537 { | 900 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe)) |
| 538 lock_block<mt_policy> lock(this); | 901 { |
| 539 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | 902 lock_block<mt_policy> lock(this); |
| 540 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 903 this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 541 while(it != itEnd) | 904 pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 542 { | 905 } |
| 543 itNext = it; | 906 |
| 544 ++itNext; | 907 void emit(arg1_type a1) |
| 545 if ((*it)->getdest() == pclass) | 908 { |
| 546 return true; | 909 lock_block<mt_policy> lock(this); |
| 547 it = itNext; | 910 typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 548 } | 911 typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 549 return false; | 912 |
| 550 } | 913 while(it != itEnd) |
| 551 #endif | 914 { |
| 552 | 915 _opaque_connection const& conn = *it; |
| 553 void disconnect(has_slots_interface* pclass) | 916 ++it; |
| 554 { | 917 |
| 555 lock_block<mt_policy> lock(this); | 918 conn.emit<arg1_type>(a1); |
| 556 typename connections_list::iterator it = m_connected_slo
ts.begin(); | 919 } |
| 557 typename connections_list::iterator itEnd = m_connected_
slots.end(); | 920 } |
| 558 | 921 |
| 559 while(it != itEnd) | 922 void operator()(arg1_type a1) |
| 560 { | 923 { |
| 561 if((*it)->getdest() == pclass) | 924 emit(a1); |
| 562 { | 925 } |
| 563 delete *it; | 926 }; |
| 564 m_connected_slots.erase(it); | 927 |
| 565 pclass->signal_disconnect(this); | 928 template<class arg1_type, class arg2_type, class mt_policy = SIGSLOT_DEF
AULT_MT_POLICY> |
| 566 return; | 929 class signal2 : public _signal_base<mt_policy> |
| 567 } | 930 { |
| 568 | 931 private: |
| 569 ++it; | 932 typedef _signal_base<mt_policy> base; |
| 570 } | 933 |
| 571 } | 934 protected: |
| 572 | 935 typedef typename base::connections_list connections_list; |
| 573 void slot_disconnect(has_slots_interface* pslot) | 936 |
| 574 { | 937 public: |
| 575 lock_block<mt_policy> lock(this); | 938 signal2() |
| 576 typename connections_list::iterator it = m_connected_slo
ts.begin(); | 939 { |
| 577 typename connections_list::iterator itEnd = m_connected_
slots.end(); | 940 } |
| 578 | 941 |
| 579 while(it != itEnd) | 942 template<class desttype> |
| 580 { | 943 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 581 typename connections_list::iterator itNext = it; | 944 arg2_type)) |
| 582 ++itNext; | 945 { |
| 583 | 946 lock_block<mt_policy> lock(this); |
| 584 if((*it)->getdest() == pslot) | 947 this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 585 { | 948 pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 586 delete *it; | 949 } |
| 587 m_connected_slots.erase(it); | 950 |
| 588 } | 951 void emit(arg1_type a1, arg2_type a2) |
| 589 | 952 { |
| 590 it = itNext; | 953 lock_block<mt_policy> lock(this); |
| 591 } | 954 typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 592 } | 955 typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 593 | 956 |
| 594 void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | 957 while(it != itEnd) |
| 595 { | 958 { |
| 596 lock_block<mt_policy> lock(this); | 959 _opaque_connection const& conn = *it; |
| 597 typename connections_list::iterator it = m_connected_slo
ts.begin(); | 960 ++it; |
| 598 typename connections_list::iterator itEnd = m_connected_
slots.end(); | 961 |
| 599 | 962 conn.emit<arg1_type, arg2_type>(a1, a2); |
| 600 while(it != itEnd) | 963 } |
| 601 { | 964 } |
| 602 if((*it)->getdest() == oldtarget) | 965 |
| 603 { | 966 void operator()(arg1_type a1, arg2_type a2) |
| 604 m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | 967 { |
| 605 } | 968 emit(a1, a2); |
| 606 | 969 } |
| 607 ++it; | 970 }; |
| 608 } | 971 |
| 609 } | 972 template<class arg1_type, class arg2_type, class arg3_type, class mt_pol
icy = SIGSLOT_DEFAULT_MT_POLICY> |
| 610 | 973 class signal3 : public _signal_base<mt_policy> |
| 611 protected: | 974 { |
| 612 connections_list m_connected_slots; | 975 private: |
| 613 }; | 976 typedef _signal_base<mt_policy> base; |
| 614 | 977 |
| 615 template<class arg1_type, class mt_policy> | 978 protected: |
| 616 class _signal_base1 : public _signal_base<mt_policy> | 979 typedef typename base::connections_list connections_list; |
| 617 { | 980 |
| 618 public: | 981 public: |
| 619 typedef std::list<_connection_base1<arg1_type, mt_policy> *> co
nnections_list; | 982 signal3() |
| 620 | 983 { |
| 621 _signal_base1() | 984 } |
| 622 { | 985 |
| 623 ; | 986 template<class desttype> |
| 624 } | 987 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 625 | 988 arg2_type, arg3_type)) |
| 626 _signal_base1(const _signal_base1<arg1_type, mt_policy>& s) | 989 { |
| 627 : _signal_base<mt_policy>(s) | 990 lock_block<mt_policy> lock(this); |
| 628 { | 991 this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 629 lock_block<mt_policy> lock(this); | 992 pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 630 typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | 993 } |
| 631 typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | 994 |
| 632 | 995 void emit(arg1_type a1, arg2_type a2, arg3_type a3) |
| 633 while(it != itEnd) | 996 { |
| 634 { | 997 lock_block<mt_policy> lock(this); |
| 635 (*it)->getdest()->signal_connect(this); | 998 typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 636 m_connected_slots.push_back((*it)->clone()); | 999 typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 637 | 1000 |
| 638 ++it; | 1001 while(it != itEnd) |
| 639 } | 1002 { |
| 640 } | 1003 _opaque_connection const& conn = *it; |
| 641 | 1004 ++it; |
| 642 void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | 1005 |
| 643 { | 1006 conn.emit<arg1_type, arg2_type, arg3_type>(a1, a
2, a3); |
| 644 lock_block<mt_policy> lock(this); | 1007 } |
| 645 typename connections_list::iterator it = m_connected_slo
ts.begin(); | 1008 } |
| 646 typename connections_list::iterator itEnd = m_connected_
slots.end(); | 1009 |
| 647 | 1010 void operator()(arg1_type a1, arg2_type a2, arg3_type a3) |
| 648 while(it != itEnd) | 1011 { |
| 649 { | 1012 emit(a1, a2, a3); |
| 650 if((*it)->getdest() == oldtarget) | 1013 } |
| 651 { | 1014 }; |
| 652 m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | 1015 |
| 653 } | 1016 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 654 | 1017 class signal4 : public _signal_base<mt_policy> |
| 655 ++it; | 1018 { |
| 656 } | 1019 private: |
| 657 } | 1020 typedef _signal_base<mt_policy> base; |
| 658 | 1021 |
| 659 ~_signal_base1() | 1022 protected: |
| 660 { | 1023 typedef typename base::connections_list connections_list; |
| 661 disconnect_all(); | 1024 |
| 662 } | 1025 public: |
| 663 | 1026 signal4() |
| 664 bool is_empty() | 1027 { |
| 665 { | 1028 } |
| 666 lock_block<mt_policy> lock(this); | 1029 |
| 667 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | 1030 template<class desttype> |
| 668 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 1031 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 669 return it == itEnd; | 1032 arg2_type, arg3_type, arg4_type)) |
| 670 } | 1033 { |
| 671 | 1034 lock_block<mt_policy> lock(this); |
| 672 void disconnect_all() | 1035 this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 673 { | 1036 pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 674 lock_block<mt_policy> lock(this); | 1037 } |
| 675 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | 1038 |
| 676 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 1039 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
) |
| 677 | 1040 { |
| 678 while(it != itEnd) | 1041 lock_block<mt_policy> lock(this); |
| 679 { | 1042 typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 680 (*it)->getdest()->signal_disconnect(this); | 1043 typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 681 delete *it; | 1044 |
| 682 | 1045 while(it != itEnd) |
| 683 ++it; | 1046 { |
| 684 } | 1047 _opaque_connection const& conn = *it; |
| 685 | 1048 ++it; |
| 686 m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | 1049 |
| 687 } | 1050 conn.emit<arg1_type, arg2_type, arg3_type, arg4_
type>(a1, a2, a3, a4); |
| 688 | 1051 } |
| 689 #if !defined(NDEBUG) | 1052 } |
| 690 bool connected(has_slots_interface* pclass) | 1053 |
| 691 { | 1054 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4) |
| 692 lock_block<mt_policy> lock(this); | 1055 { |
| 693 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | 1056 emit(a1, a2, a3, a4); |
| 694 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 1057 } |
| 695 while(it != itEnd) | |
| 696 { | |
| 697 itNext = it; | |
| 698 ++itNext; | |
| 699 if ((*it)->getdest() == pclass) | |
| 700 return true; | |
| 701 it = itNext; | |
| 702 } | |
| 703 return false; | |
| 704 } | |
| 705 #endif | |
| 706 | |
| 707 void disconnect(has_slots_interface* pclass) | |
| 708 { | |
| 709 lock_block<mt_policy> lock(this); | |
| 710 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 711 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 712 | |
| 713 while(it != itEnd) | |
| 714 { | |
| 715 if((*it)->getdest() == pclass) | |
| 716 { | |
| 717 delete *it; | |
| 718 m_connected_slots.erase(it); | |
| 719 pclass->signal_disconnect(this); | |
| 720 return; | |
| 721 } | |
| 722 | |
| 723 ++it; | |
| 724 } | |
| 725 } | |
| 726 | |
| 727 void slot_disconnect(has_slots_interface* pslot) | |
| 728 { | |
| 729 lock_block<mt_policy> lock(this); | |
| 730 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 731 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 732 | |
| 733 while(it != itEnd) | |
| 734 { | |
| 735 typename connections_list::iterator itNext = it; | |
| 736 ++itNext; | |
| 737 | |
| 738 if((*it)->getdest() == pslot) | |
| 739 { | |
| 740 delete *it; | |
| 741 m_connected_slots.erase(it); | |
| 742 } | |
| 743 | |
| 744 it = itNext; | |
| 745 } | |
| 746 } | |
| 747 | |
| 748 | |
| 749 protected: | |
| 750 connections_list m_connected_slots; | |
| 751 }; | |
| 752 | |
| 753 template<class arg1_type, class arg2_type, class mt_policy> | |
| 754 class _signal_base2 : public _signal_base<mt_policy> | |
| 755 { | |
| 756 public: | |
| 757 typedef std::list<_connection_base2<arg1_type, arg2_type, mt_pol
icy> *> | |
| 758 connections_list; | |
| 759 | |
| 760 _signal_base2() | |
| 761 { | |
| 762 ; | |
| 763 } | |
| 764 | |
| 765 _signal_base2(const _signal_base2<arg1_type, arg2_type, mt_polic
y>& s) | |
| 766 : _signal_base<mt_policy>(s) | |
| 767 { | |
| 768 lock_block<mt_policy> lock(this); | |
| 769 typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | |
| 770 typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | |
| 771 | |
| 772 while(it != itEnd) | |
| 773 { | |
| 774 (*it)->getdest()->signal_connect(this); | |
| 775 m_connected_slots.push_back((*it)->clone()); | |
| 776 | |
| 777 ++it; | |
| 778 } | |
| 779 } | |
| 780 | |
| 781 void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | |
| 782 { | |
| 783 lock_block<mt_policy> lock(this); | |
| 784 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 785 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 786 | |
| 787 while(it != itEnd) | |
| 788 { | |
| 789 if((*it)->getdest() == oldtarget) | |
| 790 { | |
| 791 m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | |
| 792 } | |
| 793 | |
| 794 ++it; | |
| 795 } | |
| 796 } | |
| 797 | |
| 798 ~_signal_base2() | |
| 799 { | |
| 800 disconnect_all(); | |
| 801 } | |
| 802 | |
| 803 bool is_empty() | |
| 804 { | |
| 805 lock_block<mt_policy> lock(this); | |
| 806 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 807 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 808 return it == itEnd; | |
| 809 } | |
| 810 | |
| 811 void disconnect_all() | |
| 812 { | |
| 813 lock_block<mt_policy> lock(this); | |
| 814 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 815 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 816 | |
| 817 while(it != itEnd) | |
| 818 { | |
| 819 (*it)->getdest()->signal_disconnect(this); | |
| 820 delete *it; | |
| 821 | |
| 822 ++it; | |
| 823 } | |
| 824 | |
| 825 m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 826 } | |
| 827 | |
| 828 #if !defined(NDEBUG) | |
| 829 bool connected(has_slots_interface* pclass) | |
| 830 { | |
| 831 lock_block<mt_policy> lock(this); | |
| 832 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 833 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 834 while(it != itEnd) | |
| 835 { | |
| 836 itNext = it; | |
| 837 ++itNext; | |
| 838 if ((*it)->getdest() == pclass) | |
| 839 return true; | |
| 840 it = itNext; | |
| 841 } | |
| 842 return false; | |
| 843 } | |
| 844 #endif | |
| 845 | |
| 846 void disconnect(has_slots_interface* pclass) | |
| 847 { | |
| 848 lock_block<mt_policy> lock(this); | |
| 849 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 850 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 851 | |
| 852 while(it != itEnd) | |
| 853 { | |
| 854 if((*it)->getdest() == pclass) | |
| 855 { | |
| 856 delete *it; | |
| 857 m_connected_slots.erase(it); | |
| 858 pclass->signal_disconnect(this); | |
| 859 return; | |
| 860 } | |
| 861 | |
| 862 ++it; | |
| 863 } | |
| 864 } | |
| 865 | |
| 866 void slot_disconnect(has_slots_interface* pslot) | |
| 867 { | |
| 868 lock_block<mt_policy> lock(this); | |
| 869 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 870 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 871 | |
| 872 while(it != itEnd) | |
| 873 { | |
| 874 typename connections_list::iterator itNext = it; | |
| 875 ++itNext; | |
| 876 | |
| 877 if((*it)->getdest() == pslot) | |
| 878 { | |
| 879 delete *it; | |
| 880 m_connected_slots.erase(it); | |
| 881 } | |
| 882 | |
| 883 it = itNext; | |
| 884 } | |
| 885 } | |
| 886 | |
| 887 protected: | |
| 888 connections_list m_connected_slots; | |
| 889 }; | |
| 890 | |
| 891 template<class arg1_type, class arg2_type, class arg3_type, class mt_pol
icy> | |
| 892 class _signal_base3 : public _signal_base<mt_policy> | |
| 893 { | |
| 894 public: | |
| 895 typedef std::list<_connection_base3<arg1_type, arg2_type, arg3_t
ype, mt_policy> *> | |
| 896 connections_list; | |
| 897 | |
| 898 _signal_base3() | |
| 899 { | |
| 900 ; | |
| 901 } | |
| 902 | |
| 903 _signal_base3(const _signal_base3<arg1_type, arg2_type, arg3_typ
e, mt_policy>& s) | |
| 904 : _signal_base<mt_policy>(s) | |
| 905 { | |
| 906 lock_block<mt_policy> lock(this); | |
| 907 typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | |
| 908 typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | |
| 909 | |
| 910 while(it != itEnd) | |
| 911 { | |
| 912 (*it)->getdest()->signal_connect(this); | |
| 913 m_connected_slots.push_back((*it)->clone()); | |
| 914 | |
| 915 ++it; | |
| 916 } | |
| 917 } | |
| 918 | |
| 919 void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | |
| 920 { | |
| 921 lock_block<mt_policy> lock(this); | |
| 922 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 923 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 924 | |
| 925 while(it != itEnd) | |
| 926 { | |
| 927 if((*it)->getdest() == oldtarget) | |
| 928 { | |
| 929 m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | |
| 930 } | |
| 931 | |
| 932 ++it; | |
| 933 } | |
| 934 } | |
| 935 | |
| 936 ~_signal_base3() | |
| 937 { | |
| 938 disconnect_all(); | |
| 939 } | |
| 940 | |
| 941 bool is_empty() | |
| 942 { | |
| 943 lock_block<mt_policy> lock(this); | |
| 944 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 945 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 946 return it == itEnd; | |
| 947 } | |
| 948 | |
| 949 void disconnect_all() | |
| 950 { | |
| 951 lock_block<mt_policy> lock(this); | |
| 952 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 953 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 954 | |
| 955 while(it != itEnd) | |
| 956 { | |
| 957 (*it)->getdest()->signal_disconnect(this); | |
| 958 delete *it; | |
| 959 | |
| 960 ++it; | |
| 961 } | |
| 962 | |
| 963 m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 964 } | |
| 965 | |
| 966 #if !defined(NDEBUG) | |
| 967 bool connected(has_slots_interface* pclass) | |
| 968 { | |
| 969 lock_block<mt_policy> lock(this); | |
| 970 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 971 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 972 while(it != itEnd) | |
| 973 { | |
| 974 itNext = it; | |
| 975 ++itNext; | |
| 976 if ((*it)->getdest() == pclass) | |
| 977 return true; | |
| 978 it = itNext; | |
| 979 } | |
| 980 return false; | |
| 981 } | |
| 982 #endif | |
| 983 | |
| 984 void disconnect(has_slots_interface* pclass) | |
| 985 { | |
| 986 lock_block<mt_policy> lock(this); | |
| 987 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 988 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 989 | |
| 990 while(it != itEnd) | |
| 991 { | |
| 992 if((*it)->getdest() == pclass) | |
| 993 { | |
| 994 delete *it; | |
| 995 m_connected_slots.erase(it); | |
| 996 pclass->signal_disconnect(this); | |
| 997 return; | |
| 998 } | |
| 999 | |
| 1000 ++it; | |
| 1001 } | |
| 1002 } | |
| 1003 | |
| 1004 void slot_disconnect(has_slots_interface* pslot) | |
| 1005 { | |
| 1006 lock_block<mt_policy> lock(this); | |
| 1007 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1008 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1009 | |
| 1010 while(it != itEnd) | |
| 1011 { | |
| 1012 typename connections_list::iterator itNext = it; | |
| 1013 ++itNext; | |
| 1014 | |
| 1015 if((*it)->getdest() == pslot) | |
| 1016 { | |
| 1017 delete *it; | |
| 1018 m_connected_slots.erase(it); | |
| 1019 } | |
| 1020 | |
| 1021 it = itNext; | |
| 1022 } | |
| 1023 } | |
| 1024 | |
| 1025 protected: | |
| 1026 connections_list m_connected_slots; | |
| 1027 }; | |
| 1028 | |
| 1029 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, class mt_policy> | |
| 1030 class _signal_base4 : public _signal_base<mt_policy> | |
| 1031 { | |
| 1032 public: | |
| 1033 typedef std::list<_connection_base4<arg1_type, arg2_type, arg3_t
ype, | |
| 1034 arg4_type, mt_policy> *> connections_list; | |
| 1035 | |
| 1036 _signal_base4() | |
| 1037 { | |
| 1038 ; | |
| 1039 } | |
| 1040 | |
| 1041 _signal_base4(const _signal_base4<arg1_type, arg2_type, arg3_typ
e, arg4_type, mt_policy>& s) | |
| 1042 : _signal_base<mt_policy>(s) | |
| 1043 { | |
| 1044 lock_block<mt_policy> lock(this); | |
| 1045 typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | |
| 1046 typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | |
| 1047 | |
| 1048 while(it != itEnd) | |
| 1049 { | |
| 1050 (*it)->getdest()->signal_connect(this); | |
| 1051 m_connected_slots.push_back((*it)->clone()); | |
| 1052 | |
| 1053 ++it; | |
| 1054 } | |
| 1055 } | |
| 1056 | |
| 1057 void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | |
| 1058 { | |
| 1059 lock_block<mt_policy> lock(this); | |
| 1060 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1061 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1062 | |
| 1063 while(it != itEnd) | |
| 1064 { | |
| 1065 if((*it)->getdest() == oldtarget) | |
| 1066 { | |
| 1067 m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | |
| 1068 } | |
| 1069 | |
| 1070 ++it; | |
| 1071 } | |
| 1072 } | |
| 1073 | |
| 1074 ~_signal_base4() | |
| 1075 { | |
| 1076 disconnect_all(); | |
| 1077 } | |
| 1078 | |
| 1079 bool is_empty() | |
| 1080 { | |
| 1081 lock_block<mt_policy> lock(this); | |
| 1082 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1083 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1084 return it == itEnd; | |
| 1085 } | |
| 1086 | |
| 1087 void disconnect_all() | |
| 1088 { | |
| 1089 lock_block<mt_policy> lock(this); | |
| 1090 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1091 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1092 | |
| 1093 while(it != itEnd) | |
| 1094 { | |
| 1095 (*it)->getdest()->signal_disconnect(this); | |
| 1096 delete *it; | |
| 1097 | |
| 1098 ++it; | |
| 1099 } | |
| 1100 | |
| 1101 m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 1102 } | |
| 1103 | |
| 1104 #if !defined(NDEBUG) | |
| 1105 bool connected(has_slots_interface* pclass) | |
| 1106 { | |
| 1107 lock_block<mt_policy> lock(this); | |
| 1108 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 1109 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1110 while(it != itEnd) | |
| 1111 { | |
| 1112 itNext = it; | |
| 1113 ++itNext; | |
| 1114 if ((*it)->getdest() == pclass) | |
| 1115 return true; | |
| 1116 it = itNext; | |
| 1117 } | |
| 1118 return false; | |
| 1119 } | |
| 1120 #endif | |
| 1121 | |
| 1122 void disconnect(has_slots_interface* pclass) | |
| 1123 { | |
| 1124 lock_block<mt_policy> lock(this); | |
| 1125 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1126 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1127 | |
| 1128 while(it != itEnd) | |
| 1129 { | |
| 1130 if((*it)->getdest() == pclass) | |
| 1131 { | |
| 1132 delete *it; | |
| 1133 m_connected_slots.erase(it); | |
| 1134 pclass->signal_disconnect(this); | |
| 1135 return; | |
| 1136 } | |
| 1137 | |
| 1138 ++it; | |
| 1139 } | |
| 1140 } | |
| 1141 | |
| 1142 void slot_disconnect(has_slots_interface* pslot) | |
| 1143 { | |
| 1144 lock_block<mt_policy> lock(this); | |
| 1145 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1146 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1147 | |
| 1148 while(it != itEnd) | |
| 1149 { | |
| 1150 typename connections_list::iterator itNext = it; | |
| 1151 ++itNext; | |
| 1152 | |
| 1153 if((*it)->getdest() == pslot) | |
| 1154 { | |
| 1155 delete *it; | |
| 1156 m_connected_slots.erase(it); | |
| 1157 } | |
| 1158 | |
| 1159 it = itNext; | |
| 1160 } | |
| 1161 } | |
| 1162 | |
| 1163 protected: | |
| 1164 connections_list m_connected_slots; | |
| 1165 }; | 1058 }; |
| 1166 | 1059 |
| 1167 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | 1060 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, |
| 1168 » class arg5_type, class mt_policy> | 1061 » class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 1169 » class _signal_base5 : public _signal_base<mt_policy> | 1062 » class signal5 : public _signal_base<mt_policy> |
| 1170 » { | 1063 » { |
| 1171 » public: | 1064 » private: |
| 1172 » » typedef std::list<_connection_base5<arg1_type, arg2_type, arg3_t
ype, | 1065 » » typedef _signal_base<mt_policy> base; |
| 1173 » » » arg4_type, arg5_type, mt_policy> *> connections_list; | 1066 |
| 1174 | 1067 » protected: |
| 1175 » » _signal_base5() | 1068 » » typedef typename base::connections_list connections_list; |
| 1176 » » { | 1069 |
| 1177 » » » ; | 1070 » public: |
| 1178 » » } | 1071 » » signal5() |
| 1179 | 1072 » » { |
| 1180 » » _signal_base5(const _signal_base5<arg1_type, arg2_type, arg3_typ
e, arg4_type, | 1073 » » } |
| 1181 » » » arg5_type, mt_policy>& s) | 1074 |
| 1182 » » » : _signal_base<mt_policy>(s) | 1075 » » template<class desttype> |
| 1183 » » { | 1076 » » void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 1184 » » » lock_block<mt_policy> lock(this); | 1077 » » » arg2_type, arg3_type, arg4_type, arg5_type)) |
| 1185 » » » typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | 1078 » » { |
| 1186 » » » typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | 1079 » » » lock_block<mt_policy> lock(this); |
| 1187 | 1080 » » » this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 1188 » » » while(it != itEnd) | 1081 » » » pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 1189 » » » { | 1082 » » } |
| 1190 » » » » (*it)->getdest()->signal_connect(this); | 1083 |
| 1191 » » » » m_connected_slots.push_back((*it)->clone()); | 1084 » » void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, |
| 1192 | 1085 » » » arg5_type a5) |
| 1193 » » » » ++it; | 1086 » » { |
| 1194 » » » } | 1087 » » » lock_block<mt_policy> lock(this); |
| 1195 » » } | 1088 » » » typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 1196 | 1089 » » » typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 1197 » » void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | 1090 |
| 1198 » » { | 1091 » » » while(it != itEnd) |
| 1199 » » » lock_block<mt_policy> lock(this); | 1092 » » » { |
| 1200 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | 1093 » » » » _opaque_connection const& conn = *it; |
| 1201 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | 1094 » » » » ++it; |
| 1202 | 1095 |
| 1203 » » » while(it != itEnd) | 1096 » » » » conn.emit<arg1_type, arg2_type, arg3_type, arg4_
type, arg5_type>(a1, a2, a3, a4, a5); |
| 1204 » » » { | 1097 » » » } |
| 1205 » » » » if((*it)->getdest() == oldtarget) | 1098 » » } |
| 1206 » » » » { | 1099 |
| 1207 » » » » » m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | 1100 » » void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, |
| 1208 » » » » } | 1101 » » » arg5_type a5) |
| 1209 | 1102 » » { |
| 1210 » » » » ++it; | 1103 » » » emit(a1, a2, a3, a4, a5); |
| 1211 » » » } | 1104 » » } |
| 1212 » » } | 1105 » }; |
| 1213 | 1106 |
| 1214 » » ~_signal_base5() | |
| 1215 » » { | |
| 1216 » » » disconnect_all(); | |
| 1217 » » } | |
| 1218 | |
| 1219 » » bool is_empty() | |
| 1220 » » { | |
| 1221 » » » lock_block<mt_policy> lock(this); | |
| 1222 » » » typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1223 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1224 » » » return it == itEnd; | |
| 1225 » » } | |
| 1226 | |
| 1227 » » void disconnect_all() | |
| 1228 » » { | |
| 1229 » » » lock_block<mt_policy> lock(this); | |
| 1230 » » » typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1231 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1232 | |
| 1233 » » » while(it != itEnd) | |
| 1234 » » » { | |
| 1235 » » » » (*it)->getdest()->signal_disconnect(this); | |
| 1236 » » » » delete *it; | |
| 1237 | |
| 1238 » » » » ++it; | |
| 1239 » » » } | |
| 1240 | |
| 1241 » » » m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 1242 » » } | |
| 1243 | |
| 1244 #if !defined(NDEBUG) | |
| 1245 » » » bool connected(has_slots_interface* pclass) | |
| 1246 » » { | |
| 1247 » » » lock_block<mt_policy> lock(this); | |
| 1248 » » » typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 1249 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1250 » » » while(it != itEnd) | |
| 1251 » » » { | |
| 1252 » » » » itNext = it; | |
| 1253 » » » » ++itNext; | |
| 1254 » » » » if ((*it)->getdest() == pclass) | |
| 1255 » » » » » return true; | |
| 1256 » » » » it = itNext; | |
| 1257 » » » } | |
| 1258 » » » return false; | |
| 1259 » » } | |
| 1260 #endif | |
| 1261 | |
| 1262 » » void disconnect(has_slots_interface* pclass) | |
| 1263 » » { | |
| 1264 » » » lock_block<mt_policy> lock(this); | |
| 1265 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1266 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1267 | |
| 1268 » » » while(it != itEnd) | |
| 1269 » » » { | |
| 1270 » » » » if((*it)->getdest() == pclass) | |
| 1271 » » » » { | |
| 1272 » » » » » delete *it; | |
| 1273 » » » » » m_connected_slots.erase(it); | |
| 1274 » » » » » pclass->signal_disconnect(this); | |
| 1275 » » » » » return; | |
| 1276 » » » » } | |
| 1277 | |
| 1278 » » » » ++it; | |
| 1279 » » » } | |
| 1280 » » } | |
| 1281 | |
| 1282 » » void slot_disconnect(has_slots_interface* pslot) | |
| 1283 » » { | |
| 1284 » » » lock_block<mt_policy> lock(this); | |
| 1285 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1286 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1287 | |
| 1288 » » » while(it != itEnd) | |
| 1289 » » » { | |
| 1290 » » » » typename connections_list::iterator itNext = it; | |
| 1291 » » » » ++itNext; | |
| 1292 | |
| 1293 » » » » if((*it)->getdest() == pslot) | |
| 1294 » » » » { | |
| 1295 » » » » » delete *it; | |
| 1296 » » » » » m_connected_slots.erase(it); | |
| 1297 » » » » } | |
| 1298 | |
| 1299 » » » » it = itNext; | |
| 1300 » » » } | |
| 1301 » » } | |
| 1302 | |
| 1303 » protected: | |
| 1304 » » connections_list m_connected_slots; | |
| 1305 » }; | |
| 1306 | 1107 |
| 1307 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | 1108 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, |
| 1308 » class arg5_type, class arg6_type, class mt_policy> | 1109 » class arg5_type, class arg6_type, class mt_policy = SIGSLOT_DEFAULT_MT_P
OLICY> |
| 1309 » class _signal_base6 : public _signal_base<mt_policy> | 1110 » class signal6 : public _signal_base<mt_policy> |
| 1310 » { | 1111 » { |
| 1311 » public: | 1112 » private: |
| 1312 » » typedef std::list<_connection_base6<arg1_type, arg2_type, arg3_t
ype, | 1113 » » typedef _signal_base<mt_policy> base; |
| 1313 » » » arg4_type, arg5_type, arg6_type, mt_policy> *> connecti
ons_list; | 1114 |
| 1314 | 1115 » protected: |
| 1315 » » _signal_base6() | 1116 » » typedef typename base::connections_list connections_list; |
| 1316 » » { | 1117 |
| 1317 » » » ; | 1118 » public: |
| 1318 » » } | 1119 » » signal6() |
| 1319 | 1120 » » { |
| 1320 » » _signal_base6(const _signal_base6<arg1_type, arg2_type, arg3_typ
e, arg4_type, | 1121 » » } |
| 1321 » » » arg5_type, arg6_type, mt_policy>& s) | 1122 |
| 1322 » » » : _signal_base<mt_policy>(s) | 1123 » » template<class desttype> |
| 1323 » » { | 1124 » » void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 1324 » » » lock_block<mt_policy> lock(this); | 1125 » » » arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) |
| 1325 » » » typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | 1126 » » { |
| 1326 » » » typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | 1127 » » » lock_block<mt_policy> lock(this); |
| 1327 | 1128 » » » this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 1328 » » » while(it != itEnd) | 1129 » » » pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 1329 » » » { | 1130 » » } |
| 1330 » » » » (*it)->getdest()->signal_connect(this); | 1131 |
| 1331 » » » » m_connected_slots.push_back((*it)->clone()); | 1132 » » void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, |
| 1332 | 1133 » » » arg5_type a5, arg6_type a6) |
| 1333 » » » » ++it; | 1134 » » { |
| 1334 » » » } | 1135 » » » lock_block<mt_policy> lock(this); |
| 1335 » » } | 1136 » » » typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 1336 | 1137 » » » typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 1337 » » void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | 1138 |
| 1338 » » { | 1139 » » » while(it != itEnd) |
| 1339 » » » lock_block<mt_policy> lock(this); | 1140 » » » { |
| 1340 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | 1141 » » » » _opaque_connection const& conn = *it; |
| 1341 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | 1142 » » » » ++it; |
| 1342 | 1143 |
| 1343 » » » while(it != itEnd) | 1144 » » » » conn.emit<arg1_type, arg2_type, arg3_type, arg4_
type, arg5_type, arg6_type>(a1, a2, a3, a4, a5, a6); |
| 1344 » » » { | 1145 » » » } |
| 1345 » » » » if((*it)->getdest() == oldtarget) | 1146 » » } |
| 1346 » » » » { | 1147 |
| 1347 » » » » » m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | 1148 » » void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, |
| 1348 » » » » } | 1149 » » » arg5_type a5, arg6_type a6) |
| 1349 | 1150 » » { |
| 1350 » » » » ++it; | 1151 » » » emit(a1, a2, a3, a4, a5, a6); |
| 1351 » » » } | 1152 » » } |
| 1352 » » } | |
| 1353 | |
| 1354 » » ~_signal_base6() | |
| 1355 » » { | |
| 1356 » » » disconnect_all(); | |
| 1357 » » } | |
| 1358 | |
| 1359 » » bool is_empty() | |
| 1360 » » { | |
| 1361 » » » lock_block<mt_policy> lock(this); | |
| 1362 » » » typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1363 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1364 » » » return it == itEnd; | |
| 1365 » » } | |
| 1366 | |
| 1367 » » void disconnect_all() | |
| 1368 » » { | |
| 1369 » » » lock_block<mt_policy> lock(this); | |
| 1370 » » » typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1371 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1372 | |
| 1373 » » » while(it != itEnd) | |
| 1374 » » » { | |
| 1375 » » » » (*it)->getdest()->signal_disconnect(this); | |
| 1376 » » » » delete *it; | |
| 1377 | |
| 1378 » » » » ++it; | |
| 1379 » » » } | |
| 1380 | |
| 1381 » » » m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 1382 » » } | |
| 1383 | |
| 1384 #if !defined(NDEBUG) | |
| 1385 » » » bool connected(has_slots_interface* pclass) | |
| 1386 » » { | |
| 1387 » » » lock_block<mt_policy> lock(this); | |
| 1388 » » » typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 1389 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1390 » » » while(it != itEnd) | |
| 1391 » » » { | |
| 1392 » » » » itNext = it; | |
| 1393 » » » » ++itNext; | |
| 1394 » » » » if ((*it)->getdest() == pclass) | |
| 1395 » » » » » return true; | |
| 1396 » » » » it = itNext; | |
| 1397 » » » } | |
| 1398 » » » return false; | |
| 1399 » » } | |
| 1400 #endif | |
| 1401 | |
| 1402 » » void disconnect(has_slots_interface* pclass) | |
| 1403 » » { | |
| 1404 » » » lock_block<mt_policy> lock(this); | |
| 1405 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1406 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1407 | |
| 1408 » » » while(it != itEnd) | |
| 1409 » » » { | |
| 1410 » » » » if((*it)->getdest() == pclass) | |
| 1411 » » » » { | |
| 1412 » » » » » delete *it; | |
| 1413 » » » » » m_connected_slots.erase(it); | |
| 1414 » » » » » pclass->signal_disconnect(this); | |
| 1415 » » » » » return; | |
| 1416 » » » » } | |
| 1417 | |
| 1418 » » » » ++it; | |
| 1419 » » » } | |
| 1420 » » } | |
| 1421 | |
| 1422 » » void slot_disconnect(has_slots_interface* pslot) | |
| 1423 » » { | |
| 1424 » » » lock_block<mt_policy> lock(this); | |
| 1425 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1426 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1427 | |
| 1428 » » » while(it != itEnd) | |
| 1429 » » » { | |
| 1430 » » » » typename connections_list::iterator itNext = it; | |
| 1431 » » » » ++itNext; | |
| 1432 | |
| 1433 » » » » if((*it)->getdest() == pslot) | |
| 1434 » » » » { | |
| 1435 » » » » » delete *it; | |
| 1436 » » » » » m_connected_slots.erase(it); | |
| 1437 » » » » } | |
| 1438 | |
| 1439 » » » » it = itNext; | |
| 1440 » » » } | |
| 1441 » » } | |
| 1442 | |
| 1443 » protected: | |
| 1444 » » connections_list m_connected_slots; | |
| 1445 }; | 1153 }; |
| 1446 | 1154 |
| 1447 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | 1155 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, |
| 1448 » class arg5_type, class arg6_type, class arg7_type, class mt_policy> | 1156 » class arg5_type, class arg6_type, class arg7_type, class mt_policy = SIG
SLOT_DEFAULT_MT_POLICY> |
| 1449 » class _signal_base7 : public _signal_base<mt_policy> | 1157 » class signal7 : public _signal_base<mt_policy> |
| 1450 » { | 1158 » { |
| 1451 » public: | 1159 » private: |
| 1452 » » typedef std::list<_connection_base7<arg1_type, arg2_type, arg3_t
ype, | 1160 » » typedef _signal_base<mt_policy> base; |
| 1453 » » » arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> *
> connections_list; | 1161 |
| 1454 | 1162 » protected: |
| 1455 » » _signal_base7() | 1163 » » typedef typename base::connections_list connections_list; |
| 1456 » » { | 1164 |
| 1457 » » » ; | 1165 » public: |
| 1458 » » } | 1166 » » signal7() |
| 1459 | 1167 » » { |
| 1460 » » _signal_base7(const _signal_base7<arg1_type, arg2_type, arg3_typ
e, arg4_type, | 1168 » » } |
| 1461 » » » arg5_type, arg6_type, arg7_type, mt_policy>& s) | 1169 |
| 1462 » » » : _signal_base<mt_policy>(s) | 1170 » » template<class desttype> |
| 1463 » » { | 1171 » » void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 1464 » » » lock_block<mt_policy> lock(this); | 1172 » » » arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, |
| 1465 » » » typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | 1173 » » » arg7_type)) |
| 1466 » » » typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | 1174 » » { |
| 1467 | 1175 » » » lock_block<mt_policy> lock(this); |
| 1468 » » » while(it != itEnd) | 1176 » » » this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 1469 » » » { | 1177 » » » pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 1470 » » » » (*it)->getdest()->signal_connect(this); | 1178 » » } |
| 1471 » » » » m_connected_slots.push_back((*it)->clone()); | 1179 |
| 1472 | 1180 » » void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, |
| 1473 » » » » ++it; | 1181 » » » arg5_type a5, arg6_type a6, arg7_type a7) |
| 1474 » » » } | 1182 » » { |
| 1475 » » } | 1183 » » » lock_block<mt_policy> lock(this); |
| 1476 | 1184 » » » typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 1477 » » void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | 1185 » » » typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 1478 » » { | 1186 |
| 1479 » » » lock_block<mt_policy> lock(this); | 1187 » » » while(it != itEnd) |
| 1480 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | 1188 » » » { |
| 1481 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | 1189 » » » » _opaque_connection const& conn = *it; |
| 1482 | 1190 » » » » ++it; |
| 1483 » » » while(it != itEnd) | 1191 |
| 1484 » » » { | 1192 » » » » conn.emit<arg1_type, arg2_type, arg3_type, arg4_
type, arg5_type, arg6_type, arg7_type>(a1, a2, a3, a4, a5, a6, a7); |
| 1485 » » » » if((*it)->getdest() == oldtarget) | 1193 » » » } |
| 1486 » » » » { | 1194 » » } |
| 1487 » » » » » m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | 1195 |
| 1488 » » » » } | 1196 » » void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, |
| 1489 | 1197 » » » arg5_type a5, arg6_type a6, arg7_type a7) |
| 1490 » » » » ++it; | 1198 » » { |
| 1491 » » » } | 1199 » » » emit(a1, a2, a3, a4, a5, a6, a7); |
| 1492 » » } | 1200 » » } |
| 1493 | |
| 1494 » » ~_signal_base7() | |
| 1495 » » { | |
| 1496 » » » disconnect_all(); | |
| 1497 » » } | |
| 1498 | |
| 1499 » » bool is_empty() | |
| 1500 » » { | |
| 1501 » » » lock_block<mt_policy> lock(this); | |
| 1502 » » » typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1503 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1504 » » » return it == itEnd; | |
| 1505 » » } | |
| 1506 | |
| 1507 » » void disconnect_all() | |
| 1508 » » { | |
| 1509 » » » lock_block<mt_policy> lock(this); | |
| 1510 » » » typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1511 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1512 | |
| 1513 » » » while(it != itEnd) | |
| 1514 » » » { | |
| 1515 » » » » (*it)->getdest()->signal_disconnect(this); | |
| 1516 » » » » delete *it; | |
| 1517 | |
| 1518 » » » » ++it; | |
| 1519 » » » } | |
| 1520 | |
| 1521 » » » m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 1522 » » } | |
| 1523 | |
| 1524 #if !defined(NDEBUG) | |
| 1525 » » » bool connected(has_slots_interface* pclass) | |
| 1526 » » { | |
| 1527 » » » lock_block<mt_policy> lock(this); | |
| 1528 » » » typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 1529 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1530 » » » while(it != itEnd) | |
| 1531 » » » { | |
| 1532 » » » » itNext = it; | |
| 1533 » » » » ++itNext; | |
| 1534 » » » » if ((*it)->getdest() == pclass) | |
| 1535 » » » » » return true; | |
| 1536 » » » » it = itNext; | |
| 1537 » » » } | |
| 1538 » » » return false; | |
| 1539 » » } | |
| 1540 #endif | |
| 1541 | |
| 1542 » » void disconnect(has_slots_interface* pclass) | |
| 1543 » » { | |
| 1544 » » » lock_block<mt_policy> lock(this); | |
| 1545 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1546 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1547 | |
| 1548 » » » while(it != itEnd) | |
| 1549 » » » { | |
| 1550 » » » » if((*it)->getdest() == pclass) | |
| 1551 » » » » { | |
| 1552 » » » » » delete *it; | |
| 1553 » » » » » m_connected_slots.erase(it); | |
| 1554 » » » » » pclass->signal_disconnect(this); | |
| 1555 » » » » » return; | |
| 1556 » » » » } | |
| 1557 | |
| 1558 » » » » ++it; | |
| 1559 » » » } | |
| 1560 » » } | |
| 1561 | |
| 1562 » » void slot_disconnect(has_slots_interface* pslot) | |
| 1563 » » { | |
| 1564 » » » lock_block<mt_policy> lock(this); | |
| 1565 » » » typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1566 » » » typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1567 | |
| 1568 » » » while(it != itEnd) | |
| 1569 » » » { | |
| 1570 » » » » typename connections_list::iterator itNext = it; | |
| 1571 » » » » ++itNext; | |
| 1572 | |
| 1573 » » » » if((*it)->getdest() == pslot) | |
| 1574 » » » » { | |
| 1575 » » » » » delete *it; | |
| 1576 » » » » » m_connected_slots.erase(it); | |
| 1577 » » » » } | |
| 1578 | |
| 1579 » » » » it = itNext; | |
| 1580 » » » } | |
| 1581 » » } | |
| 1582 | |
| 1583 » protected: | |
| 1584 » » connections_list m_connected_slots; | |
| 1585 }; | 1201 }; |
| 1586 | 1202 |
| 1587 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | 1203 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, |
| 1588 class arg5_type, class arg6_type, class arg7_type, class arg8_type, clas
s mt_policy> | 1204 class arg5_type, class arg6_type, class arg7_type, class arg8_type, clas
s mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 1589 class _signal_base8 : public _signal_base<mt_policy> | 1205 class signal8 : public _signal_base<mt_policy> |
| 1590 { | 1206 { |
| 1591 public: | 1207 private: |
| 1592 typedef std::list<_connection_base8<arg1_type, arg2_type, arg3_t
ype, | 1208 typedef _signal_base<mt_policy> base; |
| 1593 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, m
t_policy> *> | 1209 |
| 1594 connections_list; | 1210 protected: |
| 1595 | 1211 typedef typename base::connections_list connections_list; |
| 1596 _signal_base8() | 1212 |
| 1597 { | 1213 public: |
| 1598 ; | 1214 signal8() |
| 1599 } | 1215 { |
| 1600 | 1216 } |
| 1601 _signal_base8(const _signal_base8<arg1_type, arg2_type, arg3_typ
e, arg4_type, | 1217 |
| 1602 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>&
s) | 1218 template<class desttype> |
| 1603 : _signal_base<mt_policy>(s) | 1219 void connect(desttype* pclass, void (desttype::*pmemfun)(arg1_ty
pe, |
| 1604 { | |
| 1605 lock_block<mt_policy> lock(this); | |
| 1606 typename connections_list::const_iterator it = s.m_conne
cted_slots.begin(); | |
| 1607 typename connections_list::const_iterator itEnd = s.m_co
nnected_slots.end(); | |
| 1608 | |
| 1609 while(it != itEnd) | |
| 1610 { | |
| 1611 (*it)->getdest()->signal_connect(this); | |
| 1612 m_connected_slots.push_back((*it)->clone()); | |
| 1613 | |
| 1614 ++it; | |
| 1615 } | |
| 1616 } | |
| 1617 | |
| 1618 void slot_duplicate(const has_slots_interface* oldtarget, has_sl
ots_interface* newtarget) | |
| 1619 { | |
| 1620 lock_block<mt_policy> lock(this); | |
| 1621 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1622 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1623 | |
| 1624 while(it != itEnd) | |
| 1625 { | |
| 1626 if((*it)->getdest() == oldtarget) | |
| 1627 { | |
| 1628 m_connected_slots.push_back((*it)->dupli
cate(newtarget)); | |
| 1629 } | |
| 1630 | |
| 1631 ++it; | |
| 1632 } | |
| 1633 } | |
| 1634 | |
| 1635 ~_signal_base8() | |
| 1636 { | |
| 1637 disconnect_all(); | |
| 1638 } | |
| 1639 | |
| 1640 bool is_empty() | |
| 1641 { | |
| 1642 lock_block<mt_policy> lock(this); | |
| 1643 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1644 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1645 return it == itEnd; | |
| 1646 } | |
| 1647 | |
| 1648 void disconnect_all() | |
| 1649 { | |
| 1650 lock_block<mt_policy> lock(this); | |
| 1651 typename connections_list::const_iterator it = m_connect
ed_slots.begin(); | |
| 1652 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1653 | |
| 1654 while(it != itEnd) | |
| 1655 { | |
| 1656 (*it)->getdest()->signal_disconnect(this); | |
| 1657 delete *it; | |
| 1658 | |
| 1659 ++it; | |
| 1660 } | |
| 1661 | |
| 1662 m_connected_slots.erase(m_connected_slots.begin(), m_con
nected_slots.end()); | |
| 1663 } | |
| 1664 | |
| 1665 #if !defined(NDEBUG) | |
| 1666 bool connected(has_slots_interface* pclass) | |
| 1667 { | |
| 1668 lock_block<mt_policy> lock(this); | |
| 1669 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 1670 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 1671 while(it != itEnd) | |
| 1672 { | |
| 1673 itNext = it; | |
| 1674 ++itNext; | |
| 1675 if ((*it)->getdest() == pclass) | |
| 1676 return true; | |
| 1677 it = itNext; | |
| 1678 } | |
| 1679 return false; | |
| 1680 } | |
| 1681 #endif | |
| 1682 | |
| 1683 void disconnect(has_slots_interface* pclass) | |
| 1684 { | |
| 1685 lock_block<mt_policy> lock(this); | |
| 1686 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1687 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1688 | |
| 1689 while(it != itEnd) | |
| 1690 { | |
| 1691 if((*it)->getdest() == pclass) | |
| 1692 { | |
| 1693 delete *it; | |
| 1694 m_connected_slots.erase(it); | |
| 1695 pclass->signal_disconnect(this); | |
| 1696 return; | |
| 1697 } | |
| 1698 | |
| 1699 ++it; | |
| 1700 } | |
| 1701 } | |
| 1702 | |
| 1703 void slot_disconnect(has_slots_interface* pslot) | |
| 1704 { | |
| 1705 lock_block<mt_policy> lock(this); | |
| 1706 typename connections_list::iterator it = m_connected_slo
ts.begin(); | |
| 1707 typename connections_list::iterator itEnd = m_connected_
slots.end(); | |
| 1708 | |
| 1709 while(it != itEnd) | |
| 1710 { | |
| 1711 typename connections_list::iterator itNext = it; | |
| 1712 ++itNext; | |
| 1713 | |
| 1714 if((*it)->getdest() == pslot) | |
| 1715 { | |
| 1716 delete *it; | |
| 1717 m_connected_slots.erase(it); | |
| 1718 } | |
| 1719 | |
| 1720 it = itNext; | |
| 1721 } | |
| 1722 } | |
| 1723 | |
| 1724 protected: | |
| 1725 connections_list m_connected_slots; | |
| 1726 }; | |
| 1727 | |
| 1728 | |
| 1729 template<class dest_type, class mt_policy> | |
| 1730 class _connection0 : public _connection_base0<mt_policy> | |
| 1731 { | |
| 1732 public: | |
| 1733 _connection0() | |
| 1734 { | |
| 1735 m_pobject = NULL; | |
| 1736 m_pmemfun = NULL; | |
| 1737 } | |
| 1738 | |
| 1739 _connection0(dest_type* pobject, void (dest_type::*pmemfun)()) | |
| 1740 { | |
| 1741 m_pobject = pobject; | |
| 1742 m_pmemfun = pmemfun; | |
| 1743 } | |
| 1744 | |
| 1745 virtual ~_connection0() | |
| 1746 { | |
| 1747 } | |
| 1748 | |
| 1749 virtual _connection_base0<mt_policy>* clone() | |
| 1750 { | |
| 1751 return new _connection0<dest_type, mt_policy>(*this); | |
| 1752 } | |
| 1753 | |
| 1754 virtual _connection_base0<mt_policy>* duplicate(has_slots_interf
ace* pnewdest) | |
| 1755 { | |
| 1756 return new _connection0<dest_type, mt_policy>((dest_type
*)pnewdest, m_pmemfun); | |
| 1757 } | |
| 1758 | |
| 1759 virtual void emit() | |
| 1760 { | |
| 1761 (m_pobject->*m_pmemfun)(); | |
| 1762 } | |
| 1763 | |
| 1764 virtual has_slots_interface* getdest() const | |
| 1765 { | |
| 1766 return m_pobject; | |
| 1767 } | |
| 1768 | |
| 1769 private: | |
| 1770 dest_type* m_pobject; | |
| 1771 void (dest_type::* m_pmemfun)(); | |
| 1772 }; | |
| 1773 | |
| 1774 template<class dest_type, class arg1_type, class mt_policy> | |
| 1775 class _connection1 : public _connection_base1<arg1_type, mt_policy> | |
| 1776 { | |
| 1777 public: | |
| 1778 _connection1() | |
| 1779 { | |
| 1780 m_pobject = NULL; | |
| 1781 m_pmemfun = NULL; | |
| 1782 } | |
| 1783 | |
| 1784 _connection1(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type)) | |
| 1785 { | |
| 1786 m_pobject = pobject; | |
| 1787 m_pmemfun = pmemfun; | |
| 1788 } | |
| 1789 | |
| 1790 virtual ~_connection1() | |
| 1791 { | |
| 1792 } | |
| 1793 | |
| 1794 virtual _connection_base1<arg1_type, mt_policy>* clone() | |
| 1795 { | |
| 1796 return new _connection1<dest_type, arg1_type, mt_policy>
(*this); | |
| 1797 } | |
| 1798 | |
| 1799 virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_s
lots_interface* pnewdest) | |
| 1800 { | |
| 1801 return new _connection1<dest_type, arg1_type, mt_policy>
((dest_type *)pnewdest, m_pmemfun); | |
| 1802 } | |
| 1803 | |
| 1804 virtual void emit(arg1_type a1) | |
| 1805 { | |
| 1806 (m_pobject->*m_pmemfun)(a1); | |
| 1807 } | |
| 1808 | |
| 1809 virtual has_slots_interface* getdest() const | |
| 1810 { | |
| 1811 return m_pobject; | |
| 1812 } | |
| 1813 | |
| 1814 private: | |
| 1815 dest_type* m_pobject; | |
| 1816 void (dest_type::* m_pmemfun)(arg1_type); | |
| 1817 }; | |
| 1818 | |
| 1819 template<class dest_type, class arg1_type, class arg2_type, class mt_pol
icy> | |
| 1820 class _connection2 : public _connection_base2<arg1_type, arg2_type, mt_p
olicy> | |
| 1821 { | |
| 1822 public: | |
| 1823 _connection2() | |
| 1824 { | |
| 1825 m_pobject = NULL; | |
| 1826 m_pmemfun = NULL; | |
| 1827 } | |
| 1828 | |
| 1829 _connection2(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 1830 arg2_type)) | |
| 1831 { | |
| 1832 m_pobject = pobject; | |
| 1833 m_pmemfun = pmemfun; | |
| 1834 } | |
| 1835 | |
| 1836 virtual ~_connection2() | |
| 1837 { | |
| 1838 } | |
| 1839 | |
| 1840 virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clon
e() | |
| 1841 { | |
| 1842 return new _connection2<dest_type, arg1_type, arg2_type,
mt_policy>(*this); | |
| 1843 } | |
| 1844 | |
| 1845 virtual _connection_base2<arg1_type, arg2_type, mt_policy>* dupl
icate(has_slots_interface* pnewdest) | |
| 1846 { | |
| 1847 return new _connection2<dest_type, arg1_type, arg2_type,
mt_policy>((dest_type *)pnewdest, m_pmemfun); | |
| 1848 } | |
| 1849 | |
| 1850 virtual void emit(arg1_type a1, arg2_type a2) | |
| 1851 { | |
| 1852 (m_pobject->*m_pmemfun)(a1, a2); | |
| 1853 } | |
| 1854 | |
| 1855 virtual has_slots_interface* getdest() const | |
| 1856 { | |
| 1857 return m_pobject; | |
| 1858 } | |
| 1859 | |
| 1860 private: | |
| 1861 dest_type* m_pobject; | |
| 1862 void (dest_type::* m_pmemfun)(arg1_type, arg2_type); | |
| 1863 }; | |
| 1864 | |
| 1865 template<class dest_type, class arg1_type, class arg2_type, class arg3_t
ype, class mt_policy> | |
| 1866 class _connection3 : public _connection_base3<arg1_type, arg2_type, arg3
_type, mt_policy> | |
| 1867 { | |
| 1868 public: | |
| 1869 _connection3() | |
| 1870 { | |
| 1871 m_pobject = NULL; | |
| 1872 m_pmemfun = NULL; | |
| 1873 } | |
| 1874 | |
| 1875 _connection3(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 1876 arg2_type, arg3_type)) | |
| 1877 { | |
| 1878 m_pobject = pobject; | |
| 1879 m_pmemfun = pmemfun; | |
| 1880 } | |
| 1881 | |
| 1882 virtual ~_connection3() | |
| 1883 { | |
| 1884 } | |
| 1885 | |
| 1886 virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_po
licy>* clone() | |
| 1887 { | |
| 1888 return new _connection3<dest_type, arg1_type, arg2_type,
arg3_type, mt_policy>(*this); | |
| 1889 } | |
| 1890 | |
| 1891 virtual _connection_base3<arg1_type, arg2_type, arg3_type, mt_po
licy>* duplicate(has_slots_interface* pnewdest) | |
| 1892 { | |
| 1893 return new _connection3<dest_type, arg1_type, arg2_type,
arg3_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); | |
| 1894 } | |
| 1895 | |
| 1896 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3) | |
| 1897 { | |
| 1898 (m_pobject->*m_pmemfun)(a1, a2, a3); | |
| 1899 } | |
| 1900 | |
| 1901 virtual has_slots_interface* getdest() const | |
| 1902 { | |
| 1903 return m_pobject; | |
| 1904 } | |
| 1905 | |
| 1906 private: | |
| 1907 dest_type* m_pobject; | |
| 1908 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type); | |
| 1909 }; | |
| 1910 | |
| 1911 template<class dest_type, class arg1_type, class arg2_type, class arg3_t
ype, | |
| 1912 class arg4_type, class mt_policy> | |
| 1913 class _connection4 : public _connection_base4<arg1_type, arg2_type, | |
| 1914 arg3_type, arg4_type, mt_policy> | |
| 1915 { | |
| 1916 public: | |
| 1917 _connection4() | |
| 1918 { | |
| 1919 m_pobject = NULL; | |
| 1920 m_pmemfun = NULL; | |
| 1921 } | |
| 1922 | |
| 1923 _connection4(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 1924 arg2_type, arg3_type, arg4_type)) | |
| 1925 { | |
| 1926 m_pobject = pobject; | |
| 1927 m_pmemfun = pmemfun; | |
| 1928 } | |
| 1929 | |
| 1930 virtual ~_connection4() | |
| 1931 { | |
| 1932 } | |
| 1933 | |
| 1934 virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_
type, mt_policy>* clone() | |
| 1935 { | |
| 1936 return new _connection4<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, mt_policy>(*this); | |
| 1937 } | |
| 1938 | |
| 1939 virtual _connection_base4<arg1_type, arg2_type, arg3_type, arg4_
type, mt_policy>* duplicate(has_slots_interface* pnewdest) | |
| 1940 { | |
| 1941 return new _connection4<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, mt_policy>((dest_type *)pnewdest, m_pmemfun); | |
| 1942 } | |
| 1943 | |
| 1944 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, | |
| 1945 arg4_type a4) | |
| 1946 { | |
| 1947 (m_pobject->*m_pmemfun)(a1, a2, a3, a4); | |
| 1948 } | |
| 1949 | |
| 1950 virtual has_slots_interface* getdest() const | |
| 1951 { | |
| 1952 return m_pobject; | |
| 1953 } | |
| 1954 | |
| 1955 private: | |
| 1956 dest_type* m_pobject; | |
| 1957 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, | |
| 1958 arg4_type); | |
| 1959 }; | |
| 1960 | |
| 1961 template<class dest_type, class arg1_type, class arg2_type, class arg3_t
ype, | |
| 1962 class arg4_type, class arg5_type, class mt_policy> | |
| 1963 class _connection5 : public _connection_base5<arg1_type, arg2_type, | |
| 1964 arg3_type, arg4_type, arg5_type, mt_policy> | |
| 1965 { | |
| 1966 public: | |
| 1967 _connection5() | |
| 1968 { | |
| 1969 m_pobject = NULL; | |
| 1970 m_pmemfun = NULL; | |
| 1971 } | |
| 1972 | |
| 1973 _connection5(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 1974 arg2_type, arg3_type, arg4_type, arg5_type)) | |
| 1975 { | |
| 1976 m_pobject = pobject; | |
| 1977 m_pmemfun = pmemfun; | |
| 1978 } | |
| 1979 | |
| 1980 virtual ~_connection5() | |
| 1981 { | |
| 1982 } | |
| 1983 | |
| 1984 virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 1985 arg5_type, mt_policy>* clone() | |
| 1986 { | |
| 1987 return new _connection5<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 1988 arg5_type, mt_policy>(*this); | |
| 1989 } | |
| 1990 | |
| 1991 virtual _connection_base5<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 1992 arg5_type, mt_policy>* duplicate(has_slots_interface* pn
ewdest) | |
| 1993 { | |
| 1994 return new _connection5<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 1995 arg5_type, mt_policy>((dest_type *)pnewdest, m_p
memfun); | |
| 1996 } | |
| 1997 | |
| 1998 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4
_type a4, | |
| 1999 arg5_type a5) | |
| 2000 { | |
| 2001 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5); | |
| 2002 } | |
| 2003 | |
| 2004 virtual has_slots_interface* getdest() const | |
| 2005 { | |
| 2006 return m_pobject; | |
| 2007 } | |
| 2008 | |
| 2009 private: | |
| 2010 dest_type* m_pobject; | |
| 2011 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, a
rg4_type, | |
| 2012 arg5_type); | |
| 2013 }; | |
| 2014 | |
| 2015 template<class dest_type, class arg1_type, class arg2_type, class arg3_t
ype, | |
| 2016 class arg4_type, class arg5_type, class arg6_type, class mt_policy> | |
| 2017 class _connection6 : public _connection_base6<arg1_type, arg2_type, | |
| 2018 arg3_type, arg4_type, arg5_type, arg6_type, mt_policy> | |
| 2019 { | |
| 2020 public: | |
| 2021 _connection6() | |
| 2022 { | |
| 2023 m_pobject = NULL; | |
| 2024 m_pmemfun = NULL; | |
| 2025 } | |
| 2026 | |
| 2027 _connection6(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 2028 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) | |
| 2029 { | |
| 2030 m_pobject = pobject; | |
| 2031 m_pmemfun = pmemfun; | |
| 2032 } | |
| 2033 | |
| 2034 virtual ~_connection6() | |
| 2035 { | |
| 2036 } | |
| 2037 | |
| 2038 virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 2039 arg5_type, arg6_type, mt_policy>* clone() | |
| 2040 { | |
| 2041 return new _connection6<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 2042 arg5_type, arg6_type, mt_policy>(*this); | |
| 2043 } | |
| 2044 | |
| 2045 virtual _connection_base6<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 2046 arg5_type, arg6_type, mt_policy>* duplicate(has_slots_in
terface* pnewdest) | |
| 2047 { | |
| 2048 return new _connection6<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 2049 arg5_type, arg6_type, mt_policy>((dest_type *)pn
ewdest, m_pmemfun); | |
| 2050 } | |
| 2051 | |
| 2052 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4
_type a4, | |
| 2053 arg5_type a5, arg6_type a6) | |
| 2054 { | |
| 2055 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6); | |
| 2056 } | |
| 2057 | |
| 2058 virtual has_slots_interface* getdest() const | |
| 2059 { | |
| 2060 return m_pobject; | |
| 2061 } | |
| 2062 | |
| 2063 private: | |
| 2064 dest_type* m_pobject; | |
| 2065 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, a
rg4_type, | |
| 2066 arg5_type, arg6_type); | |
| 2067 }; | |
| 2068 | |
| 2069 template<class dest_type, class arg1_type, class arg2_type, class arg3_t
ype, | |
| 2070 class arg4_type, class arg5_type, class arg6_type, class arg7_type, clas
s mt_policy> | |
| 2071 class _connection7 : public _connection_base7<arg1_type, arg2_type, | |
| 2072 arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, mt_policy
> | |
| 2073 { | |
| 2074 public: | |
| 2075 _connection7() | |
| 2076 { | |
| 2077 m_pobject = NULL; | |
| 2078 m_pmemfun = NULL; | |
| 2079 } | |
| 2080 | |
| 2081 _connection7(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 2082 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, a
rg7_type)) | |
| 2083 { | |
| 2084 m_pobject = pobject; | |
| 2085 m_pmemfun = pmemfun; | |
| 2086 } | |
| 2087 | |
| 2088 virtual ~_connection7() | |
| 2089 { | |
| 2090 } | |
| 2091 | |
| 2092 virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 2093 arg5_type, arg6_type, arg7_type, mt_policy>* clone() | |
| 2094 { | |
| 2095 return new _connection7<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 2096 arg5_type, arg6_type, arg7_type, mt_policy>(*thi
s); | |
| 2097 } | |
| 2098 | |
| 2099 virtual _connection_base7<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 2100 arg5_type, arg6_type, arg7_type, mt_policy>* duplicate(h
as_slots_interface* pnewdest) | |
| 2101 { | |
| 2102 return new _connection7<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 2103 arg5_type, arg6_type, arg7_type, mt_policy>((des
t_type *)pnewdest, m_pmemfun); | |
| 2104 } | |
| 2105 | |
| 2106 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4
_type a4, | |
| 2107 arg5_type a5, arg6_type a6, arg7_type a7) | |
| 2108 { | |
| 2109 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7); | |
| 2110 } | |
| 2111 | |
| 2112 virtual has_slots_interface* getdest() const | |
| 2113 { | |
| 2114 return m_pobject; | |
| 2115 } | |
| 2116 | |
| 2117 private: | |
| 2118 dest_type* m_pobject; | |
| 2119 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, a
rg4_type, | |
| 2120 arg5_type, arg6_type, arg7_type); | |
| 2121 }; | |
| 2122 | |
| 2123 template<class dest_type, class arg1_type, class arg2_type, class arg3_t
ype, | |
| 2124 class arg4_type, class arg5_type, class arg6_type, class arg7_type, | |
| 2125 class arg8_type, class mt_policy> | |
| 2126 class _connection8 : public _connection_base8<arg1_type, arg2_type, | |
| 2127 arg3_type, arg4_type, arg5_type, arg6_type, arg7_type, arg8_type
, mt_policy> | |
| 2128 { | |
| 2129 public: | |
| 2130 _connection8() | |
| 2131 { | |
| 2132 m_pobject = NULL; | |
| 2133 m_pmemfun = NULL; | |
| 2134 } | |
| 2135 | |
| 2136 _connection8(dest_type* pobject, void (dest_type::*pmemfun)(arg1
_type, | |
| 2137 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, | 1220 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, |
| 2138 arg7_type, arg8_type)) | 1221 arg7_type, arg8_type)) |
| 2139 { | 1222 { |
| 2140 m_pobject = pobject; | 1223 lock_block<mt_policy> lock(this); |
| 2141 m_pmemfun = pmemfun; | 1224 this->m_connected_slots.push_back(_opaque_connection(pcl
ass, pmemfun)); |
| 2142 } | 1225 pclass->signal_connect(static_cast< _signal_base_interfa
ce* >(this)); |
| 2143 | |
| 2144 virtual ~_connection8() | |
| 2145 { | |
| 2146 } | |
| 2147 | |
| 2148 virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 2149 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>*
clone() | |
| 2150 { | |
| 2151 return new _connection8<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 2152 arg5_type, arg6_type, arg7_type, arg8_type, mt_p
olicy>(*this); | |
| 2153 } | |
| 2154 | |
| 2155 virtual _connection_base8<arg1_type, arg2_type, arg3_type, arg4_
type, | |
| 2156 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>*
duplicate(has_slots_interface* pnewdest) | |
| 2157 { | |
| 2158 return new _connection8<dest_type, arg1_type, arg2_type,
arg3_type, arg4_type, | |
| 2159 arg5_type, arg6_type, arg7_type, arg8_type, mt_p
olicy>((dest_type *)pnewdest, m_pmemfun); | |
| 2160 } | |
| 2161 | |
| 2162 virtual void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4
_type a4, | |
| 2163 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) | |
| 2164 { | |
| 2165 (m_pobject->*m_pmemfun)(a1, a2, a3, a4, a5, a6, a7, a8); | |
| 2166 } | |
| 2167 | |
| 2168 virtual has_slots_interface* getdest() const | |
| 2169 { | |
| 2170 return m_pobject; | |
| 2171 } | |
| 2172 | |
| 2173 private: | |
| 2174 dest_type* m_pobject; | |
| 2175 void (dest_type::* m_pmemfun)(arg1_type, arg2_type, arg3_type, a
rg4_type, | |
| 2176 arg5_type, arg6_type, arg7_type, arg8_type); | |
| 2177 }; | |
| 2178 | |
| 2179 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 2180 class signal0 : public _signal_base0<mt_policy> | |
| 2181 { | |
| 2182 public: | |
| 2183 typedef _signal_base0<mt_policy> base; | |
| 2184 typedef typename base::connections_list connections_list; | |
| 2185 using base::m_connected_slots; | |
| 2186 | |
| 2187 signal0() | |
| 2188 { | |
| 2189 ; | |
| 2190 } | |
| 2191 | |
| 2192 signal0(const signal0<mt_policy>& s) | |
| 2193 : _signal_base0<mt_policy>(s) | |
| 2194 { | |
| 2195 ; | |
| 2196 } | |
| 2197 | |
| 2198 template<class desttype> | |
| 2199 void connect(desttype* pclass, void (desttype::*pmemfun)
()) | |
| 2200 { | |
| 2201 lock_block<mt_policy> lock(this); | |
| 2202 _connection0<desttype, mt_policy>* conn = | |
| 2203 new _connection0<desttype, mt_policy>(pclass, pm
emfun); | |
| 2204 m_connected_slots.push_back(conn); | |
| 2205 pclass->signal_connect(this); | |
| 2206 } | |
| 2207 | |
| 2208 void emit() | |
| 2209 { | |
| 2210 lock_block<mt_policy> lock(this); | |
| 2211 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2212 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2213 | |
| 2214 while(it != itEnd) | |
| 2215 { | |
| 2216 itNext = it; | |
| 2217 ++itNext; | |
| 2218 | |
| 2219 (*it)->emit(); | |
| 2220 | |
| 2221 it = itNext; | |
| 2222 } | |
| 2223 } | |
| 2224 | |
| 2225 void operator()() | |
| 2226 { | |
| 2227 lock_block<mt_policy> lock(this); | |
| 2228 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2229 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2230 | |
| 2231 while(it != itEnd) | |
| 2232 { | |
| 2233 itNext = it; | |
| 2234 ++itNext; | |
| 2235 | |
| 2236 (*it)->emit(); | |
| 2237 | |
| 2238 it = itNext; | |
| 2239 } | |
| 2240 } | |
| 2241 }; | |
| 2242 | |
| 2243 template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 2244 class signal1 : public _signal_base1<arg1_type, mt_policy> | |
| 2245 { | |
| 2246 public: | |
| 2247 typedef _signal_base1<arg1_type, mt_policy> base; | |
| 2248 typedef typename base::connections_list connections_list; | |
| 2249 using base::m_connected_slots; | |
| 2250 | |
| 2251 signal1() | |
| 2252 { | |
| 2253 ; | |
| 2254 } | |
| 2255 | |
| 2256 signal1(const signal1<arg1_type, mt_policy>& s) | |
| 2257 : _signal_base1<arg1_type, mt_policy>(s) | |
| 2258 { | |
| 2259 ; | |
| 2260 } | |
| 2261 | |
| 2262 template<class desttype> | |
| 2263 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type)) | |
| 2264 { | |
| 2265 lock_block<mt_policy> lock(this); | |
| 2266 _connection1<desttype, arg1_type, mt_policy>* conn = | |
| 2267 new _connection1<desttype, arg1_type, mt_policy>
(pclass, pmemfun); | |
| 2268 m_connected_slots.push_back(conn); | |
| 2269 pclass->signal_connect(this); | |
| 2270 } | |
| 2271 | |
| 2272 void emit(arg1_type a1) | |
| 2273 { | |
| 2274 lock_block<mt_policy> lock(this); | |
| 2275 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2276 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2277 | |
| 2278 while(it != itEnd) | |
| 2279 { | |
| 2280 itNext = it; | |
| 2281 ++itNext; | |
| 2282 | |
| 2283 (*it)->emit(a1); | |
| 2284 | |
| 2285 it = itNext; | |
| 2286 } | |
| 2287 } | |
| 2288 | |
| 2289 void operator()(arg1_type a1) | |
| 2290 { | |
| 2291 lock_block<mt_policy> lock(this); | |
| 2292 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2293 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2294 | |
| 2295 while(it != itEnd) | |
| 2296 { | |
| 2297 itNext = it; | |
| 2298 ++itNext; | |
| 2299 | |
| 2300 (*it)->emit(a1); | |
| 2301 | |
| 2302 it = itNext; | |
| 2303 } | |
| 2304 } | |
| 2305 }; | |
| 2306 | |
| 2307 template<class arg1_type, class arg2_type, class mt_policy = SIGSLOT_DEF
AULT_MT_POLICY> | |
| 2308 class signal2 : public _signal_base2<arg1_type, arg2_type, mt_policy> | |
| 2309 { | |
| 2310 public: | |
| 2311 typedef _signal_base2<arg1_type, arg2_type, mt_policy> base; | |
| 2312 typedef typename base::connections_list connections_list; | |
| 2313 using base::m_connected_slots; | |
| 2314 | |
| 2315 signal2() | |
| 2316 { | |
| 2317 ; | |
| 2318 } | |
| 2319 | |
| 2320 signal2(const signal2<arg1_type, arg2_type, mt_policy>& s) | |
| 2321 : _signal_base2<arg1_type, arg2_type, mt_policy>(s) | |
| 2322 { | |
| 2323 ; | |
| 2324 } | |
| 2325 | |
| 2326 template<class desttype> | |
| 2327 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2328 arg2_type)) | |
| 2329 { | |
| 2330 lock_block<mt_policy> lock(this); | |
| 2331 _connection2<desttype, arg1_type, arg2_type, mt_policy>*
conn = new | |
| 2332 _connection2<desttype, arg1_type, arg2_type, mt_
policy>(pclass, pmemfun); | |
| 2333 m_connected_slots.push_back(conn); | |
| 2334 pclass->signal_connect(this); | |
| 2335 } | |
| 2336 | |
| 2337 void emit(arg1_type a1, arg2_type a2) | |
| 2338 { | |
| 2339 lock_block<mt_policy> lock(this); | |
| 2340 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2341 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2342 | |
| 2343 while(it != itEnd) | |
| 2344 { | |
| 2345 itNext = it; | |
| 2346 ++itNext; | |
| 2347 | |
| 2348 (*it)->emit(a1, a2); | |
| 2349 | |
| 2350 it = itNext; | |
| 2351 } | |
| 2352 } | |
| 2353 | |
| 2354 void operator()(arg1_type a1, arg2_type a2) | |
| 2355 { | |
| 2356 lock_block<mt_policy> lock(this); | |
| 2357 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2358 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2359 | |
| 2360 while(it != itEnd) | |
| 2361 { | |
| 2362 itNext = it; | |
| 2363 ++itNext; | |
| 2364 | |
| 2365 (*it)->emit(a1, a2); | |
| 2366 | |
| 2367 it = itNext; | |
| 2368 } | |
| 2369 } | |
| 2370 }; | |
| 2371 | |
| 2372 template<class arg1_type, class arg2_type, class arg3_type, class mt_pol
icy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 2373 class signal3 : public _signal_base3<arg1_type, arg2_type, arg3_type, mt
_policy> | |
| 2374 { | |
| 2375 public: | |
| 2376 typedef _signal_base3<arg1_type, arg2_type, arg3_type, mt_policy
> base; | |
| 2377 typedef typename base::connections_list connections_list; | |
| 2378 using base::m_connected_slots; | |
| 2379 | |
| 2380 signal3() | |
| 2381 { | |
| 2382 ; | |
| 2383 } | |
| 2384 | |
| 2385 signal3(const signal3<arg1_type, arg2_type, arg3_type, mt_policy
>& s) | |
| 2386 : _signal_base3<arg1_type, arg2_type, arg3_type, mt_poli
cy>(s) | |
| 2387 { | |
| 2388 ; | |
| 2389 } | |
| 2390 | |
| 2391 template<class desttype> | |
| 2392 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2393 arg2_type, arg3_type)) | |
| 2394 { | |
| 2395 lock_block<mt_policy> lock(this); | |
| 2396 _connection3<desttype, arg1_type, arg2_type, arg3_type,
mt_policy>* conn = | |
| 2397 new _connection3<desttype, arg1_type, arg2_type,
arg3_type, mt_policy>(pclass, | |
| 2398 pmemfun); | |
| 2399 m_connected_slots.push_back(conn); | |
| 2400 pclass->signal_connect(this); | |
| 2401 } | |
| 2402 | |
| 2403 void emit(arg1_type a1, arg2_type a2, arg3_type a3) | |
| 2404 { | |
| 2405 lock_block<mt_policy> lock(this); | |
| 2406 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2407 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2408 | |
| 2409 while(it != itEnd) | |
| 2410 { | |
| 2411 itNext = it; | |
| 2412 ++itNext; | |
| 2413 | |
| 2414 (*it)->emit(a1, a2, a3); | |
| 2415 | |
| 2416 it = itNext; | |
| 2417 } | |
| 2418 } | |
| 2419 | |
| 2420 void operator()(arg1_type a1, arg2_type a2, arg3_type a3) | |
| 2421 { | |
| 2422 lock_block<mt_policy> lock(this); | |
| 2423 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2424 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2425 | |
| 2426 while(it != itEnd) | |
| 2427 { | |
| 2428 itNext = it; | |
| 2429 ++itNext; | |
| 2430 | |
| 2431 (*it)->emit(a1, a2, a3); | |
| 2432 | |
| 2433 it = itNext; | |
| 2434 } | |
| 2435 } | |
| 2436 }; | |
| 2437 | |
| 2438 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 2439 class signal4 : public _signal_base4<arg1_type, arg2_type, arg3_type, | |
| 2440 arg4_type, mt_policy> | |
| 2441 { | |
| 2442 public: | |
| 2443 typedef _signal_base4<arg1_type, arg2_type, arg3_type, arg4_type
, mt_policy> base; | |
| 2444 typedef typename base::connections_list connections_list; | |
| 2445 using base::m_connected_slots; | |
| 2446 | |
| 2447 signal4() | |
| 2448 { | |
| 2449 ; | |
| 2450 } | |
| 2451 | |
| 2452 signal4(const signal4<arg1_type, arg2_type, arg3_type, arg4_type
, mt_policy>& s) | |
| 2453 : _signal_base4<arg1_type, arg2_type, arg3_type, arg4_ty
pe, mt_policy>(s) | |
| 2454 { | |
| 2455 ; | |
| 2456 } | |
| 2457 | |
| 2458 template<class desttype> | |
| 2459 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2460 arg2_type, arg3_type, arg4_type)) | |
| 2461 { | |
| 2462 lock_block<mt_policy> lock(this); | |
| 2463 _connection4<desttype, arg1_type, arg2_type, arg3_type,
arg4_type, mt_policy>* | |
| 2464 conn = new _connection4<desttype, arg1_type, arg
2_type, arg3_type, | |
| 2465 arg4_type, mt_policy>(pclass, pmemfun); | |
| 2466 m_connected_slots.push_back(conn); | |
| 2467 pclass->signal_connect(this); | |
| 2468 } | |
| 2469 | |
| 2470 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
) | |
| 2471 { | |
| 2472 lock_block<mt_policy> lock(this); | |
| 2473 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2474 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2475 | |
| 2476 while(it != itEnd) | |
| 2477 { | |
| 2478 itNext = it; | |
| 2479 ++itNext; | |
| 2480 | |
| 2481 (*it)->emit(a1, a2, a3, a4); | |
| 2482 | |
| 2483 it = itNext; | |
| 2484 } | |
| 2485 } | |
| 2486 | |
| 2487 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4) | |
| 2488 { | |
| 2489 lock_block<mt_policy> lock(this); | |
| 2490 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2491 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2492 | |
| 2493 while(it != itEnd) | |
| 2494 { | |
| 2495 itNext = it; | |
| 2496 ++itNext; | |
| 2497 | |
| 2498 (*it)->emit(a1, a2, a3, a4); | |
| 2499 | |
| 2500 it = itNext; | |
| 2501 } | |
| 2502 } | |
| 2503 }; | |
| 2504 | |
| 2505 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 2506 class arg5_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 2507 class signal5 : public _signal_base5<arg1_type, arg2_type, arg3_type, | |
| 2508 arg4_type, arg5_type, mt_policy> | |
| 2509 { | |
| 2510 public: | |
| 2511 typedef _signal_base5<arg1_type, arg2_type, arg3_type, arg4_type
, arg5_type, mt_policy> base; | |
| 2512 typedef typename base::connections_list connections_list; | |
| 2513 using base::m_connected_slots; | |
| 2514 | |
| 2515 signal5() | |
| 2516 { | |
| 2517 ; | |
| 2518 } | |
| 2519 | |
| 2520 signal5(const signal5<arg1_type, arg2_type, arg3_type, arg4_type
, | |
| 2521 arg5_type, mt_policy>& s) | |
| 2522 : _signal_base5<arg1_type, arg2_type, arg3_type, arg4_ty
pe, | |
| 2523 arg5_type, mt_policy>(s) | |
| 2524 { | |
| 2525 ; | |
| 2526 } | |
| 2527 | |
| 2528 template<class desttype> | |
| 2529 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2530 arg2_type, arg3_type, arg4_type, arg5_type)) | |
| 2531 { | |
| 2532 lock_block<mt_policy> lock(this); | |
| 2533 _connection5<desttype, arg1_type, arg2_type, arg3_type,
arg4_type, | |
| 2534 arg5_type, mt_policy>* conn = new _connection5<d
esttype, arg1_type, arg2_type, | |
| 2535 arg3_type, arg4_type, arg5_type, mt_policy>(pcla
ss, pmemfun); | |
| 2536 m_connected_slots.push_back(conn); | |
| 2537 pclass->signal_connect(this); | |
| 2538 } | |
| 2539 | |
| 2540 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, | |
| 2541 arg5_type a5) | |
| 2542 { | |
| 2543 lock_block<mt_policy> lock(this); | |
| 2544 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2545 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2546 | |
| 2547 while(it != itEnd) | |
| 2548 { | |
| 2549 itNext = it; | |
| 2550 ++itNext; | |
| 2551 | |
| 2552 (*it)->emit(a1, a2, a3, a4, a5); | |
| 2553 | |
| 2554 it = itNext; | |
| 2555 } | |
| 2556 } | |
| 2557 | |
| 2558 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, | |
| 2559 arg5_type a5) | |
| 2560 { | |
| 2561 lock_block<mt_policy> lock(this); | |
| 2562 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2563 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2564 | |
| 2565 while(it != itEnd) | |
| 2566 { | |
| 2567 itNext = it; | |
| 2568 ++itNext; | |
| 2569 | |
| 2570 (*it)->emit(a1, a2, a3, a4, a5); | |
| 2571 | |
| 2572 it = itNext; | |
| 2573 } | |
| 2574 } | |
| 2575 }; | |
| 2576 | |
| 2577 | |
| 2578 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 2579 class arg5_type, class arg6_type, class mt_policy = SIGSLOT_DEFAULT_MT_P
OLICY> | |
| 2580 class signal6 : public _signal_base6<arg1_type, arg2_type, arg3_type, | |
| 2581 arg4_type, arg5_type, arg6_type, mt_policy> | |
| 2582 { | |
| 2583 public: | |
| 2584 typedef _signal_base6<arg1_type, arg2_type, arg3_type, arg4_type
, arg5_type, arg6_type, mt_policy> base; | |
| 2585 typedef typename base::connections_list connections_list; | |
| 2586 using base::m_connected_slots; | |
| 2587 | |
| 2588 signal6() | |
| 2589 { | |
| 2590 ; | |
| 2591 } | |
| 2592 | |
| 2593 signal6(const signal6<arg1_type, arg2_type, arg3_type, arg4_type
, | |
| 2594 arg5_type, arg6_type, mt_policy>& s) | |
| 2595 : _signal_base6<arg1_type, arg2_type, arg3_type, arg4_ty
pe, | |
| 2596 arg5_type, arg6_type, mt_policy>(s) | |
| 2597 { | |
| 2598 ; | |
| 2599 } | |
| 2600 | |
| 2601 template<class desttype> | |
| 2602 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2603 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type)) | |
| 2604 { | |
| 2605 lock_block<mt_policy> lock(this); | |
| 2606 _connection6<desttype, arg1_type, arg2_type, arg3_type,
arg4_type, | |
| 2607 arg5_type, arg6_type, mt_policy>* conn = | |
| 2608 new _connection6<desttype, arg1_type, arg2_type,
arg3_type, | |
| 2609 arg4_type, arg5_type, arg6_type, mt_policy>(pcla
ss, pmemfun); | |
| 2610 m_connected_slots.push_back(conn); | |
| 2611 pclass->signal_connect(this); | |
| 2612 } | |
| 2613 | |
| 2614 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, | |
| 2615 arg5_type a5, arg6_type a6) | |
| 2616 { | |
| 2617 lock_block<mt_policy> lock(this); | |
| 2618 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2619 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2620 | |
| 2621 while(it != itEnd) | |
| 2622 { | |
| 2623 itNext = it; | |
| 2624 ++itNext; | |
| 2625 | |
| 2626 (*it)->emit(a1, a2, a3, a4, a5, a6); | |
| 2627 | |
| 2628 it = itNext; | |
| 2629 } | |
| 2630 } | |
| 2631 | |
| 2632 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, | |
| 2633 arg5_type a5, arg6_type a6) | |
| 2634 { | |
| 2635 lock_block<mt_policy> lock(this); | |
| 2636 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2637 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2638 | |
| 2639 while(it != itEnd) | |
| 2640 { | |
| 2641 itNext = it; | |
| 2642 ++itNext; | |
| 2643 | |
| 2644 (*it)->emit(a1, a2, a3, a4, a5, a6); | |
| 2645 | |
| 2646 it = itNext; | |
| 2647 } | |
| 2648 } | |
| 2649 }; | |
| 2650 | |
| 2651 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 2652 class arg5_type, class arg6_type, class arg7_type, class mt_policy = SIG
SLOT_DEFAULT_MT_POLICY> | |
| 2653 class signal7 : public _signal_base7<arg1_type, arg2_type, arg3_type, | |
| 2654 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> | |
| 2655 { | |
| 2656 public: | |
| 2657 typedef _signal_base7<arg1_type, arg2_type, arg3_type, arg4_type
, | |
| 2658 arg5_type, arg6_type, arg7_type, mt_policy> base; | |
| 2659 typedef typename base::connections_list connections_list; | |
| 2660 using base::m_connected_slots; | |
| 2661 | |
| 2662 signal7() | |
| 2663 { | |
| 2664 ; | |
| 2665 } | |
| 2666 | |
| 2667 signal7(const signal7<arg1_type, arg2_type, arg3_type, arg4_type
, | |
| 2668 arg5_type, arg6_type, arg7_type, mt_policy>& s) | |
| 2669 : _signal_base7<arg1_type, arg2_type, arg3_type, arg4_ty
pe, | |
| 2670 arg5_type, arg6_type, arg7_type, mt_policy>(s) | |
| 2671 { | |
| 2672 ; | |
| 2673 } | |
| 2674 | |
| 2675 template<class desttype> | |
| 2676 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2677 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, | |
| 2678 arg7_type)) | |
| 2679 { | |
| 2680 lock_block<mt_policy> lock(this); | |
| 2681 _connection7<desttype, arg1_type, arg2_type, arg3_type,
arg4_type, | |
| 2682 arg5_type, arg6_type, arg7_type, mt_policy>* con
n = | |
| 2683 new _connection7<desttype, arg1_type, arg2_type,
arg3_type, | |
| 2684 arg4_type, arg5_type, arg6_type, arg7_type, mt_p
olicy>(pclass, pmemfun); | |
| 2685 m_connected_slots.push_back(conn); | |
| 2686 pclass->signal_connect(this); | |
| 2687 } | |
| 2688 | |
| 2689 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, | |
| 2690 arg5_type a5, arg6_type a6, arg7_type a7) | |
| 2691 { | |
| 2692 lock_block<mt_policy> lock(this); | |
| 2693 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2694 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2695 | |
| 2696 while(it != itEnd) | |
| 2697 { | |
| 2698 itNext = it; | |
| 2699 ++itNext; | |
| 2700 | |
| 2701 (*it)->emit(a1, a2, a3, a4, a5, a6, a7); | |
| 2702 | |
| 2703 it = itNext; | |
| 2704 } | |
| 2705 } | |
| 2706 | |
| 2707 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, | |
| 2708 arg5_type a5, arg6_type a6, arg7_type a7) | |
| 2709 { | |
| 2710 lock_block<mt_policy> lock(this); | |
| 2711 typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | |
| 2712 typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | |
| 2713 | |
| 2714 while(it != itEnd) | |
| 2715 { | |
| 2716 itNext = it; | |
| 2717 ++itNext; | |
| 2718 | |
| 2719 (*it)->emit(a1, a2, a3, a4, a5, a6, a7); | |
| 2720 | |
| 2721 it = itNext; | |
| 2722 } | |
| 2723 } | |
| 2724 }; | |
| 2725 | |
| 2726 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t
ype, | |
| 2727 class arg5_type, class arg6_type, class arg7_type, class arg8_type, clas
s mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 2728 class signal8 : public _signal_base8<arg1_type, arg2_type, arg3_type, | |
| 2729 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, mt_policy
> | |
| 2730 { | |
| 2731 public: | |
| 2732 typedef _signal_base8<arg1_type, arg2_type, arg3_type, arg4_type
, | |
| 2733 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy> b
ase; | |
| 2734 typedef typename base::connections_list connections_list; | |
| 2735 using base::m_connected_slots; | |
| 2736 | |
| 2737 signal8() | |
| 2738 { | |
| 2739 ; | |
| 2740 } | |
| 2741 | |
| 2742 signal8(const signal8<arg1_type, arg2_type, arg3_type, arg4_type
, | |
| 2743 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>&
s) | |
| 2744 : _signal_base8<arg1_type, arg2_type, arg3_type, arg4_ty
pe, | |
| 2745 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>(s
) | |
| 2746 { | |
| 2747 ; | |
| 2748 } | |
| 2749 | |
| 2750 template<class desttype> | |
| 2751 void connect(desttype* pclass, void (desttype::*pmemfun)
(arg1_type, | |
| 2752 arg2_type, arg3_type, arg4_type, arg5_type, arg6_type, | |
| 2753 arg7_type, arg8_type)) | |
| 2754 { | |
| 2755 lock_block<mt_policy> lock(this); | |
| 2756 _connection8<desttype, arg1_type, arg2_type, arg3_type,
arg4_type, | |
| 2757 arg5_type, arg6_type, arg7_type, arg8_type, mt_p
olicy>* conn = | |
| 2758 new _connection8<desttype, arg1_type, arg2_type,
arg3_type, | |
| 2759 arg4_type, arg5_type, arg6_type, arg7_type, | |
| 2760 arg8_type, mt_policy>(pclass, pmemfun); | |
| 2761 m_connected_slots.push_back(conn); | |
| 2762 pclass->signal_connect(this); | |
| 2763 } | 1226 } |
| 2764 | 1227 |
| 2765 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, | 1228 void emit(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4
, |
| 2766 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) | 1229 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) |
| 2767 { | 1230 { |
| 2768 lock_block<mt_policy> lock(this); | 1231 lock_block<mt_policy> lock(this); |
| 2769 » » » typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | 1232 » » » typename connections_list::const_iterator it = this->m_c
onnected_slots.begin(); |
| 2770 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 1233 » » » typename connections_list::const_iterator itEnd = this->
m_connected_slots.end(); |
| 2771 | 1234 |
| 2772 » » » while(it != itEnd) | 1235 » » » while(it != itEnd) |
| 2773 » » » { | 1236 » » » { |
| 2774 » » » » itNext = it; | 1237 » » » » _opaque_connection const& conn = *it; |
| 2775 » » » » ++itNext; | 1238 » » » » ++it; |
| 2776 | 1239 |
| 2777 » » » » (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8); | 1240 » » » » conn.emit<arg1_type, arg2_type, arg3_type, arg4_
type, arg5_type, arg6_type, arg7_type, arg8_type>(a1, a2, a3, a4, a5, a6, a7, a8
); |
| 2778 | |
| 2779 » » » » it = itNext; | |
| 2780 } | 1241 } |
| 2781 } | 1242 } |
| 2782 | 1243 |
| 2783 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, | 1244 void operator()(arg1_type a1, arg2_type a2, arg3_type a3, arg4_t
ype a4, |
| 2784 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) | 1245 arg5_type a5, arg6_type a6, arg7_type a7, arg8_type a8) |
| 2785 { | 1246 { |
| 2786 » » » lock_block<mt_policy> lock(this); | 1247 » » » emit(a1, a2, a3, a4, a5, a6, a7, a8); |
| 2787 » » » typename connections_list::const_iterator itNext, it = m
_connected_slots.begin(); | 1248 » » } |
| 2788 » » » typename connections_list::const_iterator itEnd = m_conn
ected_slots.end(); | 1249 » }; |
| 2789 | 1250 |
| 2790 » » » while(it != itEnd) | 1251 } // namespace sigslot |
| 2791 » » » { | |
| 2792 » » » » itNext = it; | |
| 2793 » » » » ++itNext; | |
| 2794 | |
| 2795 » » » » (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8); | |
| 2796 | |
| 2797 » » » » it = itNext; | |
| 2798 » » » } | |
| 2799 » » } | |
| 2800 » }; | |
| 2801 | |
| 2802 }; // namespace sigslot | |
| 2803 | 1252 |
| 2804 #endif // WEBRTC_BASE_SIGSLOT_H__ | 1253 #endif // WEBRTC_BASE_SIGSLOT_H__ |
| OLD | NEW |