Chromium Code Reviews| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 // has_slots<single_threaded> and signal0<multi_threaded_local> or | 80 // has_slots<single_threaded> and signal0<multi_threaded_local> or |
| 81 // has_slots<multi_threaded_local> and signal0<single_threaded>. | 81 // has_slots<multi_threaded_local> and signal0<single_threaded>. |
| 82 // If has_slots is single threaded the user must ensure that it is not trying | 82 // If has_slots is single threaded the user must ensure that it is not trying |
| 83 // to connect or disconnect to signalx concurrently or data race may occur. | 83 // to connect or disconnect to signalx concurrently or data race may occur. |
| 84 // If signalx is single threaded the user must ensure that disconnect, connect | 84 // If signalx is single threaded the user must ensure that disconnect, connect |
| 85 // or signal is not happening concurrently or data race may occur. | 85 // or signal is not happening concurrently or data race may occur. |
| 86 | 86 |
| 87 #ifndef WEBRTC_BASE_SIGSLOT_H__ | 87 #ifndef WEBRTC_BASE_SIGSLOT_H__ |
| 88 #define WEBRTC_BASE_SIGSLOT_H__ | 88 #define WEBRTC_BASE_SIGSLOT_H__ |
| 89 | 89 |
| 90 #include <cstring> | |
| 90 #include <list> | 91 #include <list> |
| 91 #include <set> | 92 #include <set> |
| 92 #include <stdlib.h> | 93 #include <stdlib.h> |
| 93 | 94 |
| 94 // On our copy of sigslot.h, we set single threading as default. | 95 // On our copy of sigslot.h, we set single threading as default. |
| 95 #define SIGSLOT_DEFAULT_MT_POLICY single_threaded | 96 #define SIGSLOT_DEFAULT_MT_POLICY single_threaded |
| 96 | 97 |
| 97 #if defined(SIGSLOT_PURE_ISO) || (!defined(WEBRTC_WIN) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS)) | 98 #if defined(SIGSLOT_PURE_ISO) || (!defined(WEBRTC_WIN) && !defined(__GNUG__) && !defined(SIGSLOT_USE_POSIX_THREADS)) |
| 98 # define _SIGSLOT_SINGLE_THREADED | 99 # define _SIGSLOT_SINGLE_THREADED |
| 99 #elif defined(WEBRTC_WIN) | 100 #elif defined(WEBRTC_WIN) |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 116 # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local | 117 # define SIGSLOT_DEFAULT_MT_POLICY multi_threaded_local |
| 117 # endif | 118 # endif |
| 118 #endif | 119 #endif |
| 119 | 120 |
| 120 // TODO: change this namespace to rtc? | 121 // TODO: change this namespace to rtc? |
| 121 namespace sigslot { | 122 namespace sigslot { |
| 122 | 123 |
| 123 class single_threaded | 124 class single_threaded |
| 124 { | 125 { |
| 125 public: | 126 public: |
| 126 » » single_threaded() | 127 » » void lock() {} |
| 127 » » { | 128 » » void unlock() {} |
| 128 » » » ; | 129 » }; |
| 129 » » } | |
| 130 | |
| 131 virtual ~single_threaded() {} | |
| 132 | |
| 133 virtual void lock() {} | |
| 134 | |
| 135 virtual void unlock() {} | |
| 136 }; | |
| 137 | 130 |
| 138 #ifdef _SIGSLOT_HAS_WIN32_THREADS | 131 #ifdef _SIGSLOT_HAS_WIN32_THREADS |
| 139 // The multi threading policies only get compiled in if they are enabled . | 132 // The multi threading policies only get compiled in if they are enabled . |
| 140 class multi_threaded_global | 133 class multi_threaded_global |
| 141 { | 134 { |
| 142 public: | 135 public: |
| 143 multi_threaded_global() | 136 multi_threaded_global() |
| 144 { | 137 { |
| 145 static bool isinitialised = false; | 138 static bool isinitialised = false; |
| 146 | 139 |
| 147 if(!isinitialised) | 140 if(!isinitialised) |
| 148 { | 141 { |
| 149 InitializeCriticalSection(get_critsec()); | 142 InitializeCriticalSection(get_critsec()); |
| 150 isinitialised = true; | 143 isinitialised = true; |
| 151 } | 144 } |
| 152 } | 145 } |
| 153 | 146 |
| 154 » » multi_threaded_global(const multi_threaded_global&) | 147 » » void lock() |
| 155 » » { | |
| 156 » » » ; | |
| 157 » » } | |
| 158 | |
| 159 » » virtual ~multi_threaded_global() | |
| 160 » » { | |
| 161 » » » ; | |
| 162 » » } | |
| 163 | |
| 164 » » virtual void lock() | |
| 165 { | 148 { |
| 166 EnterCriticalSection(get_critsec()); | 149 EnterCriticalSection(get_critsec()); |
| 167 } | 150 } |
| 168 | 151 |
| 169 » » virtual void unlock() | 152 » » void unlock() |
| 170 { | 153 { |
| 171 LeaveCriticalSection(get_critsec()); | 154 LeaveCriticalSection(get_critsec()); |
| 172 } | 155 } |
| 173 | 156 |
| 174 private: | 157 private: |
| 175 CRITICAL_SECTION* get_critsec() | 158 CRITICAL_SECTION* get_critsec() |
| 176 { | 159 { |
| 177 static CRITICAL_SECTION g_critsec; | 160 static CRITICAL_SECTION g_critsec; |
| 178 return &g_critsec; | 161 return &g_critsec; |
| 179 } | 162 } |
| 180 }; | 163 }; |
| 181 | 164 |
| 182 class multi_threaded_local | 165 class multi_threaded_local |
| 183 { | 166 { |
| 184 public: | 167 public: |
| 185 multi_threaded_local() | 168 multi_threaded_local() |
| 186 { | 169 { |
| 187 InitializeCriticalSection(&m_critsec); | 170 InitializeCriticalSection(&m_critsec); |
| 188 } | 171 } |
| 189 | 172 |
| 190 multi_threaded_local(const multi_threaded_local&) | 173 multi_threaded_local(const multi_threaded_local&) |
| 191 { | 174 { |
| 192 InitializeCriticalSection(&m_critsec); | 175 InitializeCriticalSection(&m_critsec); |
| 193 } | 176 } |
| 194 | 177 |
| 195 » » virtual ~multi_threaded_local() | 178 » » ~multi_threaded_local() |
| 196 { | 179 { |
| 197 DeleteCriticalSection(&m_critsec); | 180 DeleteCriticalSection(&m_critsec); |
| 198 } | 181 } |
| 199 | 182 |
| 200 » » virtual void lock() | 183 » » void lock() |
| 201 { | 184 { |
| 202 EnterCriticalSection(&m_critsec); | 185 EnterCriticalSection(&m_critsec); |
| 203 } | 186 } |
| 204 | 187 |
| 205 » » virtual void unlock() | 188 » » void unlock() |
| 206 { | 189 { |
| 207 LeaveCriticalSection(&m_critsec); | 190 LeaveCriticalSection(&m_critsec); |
| 208 } | 191 } |
| 209 | 192 |
| 210 private: | 193 private: |
| 211 CRITICAL_SECTION m_critsec; | 194 CRITICAL_SECTION m_critsec; |
| 212 }; | 195 }; |
| 213 #endif // _SIGSLOT_HAS_WIN32_THREADS | 196 #endif // _SIGSLOT_HAS_WIN32_THREADS |
| 214 | 197 |
| 215 #ifdef _SIGSLOT_HAS_POSIX_THREADS | 198 #ifdef _SIGSLOT_HAS_POSIX_THREADS |
| 216 // The multi threading policies only get compiled in if they are enabled . | 199 // The multi threading policies only get compiled in if they are enabled . |
| 217 class multi_threaded_global | 200 class multi_threaded_global |
| 218 { | 201 { |
| 219 public: | 202 public: |
| 220 multi_threaded_global(); | 203 » » void lock() |
| 221 multi_threaded_global(const multi_threaded_global&); | 204 » » { |
| 222 virtual ~multi_threaded_global(); | 205 » » » pthread_mutex_lock(get_mutex()); |
| 223 virtual void lock(); | 206 » » } |
| 224 virtual void unlock(); | 207 » » void unlock() |
| 208 » » { | |
| 209 » » » pthread_mutex_unlock(get_mutex()); | |
| 210 » » } | |
| 225 | 211 |
| 226 private: | 212 » private: |
| 227 » » pthread_mutex_t* get_mutex() | 213 » » static pthread_mutex_t* get_mutex(); |
| 228 » » { | |
| 229 » » » static pthread_mutex_t g_mutex; | |
| 230 » » » return &g_mutex; | |
| 231 » » } | |
| 232 }; | 214 }; |
| 233 | 215 |
| 234 class multi_threaded_local | 216 class multi_threaded_local |
| 235 { | 217 { |
| 236 public: | 218 public: |
| 237 multi_threaded_local(); | 219 » » multi_threaded_local() |
| 238 multi_threaded_local(const multi_threaded_local&); | 220 » » { |
| 239 virtual ~multi_threaded_local(); | 221 » » » pthread_mutex_init(&m_mutex, NULL); |
| 240 virtual void lock(); | 222 » » } |
| 241 virtual void unlock(); | 223 » » multi_threaded_local(const multi_threaded_local&) |
| 224 » » { | |
| 225 » » » pthread_mutex_init(&m_mutex, NULL); | |
| 226 » » } | |
| 227 » » ~multi_threaded_local() | |
| 228 » » { | |
| 229 » » » pthread_mutex_destroy(&m_mutex); | |
| 230 » » } | |
| 231 » » void lock() | |
| 232 » » { | |
| 233 » » » pthread_mutex_lock(&m_mutex); | |
| 234 » » } | |
| 235 » » void unlock() | |
| 236 » » { | |
| 237 » » » pthread_mutex_unlock(&m_mutex); | |
| 238 » » } | |
| 242 | 239 |
| 243 private: | 240 » private: |
| 244 pthread_mutex_t m_mutex; | 241 pthread_mutex_t m_mutex; |
| 245 }; | 242 }; |
| 246 #endif // _SIGSLOT_HAS_POSIX_THREADS | 243 #endif // _SIGSLOT_HAS_POSIX_THREADS |
| 247 | 244 |
| 248 template<class mt_policy> | 245 template<class mt_policy> |
| 249 class lock_block | 246 class lock_block |
| 250 { | 247 { |
| 251 public: | 248 public: |
| 252 mt_policy *m_mutex; | 249 mt_policy *m_mutex; |
| 253 | 250 |
| 254 lock_block(mt_policy *mtx) | 251 lock_block(mt_policy *mtx) |
| 255 : m_mutex(mtx) | 252 : m_mutex(mtx) |
| 256 { | 253 { |
| 257 m_mutex->lock(); | 254 m_mutex->lock(); |
| 258 } | 255 } |
| 259 | 256 |
| 260 ~lock_block() | 257 ~lock_block() |
| 261 { | 258 { |
| 262 m_mutex->unlock(); | 259 m_mutex->unlock(); |
| 263 } | 260 } |
| 264 }; | 261 }; |
| 265 | 262 |
| 266 » class has_slots_interface; | 263 » class _signal_base_interface; |
| 267 | 264 |
| 268 » template<class mt_policy> | 265 » class has_slots_interface |
| 269 » class _connection_base0 | |
| 270 { | 266 { |
| 267 private: | |
| 268 typedef void (*signal_connect_t)(has_slots_interface* self, _sig nal_base_interface* sender); | |
| 269 typedef void (*signal_disconnect_t)(has_slots_interface* self, _ signal_base_interface* sender); | |
| 270 typedef void (*disconnect_all_t)(has_slots_interface* self); | |
| 271 | |
| 272 const signal_connect_t m_signal_connect; | |
| 273 const signal_disconnect_t m_signal_disconnect; | |
| 274 const disconnect_all_t m_disconnect_all; | |
| 275 | |
| 276 protected: | |
| 277 has_slots_interface(signal_connect_t conn, signal_disconnect_t d isc, disconnect_all_t disc_all) : | |
| 278 m_signal_connect(conn), m_signal_disconnect(disc), m_dis connect_all(disc_all) | |
| 279 { | |
| 280 } | |
| 281 | |
| 282 // Doesn't really need to be virtual, but is for backwards compa tibility | |
| 283 // (it was virtual in a previous version of sigslot). | |
| 284 virtual ~has_slots_interface() {} | |
| 285 | |
| 271 public: | 286 public: |
| 272 » » virtual ~_connection_base0() {} | 287 » » void signal_connect(_signal_base_interface* sender) |
| 273 » » virtual has_slots_interface* getdest() const = 0; | 288 » » { |
| 274 » » virtual void emit() = 0; | 289 » » » m_signal_connect(this, sender); |
| 275 » » virtual _connection_base0* clone() = 0; | 290 » » } |
| 276 » » virtual _connection_base0* duplicate(has_slots_interface* pnewde st) = 0; | |
| 277 » }; | |
| 278 | 291 |
| 279 » template<class arg1_type, class mt_policy> | 292 » » void signal_disconnect(_signal_base_interface* sender) |
| 280 » class _connection_base1 | 293 » » { |
| 281 » { | 294 » » » m_signal_disconnect(this, sender); |
| 282 » public: | 295 » » } |
| 283 » » virtual ~_connection_base1() {} | |
| 284 » » virtual has_slots_interface* getdest() const = 0; | |
| 285 » » virtual void emit(arg1_type) = 0; | |
| 286 » » virtual _connection_base1<arg1_type, mt_policy>* clone() = 0; | |
| 287 » » virtual _connection_base1<arg1_type, mt_policy>* duplicate(has_s lots_interface* pnewdest) = 0; | |
| 288 » }; | |
| 289 | 296 |
| 290 » template<class arg1_type, class arg2_type, class mt_policy> | 297 » » void disconnect_all() |
| 291 » class _connection_base2 | 298 » » { |
| 292 » { | 299 » » » m_disconnect_all(this); |
| 293 » public: | 300 » » } |
| 294 » » virtual ~_connection_base2() {} | |
| 295 » » virtual has_slots_interface* getdest() const = 0; | |
| 296 » » virtual void emit(arg1_type, arg2_type) = 0; | |
| 297 » » virtual _connection_base2<arg1_type, arg2_type, mt_policy>* clon e() = 0; | |
| 298 » » virtual _connection_base2<arg1_type, arg2_type, mt_policy>* dupl icate(has_slots_interface* pnewdest) = 0; | |
| 299 » }; | |
| 300 | |
| 301 » template<class arg1_type, class arg2_type, class arg3_type, class mt_pol icy> | |
| 302 » class _connection_base3 | |
| 303 » { | |
| 304 » public: | |
| 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 { |
| 305 private: | |
| 306 typedef void (*slot_disconnect_t)(_signal_base_interface* self, has_slots_interface* pslot); | |
| 307 typedef void (*slot_duplicate_t)(_signal_base_interface* self, c onst has_slots_interface* poldslot, has_slots_interface* pnewslot); | |
| 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 | |
| 385 public: | 320 public: |
| 386 » » virtual ~_signal_base_interface() {} | 321 » » void slot_disconnect(has_slots_interface* pslot) |
| 387 » » virtual void slot_disconnect(has_slots_interface* pslot) = 0; | 322 » » { |
| 388 » » virtual void slot_duplicate(const has_slots_interface* poldslot, has_slots_interface* pnewslot) = 0; | 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 (*emit_t)(const _opaque_connection*); | |
| 336 » » template< typename FromT, typename ToT > | |
| 337 » » union union_caster | |
| 338 » » { | |
| 339 » » » FromT from; | |
| 340 » » » ToT to; | |
| 341 » » }; | |
| 342 | |
| 343 » » emit_t pemit; | |
| 344 » » has_slots_interface* pdest; | |
| 345 » » // Pointers to member functions may be up to 16 bytes for virtua l classes, | |
| 346 » » // so make sure we have enough space to store it. | |
| 347 » » unsigned char pmethod[16]; | |
| 348 | |
| 349 » public: | |
| 350 » » template< typename DestT, typename ... Args > | |
| 351 » » _opaque_connection(DestT* pd, void (DestT::*pm)(Args...)) : pdes t(pd) | |
| 352 » » { | |
| 353 » » » typedef void (DestT::*pm_t)(Args...); | |
| 354 » » » static_assert(sizeof(pm_t) <= sizeof(pmethod), "Size of slot function pointer too large."); | |
| 355 | |
| 356 » » » std::memcpy(pmethod, &pm, sizeof(pm_t)); | |
| 357 | |
| 358 » » » typedef void (*em_t)(const _opaque_connection* self, Arg s...); | |
| 359 » » » union_caster< em_t, emit_t > caster2; | |
| 360 » » » caster2.from = &_opaque_connection::emitter< DestT, Args ... >; | |
| 361 » » » pemit = caster2.to; | |
| 362 » » } | |
| 363 | |
| 364 » » has_slots_interface* getdest() const { return pdest; } | |
| 365 | |
| 366 » » _opaque_connection duplicate(has_slots_interface* newtarget) con st | |
| 367 » » { | |
| 368 » » » _opaque_connection res = *this; | |
| 369 » » » res.pdest = newtarget; | |
| 370 » » » return res; | |
| 371 » » } | |
| 372 | |
| 373 » » // Just calls the stored "emitter" function pointer stored at co nstruction | |
| 374 » » // time. | |
| 375 » » template< typename ... Args > | |
| 376 » » void emit(Args... args) const | |
| 377 » » { | |
| 378 » » » typedef void (*em_t)(const _opaque_connection*, Args...) ; | |
| 379 » » » union_caster< emit_t, em_t > caster; | |
| 380 » » » caster.from = pemit; | |
| 381 » » » (caster.to)(this, args...); | |
| 382 » » } | |
| 383 | |
| 384 » private: | |
| 385 » » template< typename DestT, typename ... Args > | |
| 386 » » static void emitter(const _opaque_connection* self, Args... args ) | |
| 387 » » { | |
| 388 » » » typedef void (DestT::*pm_t)(Args...); | |
| 389 » » » pm_t pm; | |
| 390 » » » std::memcpy(&pm, self->pmethod, sizeof(pm_t)); | |
| 391 » » » (static_cast< DestT* >(self->pdest)->*(pm))(args...); | |
| 392 » » } | |
| 389 }; | 393 }; |
| 390 | 394 |
| 391 template<class mt_policy> | 395 template<class mt_policy> |
| 392 class _signal_base : public _signal_base_interface, public mt_policy | 396 class _signal_base : public _signal_base_interface, public mt_policy |
| 393 { | 397 { |
| 394 » }; | 398 » protected: |
| 399 » » typedef std::list< _opaque_connection > connections_list; | |
| 395 | 400 |
| 396 » class has_slots_interface | 401 » » _signal_base() : _signal_base_interface(&_signal_base::do_slot_d isconnect, &_signal_base::do_slot_duplicate) |
| 397 » { | |
| 398 » public: | |
| 399 » » has_slots_interface() | |
| 400 » » { | |
| 401 » » » ; | |
| 402 » » } | |
| 403 | |
| 404 » » virtual void signal_connect(_signal_base_interface* sender) = 0; | |
| 405 | |
| 406 » » virtual void signal_disconnect(_signal_base_interface* sender) = 0; | |
| 407 | |
| 408 » » virtual ~has_slots_interface() | |
| 409 { | 402 { |
| 410 } | 403 } |
| 411 | 404 |
| 412 » » virtual void disconnect_all() = 0; | 405 » » ~_signal_base() |
| 413 » }; | 406 » » { |
| 407 » » » disconnect_all(); | |
| 408 » » } | |
| 414 | 409 |
| 415 template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 416 class has_slots : public has_slots_interface, public mt_policy | |
| 417 { | |
| 418 private: | 410 private: |
| 419 » » typedef std::set<_signal_base_interface*> sender_set; | 411 » » _signal_base& operator= (_signal_base const& that); |
| 420 » » typedef sender_set::const_iterator const_iterator; | |
| 421 | 412 |
| 422 public: | 413 public: |
| 423 » » has_slots() | 414 » » _signal_base(const _signal_base& s) : _signal_base_interface(&_s ignal_base::do_slot_disconnect, &_signal_base::do_slot_duplicate) { |
| 424 » » { | |
| 425 » » » ; | |
| 426 » » } | |
| 427 | |
| 428 » » has_slots(const has_slots& hs) | |
| 429 » » { | |
| 430 lock_block<mt_policy> lock(this); | 415 lock_block<mt_policy> lock(this); |
| 431 » » » const_iterator it = hs.m_senders.begin(); | 416 » » » connections_list::const_iterator it = m_connected_slots. begin(); |
|
noahric
2017/03/14 03:15:53
I think this broke sigslot copying. The old code u
| |
| 432 » » » const_iterator itEnd = hs.m_senders.end(); | 417 » » » connections_list::const_iterator itEnd = m_connected_slo ts.end(); |
| 433 | |
| 434 while(it != itEnd) | 418 while(it != itEnd) |
| 435 { | 419 { |
| 436 » » » » (*it)->slot_duplicate(&hs, this); | 420 » » » » it->getdest()->signal_connect(this); |
| 437 » » » » m_senders.insert(*it); | 421 » » » » m_connected_slots.push_back(*it); |
| 438 ++it; | 422 ++it; |
| 439 } | 423 } |
| 440 } | 424 } |
| 441 | 425 |
| 442 » » void signal_connect(_signal_base_interface* sender) | 426 » » bool is_empty() |
| 443 { | 427 { |
| 444 lock_block<mt_policy> lock(this); | 428 lock_block<mt_policy> lock(this); |
| 445 » » » m_senders.insert(sender); | 429 » » » return m_connected_slots.empty(); |
| 446 » » } | |
| 447 | |
| 448 » » void signal_disconnect(_signal_base_interface* sender) | |
| 449 » » { | |
| 450 » » » lock_block<mt_policy> lock(this); | |
| 451 » » » m_senders.erase(sender); | |
| 452 » » } | |
| 453 | |
| 454 » » virtual ~has_slots() | |
| 455 » » { | |
| 456 » » » disconnect_all(); | |
| 457 } | 430 } |
| 458 | 431 |
| 459 void disconnect_all() | 432 void disconnect_all() |
| 460 { | 433 { |
| 461 lock_block<mt_policy> lock(this); | 434 lock_block<mt_policy> lock(this); |
| 462 const_iterator it = m_senders.begin(); | |
| 463 const_iterator itEnd = m_senders.end(); | |
| 464 | 435 |
| 465 » » » while(it != itEnd) | 436 » » » while(!m_connected_slots.empty()) |
| 466 { | 437 { |
| 467 » » » » (*it)->slot_disconnect(this); | 438 » » » » has_slots_interface* pdest = m_connected_slots.f ront().getdest(); |
| 468 » » » » ++it; | 439 » » » » m_connected_slots.pop_front(); |
| 469 » » » } | 440 » » » » pdest->signal_disconnect(static_cast< _signal_ba se_interface* >(this)); |
| 470 | |
| 471 » » » m_senders.erase(m_senders.begin(), m_senders.end()); | |
| 472 » » } | |
| 473 | |
| 474 » private: | |
| 475 » » sender_set m_senders; | |
| 476 » }; | |
| 477 | |
| 478 » template<class mt_policy> | |
| 479 » class _signal_base0 : public _signal_base<mt_policy> | |
| 480 » { | |
| 481 » public: | |
| 482 » » typedef std::list<_connection_base0<mt_policy> *> connections_l ist; | |
| 483 | |
| 484 » » _signal_base0() | |
| 485 » » { | |
| 486 » » » ; | |
| 487 » » } | |
| 488 | |
| 489 » » _signal_base0(const _signal_base0& s) | |
| 490 » » » : _signal_base<mt_policy>(s) | |
| 491 » » { | |
| 492 » » » lock_block<mt_policy> lock(this); | |
| 493 » » » typename connections_list::const_iterator it = s.m_conne cted_slots.begin(); | |
| 494 » » » typename connections_list::const_iterator itEnd = s.m_co nnected_slots.end(); | |
| 495 | |
| 496 » » » while(it != itEnd) | |
| 497 » » » { | |
| 498 » » » » (*it)->getdest()->signal_connect(this); | |
| 499 » » » » m_connected_slots.push_back((*it)->clone()); | |
| 500 | |
| 501 » » » » ++it; | |
| 502 } | 441 } |
| 503 } | 442 } |
| 504 | 443 |
| 505 » » ~_signal_base0() | 444 #if !defined(NDEBUG) |
| 506 » » { | 445 » » bool connected(has_slots_interface* pclass) |
| 507 » » » disconnect_all(); | |
| 508 » » } | |
| 509 | |
| 510 » » bool is_empty() | |
| 511 { | 446 { |
| 512 lock_block<mt_policy> lock(this); | 447 lock_block<mt_policy> lock(this); |
| 513 » » » typename connections_list::const_iterator it = m_connect ed_slots.begin(); | 448 » » » connections_list::const_iterator it = m_connected_slots. begin(); |
| 514 » » » typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | 449 » » » connections_list::const_iterator itEnd = m_connected_slo ts.end(); |
| 515 » » » return it == itEnd; | |
| 516 » » } | |
| 517 | |
| 518 » » void disconnect_all() | |
| 519 » » { | |
| 520 » » » lock_block<mt_policy> lock(this); | |
| 521 » » » typename connections_list::const_iterator it = m_connect ed_slots.begin(); | |
| 522 » » » typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 523 | |
| 524 while(it != itEnd) | 450 while(it != itEnd) |
| 525 { | 451 { |
| 526 » » » » (*it)->getdest()->signal_disconnect(this); | 452 » » » » if (it->getdest() == pclass) |
| 527 » » » » delete *it; | 453 » » » » » return true; |
| 528 | |
| 529 ++it; | 454 ++it; |
| 530 } | 455 } |
| 531 | |
| 532 m_connected_slots.erase(m_connected_slots.begin(), m_con nected_slots.end()); | |
| 533 } | |
| 534 | |
| 535 #if !defined(NDEBUG) | |
| 536 bool connected(has_slots_interface* pclass) | |
| 537 { | |
| 538 lock_block<mt_policy> lock(this); | |
| 539 typename connections_list::const_iterator itNext, it = m _connected_slots.begin(); | |
| 540 typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 541 while(it != itEnd) | |
| 542 { | |
| 543 itNext = it; | |
| 544 ++itNext; | |
| 545 if ((*it)->getdest() == pclass) | |
| 546 return true; | |
| 547 it = itNext; | |
| 548 } | |
| 549 return false; | 456 return false; |
| 550 } | 457 } |
| 551 #endif | 458 #endif |
| 552 | 459 |
| 553 void disconnect(has_slots_interface* pclass) | 460 void disconnect(has_slots_interface* pclass) |
| 554 { | 461 { |
| 555 lock_block<mt_policy> lock(this); | 462 lock_block<mt_policy> lock(this); |
| 556 » » » typename connections_list::iterator it = m_connected_slo ts.begin(); | 463 » » » connections_list::iterator it = m_connected_slots.begin( ); |
| 557 » » » typename connections_list::iterator itEnd = m_connected_ slots.end(); | 464 » » » connections_list::iterator itEnd = m_connected_slots.end (); |
| 558 | 465 |
| 559 while(it != itEnd) | 466 while(it != itEnd) |
| 560 { | 467 { |
| 561 » » » » if((*it)->getdest() == pclass) | 468 » » » » if(it->getdest() == pclass) |
| 562 { | 469 { |
| 563 delete *it; | |
| 564 m_connected_slots.erase(it); | 470 m_connected_slots.erase(it); |
| 565 » » » » » pclass->signal_disconnect(this); | 471 » » » » » pclass->signal_disconnect(static_cast< _ signal_base_interface* >(this)); |
| 566 return; | 472 return; |
| 567 } | 473 } |
| 568 | 474 |
| 569 ++it; | 475 ++it; |
| 570 } | 476 } |
| 571 } | 477 } |
| 572 | 478 |
| 573 » » void slot_disconnect(has_slots_interface* pslot) | 479 » private: |
| 480 » » static void do_slot_disconnect(_signal_base_interface* p, has_sl ots_interface* pslot) | |
| 574 { | 481 { |
| 575 » » » lock_block<mt_policy> lock(this); | 482 » » » _signal_base* const self = static_cast< _signal_base* >( p); |
| 576 » » » typename connections_list::iterator it = m_connected_slo ts.begin(); | 483 » » » lock_block<mt_policy> lock(self); |
| 577 » » » typename connections_list::iterator itEnd = m_connected_ slots.end(); | 484 » » » connections_list::iterator it = self->m_connected_slots. begin(); |
| 485 » » » connections_list::iterator itEnd = self->m_connected_slo ts.end(); | |
| 578 | 486 |
| 579 while(it != itEnd) | 487 while(it != itEnd) |
| 580 { | 488 { |
| 581 » » » » typename connections_list::iterator itNext = it; | 489 » » » » connections_list::iterator itNext = it; |
| 582 ++itNext; | 490 ++itNext; |
| 583 | 491 |
| 584 » » » » if((*it)->getdest() == pslot) | 492 » » » » if(it->getdest() == pslot) |
| 585 { | 493 { |
| 586 » » » » » delete *it; | 494 » » » » » self->m_connected_slots.erase(it); |
| 587 » » » » » m_connected_slots.erase(it); | |
| 588 } | 495 } |
| 589 | 496 |
| 590 it = itNext; | 497 it = itNext; |
| 591 } | 498 } |
| 592 } | 499 } |
| 593 | 500 |
| 594 » » void slot_duplicate(const has_slots_interface* oldtarget, has_sl ots_interface* newtarget) | 501 » » static void do_slot_duplicate(_signal_base_interface* p, const h as_slots_interface* oldtarget, has_slots_interface* newtarget) |
| 595 { | 502 { |
| 596 » » » lock_block<mt_policy> lock(this); | 503 » » » _signal_base* const self = static_cast< _signal_base* >( p); |
| 597 » » » typename connections_list::iterator it = m_connected_slo ts.begin(); | 504 » » » lock_block<mt_policy> lock(self); |
| 598 » » » typename connections_list::iterator itEnd = m_connected_ slots.end(); | 505 » » » connections_list::iterator it = self->m_connected_slots. begin(); |
| 506 » » » connections_list::iterator itEnd = self->m_connected_slo ts.end(); | |
| 599 | 507 |
| 600 while(it != itEnd) | 508 while(it != itEnd) |
| 601 { | 509 { |
| 602 » » » » if((*it)->getdest() == oldtarget) | 510 » » » » if(it->getdest() == oldtarget) |
| 603 { | 511 { |
| 604 » » » » » m_connected_slots.push_back((*it)->dupli cate(newtarget)); | 512 » » » » » self->m_connected_slots.push_back(it->du plicate(newtarget)); |
| 605 } | 513 } |
| 606 | 514 |
| 607 ++it; | 515 ++it; |
| 608 } | 516 } |
| 609 } | 517 } |
| 610 | 518 |
| 611 protected: | 519 protected: |
| 612 connections_list m_connected_slots; | 520 connections_list m_connected_slots; |
| 613 }; | 521 }; |
| 614 | 522 |
| 615 » template<class arg1_type, class mt_policy> | 523 » template<class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 616 » class _signal_base1 : public _signal_base<mt_policy> | 524 » class has_slots : public has_slots_interface, public mt_policy |
| 617 { | 525 { |
| 526 private: | |
| 527 typedef std::set< _signal_base_interface* > sender_set; | |
| 528 typedef sender_set::const_iterator const_iterator; | |
| 529 | |
| 618 public: | 530 public: |
| 619 » » typedef std::list<_connection_base1<arg1_type, mt_policy> *> co nnections_list; | 531 » » has_slots() : has_slots_interface(&has_slots::do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_all) |
| 620 | |
| 621 » » _signal_base1() | |
| 622 { | 532 { |
| 623 ; | |
| 624 } | 533 } |
| 625 | 534 |
| 626 » » _signal_base1(const _signal_base1<arg1_type, mt_policy>& s) | 535 » » ~has_slots() |
| 627 » » » : _signal_base<mt_policy>(s) | 536 » » { |
| 537 » » » this->disconnect_all(); | |
| 538 » » } | |
| 539 | |
| 540 » private: | |
| 541 » » has_slots(has_slots const&); | |
| 542 » » has_slots& operator= (has_slots const&); | |
| 543 | |
| 544 » » static void do_signal_connect(has_slots_interface* p, _signal_ba se_interface* sender) | |
| 545 » » { | |
| 546 » » » has_slots* const self = static_cast< has_slots* >(p); | |
| 547 » » » lock_block<mt_policy> lock(self); | |
| 548 » » » self->m_senders.insert(sender); | |
| 549 » » } | |
| 550 | |
| 551 » » static void do_signal_disconnect(has_slots_interface* p, _signal _base_interface* sender) | |
| 552 » » { | |
| 553 » » » has_slots* const self = static_cast< has_slots* >(p); | |
| 554 » » » lock_block<mt_policy> lock(self); | |
| 555 » » » self->m_senders.erase(sender); | |
| 556 » » } | |
| 557 | |
| 558 » » static void do_disconnect_all(has_slots_interface* p) | |
| 559 » » { | |
| 560 » » » has_slots* const self = static_cast< has_slots* >(p); | |
| 561 » » » lock_block<mt_policy> lock(self); | |
| 562 » » » while (!self->m_senders.empty()) | |
| 563 » » » { | |
| 564 » » » » std::set< _signal_base_interface* > senders; | |
| 565 » » » » senders.swap(self->m_senders); | |
| 566 » » » » const_iterator it = senders.begin(); | |
| 567 » » » » const_iterator itEnd = senders.end(); | |
| 568 | |
| 569 » » » » while(it != itEnd) | |
| 570 » » » » { | |
| 571 » » » » » _signal_base_interface* s = *it; | |
| 572 » » » » » ++it; | |
| 573 » » » » » s->slot_disconnect(p); | |
| 574 » » » » } | |
| 575 » » » } | |
| 576 » » } | |
| 577 | |
| 578 » private: | |
| 579 » » sender_set m_senders; | |
| 580 » }; | |
| 581 | |
| 582 » template<class mt_policy, typename ... Args> | |
| 583 » class signal_with_thread_policy : public _signal_base<mt_policy> | |
| 584 » { | |
| 585 » private: | |
| 586 » » typedef _signal_base<mt_policy> base; | |
| 587 | |
| 588 » protected: | |
| 589 » » typedef typename base::connections_list connections_list; | |
| 590 | |
| 591 » public: | |
| 592 » » signal_with_thread_policy() | |
| 593 » » { | |
| 594 » » } | |
| 595 | |
| 596 » » template<class desttype> | |
| 597 » » void connect(desttype* pclass, void (desttype::*pmemfun)(Args... )) | |
| 628 { | 598 { |
| 629 lock_block<mt_policy> lock(this); | 599 lock_block<mt_policy> lock(this); |
| 630 » » » typename connections_list::const_iterator it = s.m_conne cted_slots.begin(); | 600 » » » this->m_connected_slots.push_back(_opaque_connection(pcl ass, pmemfun)); |
| 631 » » » typename connections_list::const_iterator itEnd = s.m_co nnected_slots.end(); | 601 » » » pclass->signal_connect(static_cast< _signal_base_interfa ce* >(this)); |
| 602 » » } | |
| 603 | |
| 604 » » void emit(Args... args) | |
| 605 » » { | |
| 606 » » » lock_block<mt_policy> lock(this); | |
| 607 » » » typename connections_list::const_iterator it = this->m_c onnected_slots.begin(); | |
| 608 » » » typename connections_list::const_iterator itEnd = this-> m_connected_slots.end(); | |
| 632 | 609 |
| 633 while(it != itEnd) | 610 while(it != itEnd) |
| 634 { | 611 { |
| 635 » » » » (*it)->getdest()->signal_connect(this); | 612 » » » » _opaque_connection const& conn = *it; |
| 636 » » » » m_connected_slots.push_back((*it)->clone()); | 613 » » » » ++it; |
| 637 | 614 |
| 638 » » » » ++it; | 615 » » » » conn.emit<Args...>(args...); |
| 639 } | 616 } |
| 640 } | 617 } |
| 641 | 618 |
| 642 » » void slot_duplicate(const has_slots_interface* oldtarget, has_sl ots_interface* newtarget) | 619 » » void operator()(Args... args) |
| 643 { | 620 { |
| 644 lock_block<mt_policy> lock(this); | 621 emit(args...); |
| 645 typename connections_list::iterator it = m_connected_slo ts.begin(); | |
| 646 typename connections_list::iterator itEnd = m_connected_ slots.end(); | |
| 647 | |
| 648 while(it != itEnd) | |
| 649 { | |
| 650 if((*it)->getdest() == oldtarget) | |
| 651 { | |
| 652 m_connected_slots.push_back((*it)->dupli cate(newtarget)); | |
| 653 } | |
| 654 | |
| 655 ++it; | |
| 656 } | |
| 657 } | |
| 658 | |
| 659 ~_signal_base1() | |
| 660 { | |
| 661 disconnect_all(); | |
| 662 } | |
| 663 | |
| 664 bool is_empty() | |
| 665 { | |
| 666 lock_block<mt_policy> lock(this); | |
| 667 typename connections_list::const_iterator it = m_connect ed_slots.begin(); | |
| 668 typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 669 return it == itEnd; | |
| 670 } | |
| 671 | |
| 672 void disconnect_all() | |
| 673 { | |
| 674 lock_block<mt_policy> lock(this); | |
| 675 typename connections_list::const_iterator it = m_connect ed_slots.begin(); | |
| 676 typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 677 | |
| 678 while(it != itEnd) | |
| 679 { | |
| 680 (*it)->getdest()->signal_disconnect(this); | |
| 681 delete *it; | |
| 682 | |
| 683 ++it; | |
| 684 } | |
| 685 | |
| 686 m_connected_slots.erase(m_connected_slots.begin(), m_con nected_slots.end()); | |
| 687 } | |
| 688 | |
| 689 #if !defined(NDEBUG) | |
| 690 bool connected(has_slots_interface* pclass) | |
| 691 { | |
| 692 lock_block<mt_policy> lock(this); | |
| 693 typename connections_list::const_iterator itNext, it = m _connected_slots.begin(); | |
| 694 typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 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 }; | |
| 1166 | |
| 1167 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t ype, | |
| 1168 class arg5_type, class mt_policy> | |
| 1169 class _signal_base5 : public _signal_base<mt_policy> | |
| 1170 { | |
| 1171 public: | |
| 1172 typedef std::list<_connection_base5<arg1_type, arg2_type, arg3_t ype, | |
| 1173 arg4_type, arg5_type, mt_policy> *> connections_list; | |
| 1174 | |
| 1175 _signal_base5() | |
| 1176 { | |
| 1177 ; | |
| 1178 } | |
| 1179 | |
| 1180 _signal_base5(const _signal_base5<arg1_type, arg2_type, arg3_typ e, arg4_type, | |
| 1181 arg5_type, mt_policy>& s) | |
| 1182 : _signal_base<mt_policy>(s) | |
| 1183 { | |
| 1184 lock_block<mt_policy> lock(this); | |
| 1185 typename connections_list::const_iterator it = s.m_conne cted_slots.begin(); | |
| 1186 typename connections_list::const_iterator itEnd = s.m_co nnected_slots.end(); | |
| 1187 | |
| 1188 while(it != itEnd) | |
| 1189 { | |
| 1190 (*it)->getdest()->signal_connect(this); | |
| 1191 m_connected_slots.push_back((*it)->clone()); | |
| 1192 | |
| 1193 ++it; | |
| 1194 } | |
| 1195 } | |
| 1196 | |
| 1197 void slot_duplicate(const has_slots_interface* oldtarget, has_sl ots_interface* newtarget) | |
| 1198 { | |
| 1199 lock_block<mt_policy> lock(this); | |
| 1200 typename connections_list::iterator it = m_connected_slo ts.begin(); | |
| 1201 typename connections_list::iterator itEnd = m_connected_ slots.end(); | |
| 1202 | |
| 1203 while(it != itEnd) | |
| 1204 { | |
| 1205 if((*it)->getdest() == oldtarget) | |
| 1206 { | |
| 1207 m_connected_slots.push_back((*it)->dupli cate(newtarget)); | |
| 1208 } | |
| 1209 | |
| 1210 ++it; | |
| 1211 } | |
| 1212 } | |
| 1213 | |
| 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 | |
| 1307 template<class arg1_type, class arg2_type, class arg3_type, class arg4_t ype, | |
| 1308 class arg5_type, class arg6_type, class mt_policy> | |
| 1309 class _signal_base6 : public _signal_base<mt_policy> | |
| 1310 { | |
| 1311 public: | |
| 1312 typedef std::list<_connection_base6<arg1_type, arg2_type, arg3_t ype, | |
| 1313 arg4_type, arg5_type, arg6_type, mt_policy> *> connecti ons_list; | |
| 1314 | |
| 1315 _signal_base6() | |
| 1316 { | |
| 1317 ; | |
| 1318 } | |
| 1319 | |
| 1320 _signal_base6(const _signal_base6<arg1_type, arg2_type, arg3_typ e, arg4_type, | |
| 1321 arg5_type, arg6_type, mt_policy>& s) | |
| 1322 : _signal_base<mt_policy>(s) | |
| 1323 { | |
| 1324 lock_block<mt_policy> lock(this); | |
| 1325 typename connections_list::const_iterator it = s.m_conne cted_slots.begin(); | |
| 1326 typename connections_list::const_iterator itEnd = s.m_co nnected_slots.end(); | |
| 1327 | |
| 1328 while(it != itEnd) | |
| 1329 { | |
| 1330 (*it)->getdest()->signal_connect(this); | |
| 1331 m_connected_slots.push_back((*it)->clone()); | |
| 1332 | |
| 1333 ++it; | |
| 1334 } | |
| 1335 } | |
| 1336 | |
| 1337 void slot_duplicate(const has_slots_interface* oldtarget, has_sl ots_interface* newtarget) | |
| 1338 { | |
| 1339 lock_block<mt_policy> lock(this); | |
| 1340 typename connections_list::iterator it = m_connected_slo ts.begin(); | |
| 1341 typename connections_list::iterator itEnd = m_connected_ slots.end(); | |
| 1342 | |
| 1343 while(it != itEnd) | |
| 1344 { | |
| 1345 if((*it)->getdest() == oldtarget) | |
| 1346 { | |
| 1347 m_connected_slots.push_back((*it)->dupli cate(newtarget)); | |
| 1348 } | |
| 1349 | |
| 1350 ++it; | |
| 1351 } | |
| 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 }; | |
| 1446 | |
| 1447 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> | |
| 1449 class _signal_base7 : public _signal_base<mt_policy> | |
| 1450 { | |
| 1451 public: | |
| 1452 typedef std::list<_connection_base7<arg1_type, arg2_type, arg3_t ype, | |
| 1453 arg4_type, arg5_type, arg6_type, arg7_type, mt_policy> * > connections_list; | |
| 1454 | |
| 1455 _signal_base7() | |
| 1456 { | |
| 1457 ; | |
| 1458 } | |
| 1459 | |
| 1460 _signal_base7(const _signal_base7<arg1_type, arg2_type, arg3_typ e, arg4_type, | |
| 1461 arg5_type, arg6_type, arg7_type, mt_policy>& s) | |
| 1462 : _signal_base<mt_policy>(s) | |
| 1463 { | |
| 1464 lock_block<mt_policy> lock(this); | |
| 1465 typename connections_list::const_iterator it = s.m_conne cted_slots.begin(); | |
| 1466 typename connections_list::const_iterator itEnd = s.m_co nnected_slots.end(); | |
| 1467 | |
| 1468 while(it != itEnd) | |
| 1469 { | |
| 1470 (*it)->getdest()->signal_connect(this); | |
| 1471 m_connected_slots.push_back((*it)->clone()); | |
| 1472 | |
| 1473 ++it; | |
| 1474 } | |
| 1475 } | |
| 1476 | |
| 1477 void slot_duplicate(const has_slots_interface* oldtarget, has_sl ots_interface* newtarget) | |
| 1478 { | |
| 1479 lock_block<mt_policy> lock(this); | |
| 1480 typename connections_list::iterator it = m_connected_slo ts.begin(); | |
| 1481 typename connections_list::iterator itEnd = m_connected_ slots.end(); | |
| 1482 | |
| 1483 while(it != itEnd) | |
| 1484 { | |
| 1485 if((*it)->getdest() == oldtarget) | |
| 1486 { | |
| 1487 m_connected_slots.push_back((*it)->dupli cate(newtarget)); | |
| 1488 } | |
| 1489 | |
| 1490 ++it; | |
| 1491 } | |
| 1492 } | |
| 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 }; | |
| 1586 | |
| 1587 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> | |
| 1589 class _signal_base8 : public _signal_base<mt_policy> | |
| 1590 { | |
| 1591 public: | |
| 1592 typedef std::list<_connection_base8<arg1_type, arg2_type, arg3_t ype, | |
| 1593 arg4_type, arg5_type, arg6_type, arg7_type, arg8_type, m t_policy> *> | |
| 1594 connections_list; | |
| 1595 | |
| 1596 _signal_base8() | |
| 1597 { | |
| 1598 ; | |
| 1599 } | |
| 1600 | |
| 1601 _signal_base8(const _signal_base8<arg1_type, arg2_type, arg3_typ e, arg4_type, | |
| 1602 arg5_type, arg6_type, arg7_type, arg8_type, mt_policy>& s) | |
| 1603 : _signal_base<mt_policy>(s) | |
| 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, | |
| 2138 arg7_type, arg8_type)) | |
| 2139 { | |
| 2140 m_pobject = pobject; | |
| 2141 m_pmemfun = pmemfun; | |
| 2142 } | |
| 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 } | 622 } |
| 2241 }; | 623 }; |
| 2242 | 624 |
| 2243 » template<class arg1_type, class mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | 625 » // Alias with default thread policy. Needed because both default argumen ts |
| 2244 » class signal1 : public _signal_base1<arg1_type, mt_policy> | 626 » // and variadic template arguments must go at the end of the list, so we |
| 2245 » { | 627 » // can't have both at once. |
| 2246 » public: | 628 » template<typename ... Args> |
| 2247 » » typedef _signal_base1<arg1_type, mt_policy> base; | 629 » using signal = signal_with_thread_policy<SIGSLOT_DEFAULT_MT_POLICY, Args ...>; |
| 2248 » » typedef typename base::connections_list connections_list; | |
| 2249 » » using base::m_connected_slots; | |
| 2250 | 630 |
| 2251 » » signal1() | 631 » // The previous verion of sigslot didn't use variadic templates, so you would |
| 2252 » » { | 632 » // need to write "sigslot::signal2<Arg1, Arg2>", for example. |
| 2253 » » » ; | 633 » // Now you can just write "sigslot::signal<Arg1, Arg2>", but these alias es |
| 2254 » » } | 634 » // exist for backwards compatibility. |
| 635 » template<typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> | |
| 636 » using signal0 = signal_with_thread_policy<mt_policy>; | |
| 2255 | 637 |
| 2256 » » signal1(const signal1<arg1_type, mt_policy>& s) | 638 » template<typename A1, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 2257 » » » : _signal_base1<arg1_type, mt_policy>(s) | 639 » using signal1 = signal_with_thread_policy<mt_policy, A1>; |
| 2258 » » { | |
| 2259 » » » ; | |
| 2260 » » } | |
| 2261 | 640 |
| 2262 » » template<class desttype> | 641 » template<typename A1, typename A2, typename mt_policy = SIGSLOT_DEFAULT_ MT_POLICY> |
| 2263 » » » void connect(desttype* pclass, void (desttype::*pmemfun) (arg1_type)) | 642 » using signal2 = signal_with_thread_policy<mt_policy, A1, A2>; |
| 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 | 643 |
| 2272 » » void emit(arg1_type a1) | 644 » template<typename A1, typename A2, typename A3, typename mt_policy = SIG SLOT_DEFAULT_MT_POLICY> |
| 2273 » » { | 645 » using signal3 = signal_with_thread_policy<mt_policy, A1, A2, A3>; |
| 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 | 646 |
| 2278 » » » while(it != itEnd) | 647 » template<typename A1, typename A2, typename A3, typename A4, typename mt _policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 2279 » » » { | 648 » using signal4 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4>; |
| 2280 » » » » itNext = it; | |
| 2281 » » » » ++itNext; | |
| 2282 | 649 |
| 2283 » » » » (*it)->emit(a1); | 650 » template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 651 » using signal5 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5> ; | |
| 2284 | 652 |
| 2285 » » » » it = itNext; | 653 » template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 2286 » » » } | 654 » using signal6 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6>; |
| 2287 » » } | |
| 2288 | 655 |
| 2289 » » void operator()(arg1_type a1) | 656 » template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> |
| 2290 » » { | 657 » using signal7 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7>; |
| 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 | 658 |
| 2295 » » » while(it != itEnd) | 659 » template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename A8, typename mt_policy = SIGSLOT_DEFAULT_MT _POLICY> |
| 2296 » » » { | 660 » using signal8 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7, A8>; |
| 2297 » » » » itNext = it; | |
| 2298 » » » » ++itNext; | |
| 2299 | 661 |
| 2300 (*it)->emit(a1); | 662 } // namespace sigslot |
| 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 } | |
| 2764 | |
| 2765 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) | |
| 2767 { | |
| 2768 lock_block<mt_policy> lock(this); | |
| 2769 typename connections_list::const_iterator itNext, it = m _connected_slots.begin(); | |
| 2770 typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 2771 | |
| 2772 while(it != itEnd) | |
| 2773 { | |
| 2774 itNext = it; | |
| 2775 ++itNext; | |
| 2776 | |
| 2777 (*it)->emit(a1, a2, a3, a4, a5, a6, a7, a8); | |
| 2778 | |
| 2779 it = itNext; | |
| 2780 } | |
| 2781 } | |
| 2782 | |
| 2783 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) | |
| 2785 { | |
| 2786 lock_block<mt_policy> lock(this); | |
| 2787 typename connections_list::const_iterator itNext, it = m _connected_slots.begin(); | |
| 2788 typename connections_list::const_iterator itEnd = m_conn ected_slots.end(); | |
| 2789 | |
| 2790 while(it != itEnd) | |
| 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 | 663 |
| 2804 #endif // WEBRTC_BASE_SIGSLOT_H__ | 664 #endif // WEBRTC_BASE_SIGSLOT_H__ |
| OLD | NEW |