diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-06-22 15:42:22 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-06-22 15:42:22 +0000 |
commit | 40f72dc07efa92bb5482e21cb9eedbfd20d3eb7c (patch) | |
tree | 2ef7f663b6c54a9aeee1f584575391044c63fb7f /src | |
parent | f16c5dd212ca03ec5f13759997bf95982e3aee94 (diff) | |
download | libbu++-40f72dc07efa92bb5482e21cb9eedbfd20d3eb7c.tar.gz libbu++-40f72dc07efa92bb5482e21cb9eedbfd20d3eb7c.tar.bz2 libbu++-40f72dc07efa92bb5482e21cb9eedbfd20d3eb7c.tar.xz libbu++-40f72dc07efa92bb5482e21cb9eedbfd20d3eb7c.zip |
Signals.h is now autogenerated by build. In distribution packages we should
probably include a copy of the final version just for good measure.
Diffstat (limited to 'src')
-rw-r--r-- | src/signals.h | 674 |
1 files changed, 0 insertions, 674 deletions
diff --git a/src/signals.h b/src/signals.h deleted file mode 100644 index 39f15ec..0000000 --- a/src/signals.h +++ /dev/null | |||
@@ -1,674 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #ifndef BU_OBJECT_SIGNALS_H | ||
9 | #define BU_OBJECT_SIGNALS_H | ||
10 | |||
11 | #include "bu/util.h" | ||
12 | #include "bu/exceptionbase.h" | ||
13 | |||
14 | namespace Bu | ||
15 | { | ||
16 | subExceptionDecl( SignalException ); | ||
17 | // | ||
18 | // 0 Parameters | ||
19 | // | ||
20 | |||
21 | template<typename ret> | ||
22 | class _Slot0 | ||
23 | { | ||
24 | public: | ||
25 | _Slot0() { } | ||
26 | virtual ~_Slot0() { } | ||
27 | |||
28 | virtual ret operator()()=0; | ||
29 | |||
30 | virtual _Slot0<ret> *clone() const=0; | ||
31 | }; | ||
32 | |||
33 | template<typename cls, typename ret> | ||
34 | class __Slot0 : public _Slot0<ret> | ||
35 | { | ||
36 | public: | ||
37 | __Slot0( cls *pCls, ret (cls::*pFnc)() ) : | ||
38 | pCls( pCls ), pFnc( pFnc ) { } | ||
39 | virtual ~__Slot0() { } | ||
40 | |||
41 | virtual ret operator()() | ||
42 | { | ||
43 | |||
44 | return (pCls->*pFnc)(); | ||
45 | } | ||
46 | |||
47 | virtual _Slot0<ret> *clone() const | ||
48 | { | ||
49 | return new __Slot0<cls, ret>( pCls, pFnc ); | ||
50 | } | ||
51 | |||
52 | private: | ||
53 | cls *pCls; | ||
54 | ret (cls::*pFnc)(); | ||
55 | }; | ||
56 | |||
57 | template<typename ret> | ||
58 | class __Slot0F : public _Slot0<ret> | ||
59 | { | ||
60 | public: | ||
61 | __Slot0F( ret (*pFnc)() ) : | ||
62 | pFnc( pFnc ) { } | ||
63 | virtual ~__Slot0F() { } | ||
64 | |||
65 | virtual ret operator()() | ||
66 | { | ||
67 | return (*pFnc)(); | ||
68 | } | ||
69 | |||
70 | virtual _Slot0<ret> *clone() const | ||
71 | { | ||
72 | return new __Slot0F<ret>( pFnc ); | ||
73 | } | ||
74 | |||
75 | private: | ||
76 | ret (*pFnc)(); | ||
77 | }; | ||
78 | |||
79 | template<typename ret> | ||
80 | class Signal0 | ||
81 | { | ||
82 | public: | ||
83 | Signal0() : pCb( NULL ) { } | ||
84 | Signal0( _Slot0<ret> *pCb ) : pCb( pCb ) { } | ||
85 | Signal0( const Signal0<ret> &rSrc ) : | ||
86 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
87 | |||
88 | virtual ~Signal0() { delete pCb; pCb = NULL; } | ||
89 | |||
90 | ret operator()() | ||
91 | { | ||
92 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
93 | return (*pCb)(); | ||
94 | } | ||
95 | |||
96 | bool isSet() const { return pCb != NULL; } | ||
97 | operator bool() const { return isSet(); } | ||
98 | |||
99 | Signal0<ret> &operator=( const Signal0<ret> &rhs ) | ||
100 | { | ||
101 | pCb = rhs.pCb->clone(); | ||
102 | return *this; | ||
103 | } | ||
104 | |||
105 | private: | ||
106 | _Slot0<ret> *pCb; | ||
107 | }; | ||
108 | |||
109 | template<typename cls, typename ret> | ||
110 | Signal0<ret> slot( cls *pCls, ret (cls::*pFnc)() ) | ||
111 | { | ||
112 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
113 | return Signal0<ret>( | ||
114 | new __Slot0<cls, ret>( pCls, pFnc ) | ||
115 | ); | ||
116 | } | ||
117 | |||
118 | template<typename ret> | ||
119 | Signal0<ret> slot( ret (*pFnc)() ) | ||
120 | { | ||
121 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
122 | return Signal0<ret>( | ||
123 | new __Slot0F<ret>( pFnc ) | ||
124 | ); | ||
125 | } | ||
126 | |||
127 | // | ||
128 | // 1 Parameter | ||
129 | // | ||
130 | |||
131 | template<typename ret, typename p1t> | ||
132 | class _Slot1 | ||
133 | { | ||
134 | public: | ||
135 | _Slot1() { } | ||
136 | virtual ~_Slot1() { } | ||
137 | |||
138 | virtual ret operator()( p1t p1 )=0; | ||
139 | |||
140 | virtual _Slot1<ret, p1t> *clone() const=0; | ||
141 | }; | ||
142 | |||
143 | template<typename cls, typename ret, typename p1t> | ||
144 | class __Slot1 : public _Slot1<ret, p1t> | ||
145 | { | ||
146 | public: | ||
147 | __Slot1( cls *pCls, ret (cls::*pFnc)( p1t ) ) : | ||
148 | pCls( pCls ), pFnc( pFnc ) { } | ||
149 | virtual ~__Slot1() { } | ||
150 | |||
151 | virtual ret operator()( p1t p1 ) | ||
152 | { | ||
153 | return (pCls->*pFnc)( p1 ); | ||
154 | } | ||
155 | |||
156 | virtual _Slot1<ret, p1t> *clone() const | ||
157 | { | ||
158 | return new __Slot1<cls, ret, p1t>( pCls, pFnc ); | ||
159 | } | ||
160 | |||
161 | private: | ||
162 | cls *pCls; | ||
163 | ret (cls::*pFnc)( p1t ); | ||
164 | }; | ||
165 | |||
166 | template<typename ret, typename p1t> | ||
167 | class __Slot1F : public _Slot1<ret, p1t> | ||
168 | { | ||
169 | public: | ||
170 | __Slot1F( ret (*pFnc)( p1t ) ) : | ||
171 | pFnc( pFnc ) { } | ||
172 | virtual ~__Slot1F() { } | ||
173 | |||
174 | virtual ret operator()( p1t p1 ) | ||
175 | { | ||
176 | return (*pFnc)( p1 ); | ||
177 | } | ||
178 | |||
179 | virtual _Slot1<ret, p1t> *clone() const | ||
180 | { | ||
181 | return new __Slot1F<ret, p1t>( pFnc ); | ||
182 | } | ||
183 | |||
184 | private: | ||
185 | ret (*pFnc)( p1t p1 ); | ||
186 | }; | ||
187 | |||
188 | template<typename ret, typename p1t> | ||
189 | class Signal1 | ||
190 | { | ||
191 | public: | ||
192 | Signal1() : pCb( NULL ) { } | ||
193 | Signal1( _Slot1<ret, p1t> *pCb ) : pCb( pCb ) { } | ||
194 | Signal1( const Signal1<ret, p1t> &rSrc ) : | ||
195 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
196 | |||
197 | virtual ~Signal1() { delete pCb; pCb = NULL; } | ||
198 | |||
199 | ret operator()( p1t p1 ) | ||
200 | { | ||
201 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
202 | return (*pCb)( p1 ); | ||
203 | } | ||
204 | |||
205 | bool isSet() const { return pCb != NULL; } | ||
206 | operator bool() const { return isSet(); } | ||
207 | |||
208 | Signal1<ret, p1t> &operator=( const Signal1<ret, p1t> &rhs ) | ||
209 | { | ||
210 | pCb = rhs.pCb->clone(); | ||
211 | return *this; | ||
212 | } | ||
213 | |||
214 | private: | ||
215 | _Slot1<ret, p1t> *pCb; | ||
216 | }; | ||
217 | |||
218 | template<typename cls, typename ret, typename p1t> | ||
219 | Signal1<ret, p1t> slot( cls *pCls, ret (cls::*pFnc)( p1t ) ) | ||
220 | { | ||
221 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
222 | return Signal1<ret, p1t>( | ||
223 | new __Slot1<cls, ret, p1t>( pCls, pFnc ) | ||
224 | ); | ||
225 | } | ||
226 | |||
227 | template<typename ret, typename p1t> | ||
228 | Signal1<ret, p1t> slot( ret (*pFnc)( p1t ) ) | ||
229 | { | ||
230 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
231 | return Signal1<ret, p1t>( | ||
232 | new __Slot1F<ret, p1t>( pFnc ) | ||
233 | ); | ||
234 | } | ||
235 | |||
236 | // | ||
237 | // 2 Parameters | ||
238 | // | ||
239 | |||
240 | template<typename ret, typename p1t, typename p2t> | ||
241 | class _Slot2 | ||
242 | { | ||
243 | public: | ||
244 | _Slot2() { } | ||
245 | virtual ~_Slot2() { } | ||
246 | |||
247 | virtual ret operator()( p1t p1, p2t p2 )=0; | ||
248 | |||
249 | virtual _Slot2<ret, p1t, p2t> *clone() const=0; | ||
250 | }; | ||
251 | |||
252 | template<typename cls, typename ret, typename p1t, typename p2t> | ||
253 | class __Slot2 : public _Slot2<ret, p1t, p2t> | ||
254 | { | ||
255 | public: | ||
256 | __Slot2( cls *pCls, ret (cls::*pFnc)( p1t, p2t ) ) : | ||
257 | pCls( pCls ), pFnc( pFnc ) { } | ||
258 | virtual ~__Slot2() { } | ||
259 | |||
260 | virtual ret operator()( p1t p1, p2t p2 ) | ||
261 | { | ||
262 | return (pCls->*pFnc)( p1, p2 ); | ||
263 | } | ||
264 | |||
265 | virtual _Slot2<ret, p1t, p2t> *clone() const | ||
266 | { | ||
267 | return new __Slot2<cls, ret, p1t, p2t>( pCls, pFnc ); | ||
268 | } | ||
269 | |||
270 | private: | ||
271 | cls *pCls; | ||
272 | ret (cls::*pFnc)( p1t, p2t ); | ||
273 | }; | ||
274 | |||
275 | template<typename ret, typename p1t, typename p2t> | ||
276 | class __Slot2F : public _Slot2<ret, p1t, p2t> | ||
277 | { | ||
278 | public: | ||
279 | __Slot2F( ret (*pFnc)( p1t, p2t ) ) : | ||
280 | pFnc( pFnc ) { } | ||
281 | virtual ~__Slot2F() { } | ||
282 | |||
283 | virtual ret operator()( p1t p1, p2t p2 ) | ||
284 | { | ||
285 | return (*pFnc)( p1, p2 ); | ||
286 | } | ||
287 | |||
288 | virtual _Slot2<ret, p1t, p2t> *clone() const | ||
289 | { | ||
290 | return new __Slot2F<ret, p1t, p2t>( pFnc ); | ||
291 | } | ||
292 | |||
293 | private: | ||
294 | ret (*pFnc)( p1t, p2t ); | ||
295 | }; | ||
296 | |||
297 | template<typename ret, typename p1t, typename p2t> | ||
298 | class Signal2 | ||
299 | { | ||
300 | public: | ||
301 | Signal2() : pCb( NULL ) { } | ||
302 | Signal2( _Slot2<ret, p1t, p2t> *pCb ) : pCb( pCb ) { } | ||
303 | Signal2( const Signal2<ret, p1t, p2t> &rSrc ) : | ||
304 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
305 | |||
306 | virtual ~Signal2() { delete pCb; pCb = NULL; } | ||
307 | |||
308 | ret operator()( p1t p1, p2t p2 ) | ||
309 | { | ||
310 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
311 | return (*pCb)( p1, p2 ); | ||
312 | } | ||
313 | |||
314 | bool isSet() const { return pCb != NULL; } | ||
315 | operator bool() const { return isSet(); } | ||
316 | |||
317 | Signal2<ret, p1t, p2t> &operator=( const Signal2<ret, p1t, p2t> &rhs ) | ||
318 | { | ||
319 | pCb = rhs.pCb->clone(); | ||
320 | return *this; | ||
321 | } | ||
322 | |||
323 | private: | ||
324 | _Slot2<ret, p1t, p2t> *pCb; | ||
325 | }; | ||
326 | |||
327 | template<typename cls, typename ret, typename p1t, typename p2t> | ||
328 | Signal2<ret, p1t, p2t> slot( cls *pCls, ret (cls::*pFnc)( p1t, p2t ) ) | ||
329 | { | ||
330 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
331 | return Signal2<ret, p1t, p2t>( | ||
332 | new __Slot2<cls, ret, p1t, p2t>( pCls, pFnc ) | ||
333 | ); | ||
334 | } | ||
335 | |||
336 | template<typename ret, typename p1t, typename p2t> | ||
337 | Signal2<ret, p1t, p2t> slot( ret (*pFnc)( p1t, p2t ) ) | ||
338 | { | ||
339 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
340 | return Signal2<ret, p1t, p2t>( | ||
341 | new __Slot2F<ret, p1t, p2t>( pFnc ) | ||
342 | ); | ||
343 | } | ||
344 | |||
345 | // | ||
346 | // 3 Parameters | ||
347 | // | ||
348 | |||
349 | template<typename ret, typename p1t, typename p2t, typename p3t> | ||
350 | class _Slot3 | ||
351 | { | ||
352 | public: | ||
353 | _Slot3() { } | ||
354 | virtual ~_Slot3() { } | ||
355 | |||
356 | virtual ret operator()( p1t p1, p2t p2, p3t p3 )=0; | ||
357 | |||
358 | virtual _Slot3<ret, p1t, p2t, p3t> *clone() const=0; | ||
359 | }; | ||
360 | |||
361 | template<typename cls, typename ret, typename p1t, typename p2t, typename p3t> | ||
362 | class __Slot3 : public _Slot3<ret, p1t, p2t, p3t> | ||
363 | { | ||
364 | public: | ||
365 | __Slot3( cls *pCls, ret (cls::*pFnc)( p1t, p2t, p3t ) ) : | ||
366 | pCls( pCls ), pFnc( pFnc ) { } | ||
367 | virtual ~__Slot3() { } | ||
368 | |||
369 | virtual ret operator()( p1t p1, p2t p2, p3t p3 ) | ||
370 | { | ||
371 | return (pCls->*pFnc)( p1, p2, p3 ); | ||
372 | } | ||
373 | |||
374 | virtual _Slot3<ret, p1t, p2t, p3t> *clone() const | ||
375 | { | ||
376 | return new __Slot3<cls, ret, p1t, p2t, p3t>( pCls, pFnc ); | ||
377 | } | ||
378 | |||
379 | private: | ||
380 | cls *pCls; | ||
381 | ret (cls::*pFnc)( p1t, p2t, p3t ); | ||
382 | }; | ||
383 | |||
384 | template<typename ret, typename p1t, typename p2t, typename p3t> | ||
385 | class __Slot3F : public _Slot3<ret, p1t, p2t, p3t> | ||
386 | { | ||
387 | public: | ||
388 | __Slot3F( ret (*pFnc)( p1t, p2t, p3t ) ) : | ||
389 | pFnc( pFnc ) { } | ||
390 | virtual ~__Slot3F() { } | ||
391 | |||
392 | virtual ret operator()( p1t p1, p2t p2, p3t p3 ) | ||
393 | { | ||
394 | return (*pFnc)( p1, p2, p3 ); | ||
395 | } | ||
396 | |||
397 | virtual _Slot3<ret, p1t, p2t, p3t> *clone() const | ||
398 | { | ||
399 | return new __Slot3F<ret, p1t, p2t, p3t>( pFnc ); | ||
400 | } | ||
401 | |||
402 | private: | ||
403 | ret (*pFnc)( p1t, p2t, p3t ); | ||
404 | }; | ||
405 | |||
406 | template<typename ret, typename p1t, typename p2t, typename p3t> | ||
407 | class Signal3 | ||
408 | { | ||
409 | public: | ||
410 | Signal3() : pCb( NULL ) { } | ||
411 | Signal3( _Slot3<ret, p1t, p2t, p3t> *pCb ) : pCb( pCb ) { } | ||
412 | Signal3( const Signal3<ret, p1t, p2t, p3t> &rSrc ) : | ||
413 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
414 | |||
415 | virtual ~Signal3() { delete pCb; pCb = NULL; } | ||
416 | |||
417 | ret operator()( p1t p1, p2t p2, p3t p3 ) | ||
418 | { | ||
419 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
420 | return (*pCb)( p1, p2, p3 ); | ||
421 | } | ||
422 | |||
423 | bool isSet() const { return pCb != NULL; } | ||
424 | operator bool() const { return isSet(); } | ||
425 | |||
426 | Signal3<ret, p1t, p2t, p3t> &operator=( const Signal3<ret, p1t, p2t, p3t> &rhs ) | ||
427 | { | ||
428 | pCb = rhs.pCb->clone(); | ||
429 | return *this; | ||
430 | } | ||
431 | |||
432 | private: | ||
433 | _Slot3<ret, p1t, p2t, p3t> *pCb; | ||
434 | }; | ||
435 | |||
436 | template<typename cls, typename ret, typename p1t, typename p2t, typename p3t> | ||
437 | Signal3<ret, p1t, p2t, p3t> slot( cls *pCls, ret (cls::*pFnc)( p1t, p2t, p3t ) ) | ||
438 | { | ||
439 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
440 | return Signal3<ret, p1t, p2t, p3t>( | ||
441 | new __Slot3<cls, ret, p1t, p2t, p3t>( pCls, pFnc ) | ||
442 | ); | ||
443 | } | ||
444 | |||
445 | template<typename ret, typename p1t, typename p2t, typename p3t> | ||
446 | Signal3<ret, p1t, p2t, p3t> slot( ret (*pFnc)( p1t, p2t, p3t ) ) | ||
447 | { | ||
448 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
449 | return Signal3<ret, p1t, p2t, p3t>( | ||
450 | new __Slot3F<ret, p1t, p2t, p3t>( pFnc ) | ||
451 | ); | ||
452 | } | ||
453 | |||
454 | // | ||
455 | // 4 Parameters | ||
456 | // | ||
457 | |||
458 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t> | ||
459 | class _Slot4 | ||
460 | { | ||
461 | public: | ||
462 | _Slot4() { } | ||
463 | virtual ~_Slot4() { } | ||
464 | |||
465 | virtual ret operator()( p1t p1, p2t p2, p3t p3, p4t p4 )=0; | ||
466 | |||
467 | virtual _Slot4<ret, p1t, p2t, p3t, p4t> *clone() const=0; | ||
468 | }; | ||
469 | |||
470 | template<typename cls, typename ret, typename p1t, typename p2t, typename p3t, typename p4t> | ||
471 | class __Slot4 : public _Slot4<ret, p1t, p2t, p3t, p4t> | ||
472 | { | ||
473 | public: | ||
474 | __Slot4( cls *pCls, ret (cls::*pFnc)( p1t, p2t, p3t, p4t ) ) : | ||
475 | pCls( pCls ), pFnc( pFnc ) { } | ||
476 | virtual ~__Slot4() { } | ||
477 | |||
478 | virtual ret operator()( p1t p1, p2t p2, p3t p3, p4t p4 ) | ||
479 | { | ||
480 | return (pCls->*pFnc)( p1, p2, p3, p4 ); | ||
481 | } | ||
482 | |||
483 | virtual _Slot4<ret, p1t, p2t, p3t, p4t> *clone() const | ||
484 | { | ||
485 | return new __Slot4<cls, ret, p1t, p2t, p3t, p4t>( pCls, pFnc ); | ||
486 | } | ||
487 | |||
488 | private: | ||
489 | cls *pCls; | ||
490 | ret (cls::*pFnc)( p1t, p2t, p3t, p4t ); | ||
491 | }; | ||
492 | |||
493 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t> | ||
494 | class __Slot4F : public _Slot4<ret, p1t, p2t, p3t, p4t> | ||
495 | { | ||
496 | public: | ||
497 | __Slot4F( ret (*pFnc)( p1t, p2t, p3t, p4t ) ) : | ||
498 | pFnc( pFnc ) { } | ||
499 | virtual ~__Slot4F() { } | ||
500 | |||
501 | virtual ret operator()( p1t p1, p2t p2, p3t p3, p4t p4 ) | ||
502 | { | ||
503 | return (*pFnc)( p1, p2, p3, p4 ); | ||
504 | } | ||
505 | |||
506 | virtual _Slot4<ret, p1t, p2t, p3t, p4t> *clone() const | ||
507 | { | ||
508 | return new __Slot4F<ret, p1t, p2t, p3t, p4t>( pFnc ); | ||
509 | } | ||
510 | |||
511 | private: | ||
512 | ret (*pFnc)( p1t, p2t, p3t, p4t ); | ||
513 | }; | ||
514 | |||
515 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t> | ||
516 | class Signal4 | ||
517 | { | ||
518 | public: | ||
519 | Signal4() : pCb( NULL ) { } | ||
520 | Signal4( _Slot4<ret, p1t, p2t, p3t, p4t> *pCb ) : pCb( pCb ) { } | ||
521 | Signal4( const Signal4<ret, p1t, p2t, p3t, p4t> &rSrc ) : | ||
522 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
523 | |||
524 | virtual ~Signal4() { delete pCb; pCb = NULL; } | ||
525 | |||
526 | ret operator()( p1t p1, p2t p2, p3t p3, p4t p4 ) | ||
527 | { | ||
528 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
529 | return (*pCb)( p1, p2, p3, p4 ); | ||
530 | } | ||
531 | |||
532 | bool isSet() const { return pCb != NULL; } | ||
533 | operator bool() const { return isSet(); } | ||
534 | |||
535 | Signal4<ret, p1t, p2t, p3t, p4t> &operator=( const Signal4<ret, p1t, p2t, p3t, p4t> &rhs ) | ||
536 | { | ||
537 | pCb = rhs.pCb->clone(); | ||
538 | return *this; | ||
539 | } | ||
540 | |||
541 | private: | ||
542 | _Slot4<ret, p1t, p2t, p3t, p4t> *pCb; | ||
543 | }; | ||
544 | |||
545 | template<typename cls, typename ret, typename p1t, typename p2t, typename p3t, typename p4t> | ||
546 | Signal4<ret, p1t, p2t, p3t, p4t> slot( cls *pCls, ret (cls::*pFnc)( p1t, p2t, p3t, p4t ) ) | ||
547 | { | ||
548 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
549 | return Signal4<ret, p1t, p2t, p3t, p4t>( | ||
550 | new __Slot4<cls, ret, p1t, p2t, p3t, p4t>( pCls, pFnc ) | ||
551 | ); | ||
552 | } | ||
553 | |||
554 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t> | ||
555 | Signal4<ret, p1t, p2t, p3t, p4t> slot( ret (*pFnc)( p1t, p2t, p3t, p4t ) ) | ||
556 | { | ||
557 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
558 | return Signal4<ret, p1t, p2t, p3t, p4t>( | ||
559 | new __Slot4F<ret, p1t, p2t, p3t, p4t>( pFnc ) | ||
560 | ); | ||
561 | } | ||
562 | |||
563 | // | ||
564 | // 5 Parameters | ||
565 | // | ||
566 | |||
567 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t, typename p5t> | ||
568 | class _Slot5 | ||
569 | { | ||
570 | public: | ||
571 | _Slot5() { } | ||
572 | virtual ~_Slot5() { } | ||
573 | |||
574 | virtual ret operator()( p1t p1, p2t p2, p3t p3, p4t p4, p5t p5 )=0; | ||
575 | |||
576 | virtual _Slot5<ret, p1t, p2t, p3t, p4t, p5t> *clone() const=0; | ||
577 | }; | ||
578 | |||
579 | template<typename cls, typename ret, typename p1t, typename p2t, typename p3t, typename p4t, typename p5t> | ||
580 | class __Slot5 : public _Slot5<ret, p1t, p2t, p3t, p4t, p5t> | ||
581 | { | ||
582 | public: | ||
583 | __Slot5( cls *pCls, ret (cls::*pFnc)( p1t, p2t, p3t, p4t, p5t ) ) : | ||
584 | pCls( pCls ), pFnc( pFnc ) { } | ||
585 | virtual ~__Slot5() { } | ||
586 | |||
587 | virtual ret operator()( p1t p1, p2t p2, p3t p3, p4t p4, p5t p5 ) | ||
588 | { | ||
589 | return (pCls->*pFnc)( p1, p2, p3, p4, p5 ); | ||
590 | } | ||
591 | |||
592 | virtual _Slot5<ret, p1t, p2t, p3t, p4t, p5t> *clone() const | ||
593 | { | ||
594 | return new __Slot5<cls, ret, p1t, p2t, p3t, p4t, p5t>( pCls, pFnc ); | ||
595 | } | ||
596 | |||
597 | private: | ||
598 | cls *pCls; | ||
599 | ret (cls::*pFnc)( p1t, p2t, p3t, p4t, p5t ); | ||
600 | }; | ||
601 | |||
602 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t, typename p5t> | ||
603 | class __Slot5F : public _Slot5<ret, p1t, p2t, p3t, p4t, p5t> | ||
604 | { | ||
605 | public: | ||
606 | __Slot5F( ret (*pFnc)( p1t, p2t, p3t, p4t, p5t ) ) : | ||
607 | pFnc( pFnc ) { } | ||
608 | virtual ~__Slot5F() { } | ||
609 | |||
610 | virtual ret operator()( p1t p1, p2t p2, p3t p3, p4t p4, p5t p5 ) | ||
611 | { | ||
612 | return (*pFnc)( p1, p2, p3, p4, p5 ); | ||
613 | } | ||
614 | |||
615 | virtual _Slot5<ret, p1t, p2t, p3t, p4t, p5t> *clone() const | ||
616 | { | ||
617 | return new __Slot5F<ret, p1t, p2t, p3t, p4t, p5t>( pFnc ); | ||
618 | } | ||
619 | |||
620 | private: | ||
621 | ret (*pFnc)( p1t, p2t, p3t, p4t, p5t ); | ||
622 | }; | ||
623 | |||
624 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t, typename p5t> | ||
625 | class Signal5 | ||
626 | { | ||
627 | public: | ||
628 | Signal5() : pCb( NULL ) { } | ||
629 | Signal5( _Slot5<ret, p1t, p2t, p3t, p4t, p5t> *pCb ) : pCb( pCb ) { } | ||
630 | Signal5( const Signal5<ret, p1t, p2t, p3t, p4t, p5t> &rSrc ) : | ||
631 | pCb( (rSrc.pCb)?(rSrc.pCb->clone()):(NULL) ) { } | ||
632 | |||
633 | virtual ~Signal5() { delete pCb; pCb = NULL; } | ||
634 | |||
635 | ret operator()( p1t p1, p2t p2, p3t p3, p4t p4, p5t p5 ) | ||
636 | { | ||
637 | if( !pCb ) throw SignalException("Uninitialized signal used."); | ||
638 | return (*pCb)( p1, p2, p3, p4, p5 ); | ||
639 | } | ||
640 | |||
641 | bool isSet() const { return pCb != NULL; } | ||
642 | operator bool() const { return isSet(); } | ||
643 | |||
644 | Signal5<ret, p1t, p2t, p3t, p4t, p5t> &operator=( const Signal5<ret, p1t, p2t, p3t, p4t, p5t> &rhs ) | ||
645 | { | ||
646 | pCb = rhs.pCb->clone(); | ||
647 | return *this; | ||
648 | } | ||
649 | |||
650 | private: | ||
651 | _Slot5<ret, p1t, p2t, p3t, p4t, p5t> *pCb; | ||
652 | }; | ||
653 | |||
654 | template<typename cls, typename ret, typename p1t, typename p2t, typename p3t, typename p4t, typename p5t> | ||
655 | Signal5<ret, p1t, p2t, p3t, p4t, p5t> slot( cls *pCls, ret (cls::*pFnc)( p1t, p2t, p3t, p4t, p5t ) ) | ||
656 | { | ||
657 | if( !pCls || !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
658 | return Signal5<ret, p1t, p2t, p3t, p4t, p5t>( | ||
659 | new __Slot5<cls, ret, p1t, p2t, p3t, p4t, p5t>( pCls, pFnc ) | ||
660 | ); | ||
661 | } | ||
662 | |||
663 | template<typename ret, typename p1t, typename p2t, typename p3t, typename p4t, typename p5t> | ||
664 | Signal5<ret, p1t, p2t, p3t, p4t, p5t> slot( ret (*pFnc)( p1t, p2t, p3t, p4t, p5t ) ) | ||
665 | { | ||
666 | if( !pFnc ) throw SignalException("NULL pointer in slot()."); | ||
667 | return Signal5<ret, p1t, p2t, p3t, p4t, p5t>( | ||
668 | new __Slot5F<ret, p1t, p2t, p3t, p4t, p5t>( pFnc ) | ||
669 | ); | ||
670 | } | ||
671 | |||
672 | }; | ||
673 | |||
674 | #endif | ||