ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/include/ermyth/callback.h
Revision: 1.1
Committed: Tue Aug 28 17:14:43 2007 UTC (16 years, 9 months ago) by pippijn
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
added new files

File Contents

# Content
1 #ifndef ERMYTH_FUNCTOR_H
2 #define ERMYTH_FUNCTOR_H
3
4 #include <memory>
5 #include <iostream>
6 #include <vector>
7
8 #ifndef BENCHMARK
9 #define BENCHMARK 0
10 #endif
11 #ifndef TIMER
12 #define TIMER 0
13 #endif
14 #ifndef TEST_FUNCTOR
15 #define TEST_FUNCTOR 0
16 #endif
17 #ifndef TEST_CALLBACKS
18 #define TEST_CALLBACKS 0
19 #endif
20
21 #if __GNUC__ < 4
22 #define GCC_BUG_8271
23 #endif
24
25 namespace functor
26 {
27 namespace impl
28 {
29 class GenericClass;
30
31 template<class OutputClass, class InputClass>
32 OutputClass union_cast (const InputClass input)
33 {
34 union
35 {
36 OutputClass out;
37 InputClass in;
38 } u;
39 u.in = input;
40 return u.out;
41 }
42
43 class storage
44 {
45 protected:
46 typedef void (impl::GenericClass::*GenericMemFuncType) ();
47 impl::GenericClass *m_pthis;
48 GenericMemFuncType m_pFunction;
49
50 public:
51 storage ()
52 : m_pthis (0), m_pFunction (0)
53 {
54 }
55
56 void clear ()
57 {
58 m_pthis = 0;
59 m_pFunction = 0;
60 }
61
62 public:
63 bool operator == (const storage &x) const
64 {
65 return m_pthis == x.m_pthis && m_pFunction == x.m_pFunction;
66 }
67
68 bool operator != (const storage &x) const
69 {
70 return !(*this == x);
71 }
72
73 bool operator ! () const
74 {
75 return m_pthis == 0 && m_pFunction == 0;
76 }
77
78 public:
79 storage &operator = (const storage &rhs)
80 {
81 store (rhs);
82 return *this;
83 }
84
85 bool operator < (const storage &rhs) const
86 {
87 if (m_pthis != rhs.m_pthis)
88 return m_pthis < rhs.m_pthis;
89 return memcmp (&m_pFunction, &rhs.m_pFunction, sizeof (m_pFunction)) < 0;
90 }
91
92 bool operator > (const storage &rhs) const
93 {
94 return rhs.operator < (*this);
95 }
96
97 storage (const storage &rhs)
98 : m_pthis (rhs.m_pthis), m_pFunction (rhs.m_pFunction)
99 {
100 }
101
102 protected:
103 void store (const storage &rhs)
104 {
105 m_pFunction = rhs.m_pFunction;
106 m_pthis = rhs.m_pthis;
107 }
108 };
109
110 template<class GenericMemFunc, class StaticFuncPtr>
111 class ClosurePtr : public storage
112 {
113 typedef ClosurePtr<GenericMemFunc, StaticFuncPtr> self_type;
114
115 public:
116 template<class X, class XMemFunc>
117 void bindmemfunc (X *pthis, XMemFunc function_to_bind)
118 {
119 m_pFunction = reinterpret_cast<GenericMemFuncType> (function_to_bind);
120 m_pthis = reinterpret_cast<GenericClass *> (pthis);
121 }
122
123 template<class X, class XMemFunc>
124 void bindconstmemfunc (const X *pthis, XMemFunc function_to_bind)
125 {
126 m_pFunction = reinterpret_cast<GenericMemFuncType> (function_to_bind);
127 m_pthis = reinterpret_cast<GenericClass *> (const_cast<X *> (pthis));
128 }
129
130 #ifdef GCC_BUG_8271
131 template<class X, class XMemFunc>
132 void bindmemfunc (const X *pthis, XMemFunc function_to_bind)
133 {
134 bindconstmemfunc (pthis, function_to_bind);
135 }
136 #endif
137
138 GenericClass *GetClosureThis () const
139 {
140 return m_pthis;
141 }
142
143 GenericMemFunc GetClosureMemPtr () const
144 {
145 return reinterpret_cast<GenericMemFunc> (m_pFunction);
146 }
147
148 template<class DerivedClass, class ParentInvokerSig>
149 void bindstaticfunc (DerivedClass *pParent, ParentInvokerSig static_function_invoker, StaticFuncPtr function_to_bind)
150 {
151 if (function_to_bind == 0)
152 m_pFunction = 0;
153 else
154 bindmemfunc (pParent, static_function_invoker);
155
156 m_pthis = reinterpret_cast<GenericClass *> (reinterpret_cast<long> (function_to_bind));
157 }
158
159 operator StaticFuncPtr () const
160 {
161 return union_cast<StaticFuncPtr> (this);
162 }
163
164 bool operator == (StaticFuncPtr funcptr) const
165 {
166 if (funcptr == 0)
167 return !*this;
168 else
169 return funcptr == static_cast<StaticFuncPtr> (this);
170 }
171
172 bool operator != (StaticFuncPtr funcptr) const
173 {
174 return !(*this == funcptr);
175 }
176
177 bool operator == (self_type const &rhs) const
178 {
179 return this->storage::operator == (rhs);
180 }
181
182 bool operator != (self_type const &rhs) const
183 {
184 return !(*this == rhs);
185 }
186 };
187 }
188
189 // Auto-generated code for Functors {{{
190 // n = 0
191
192 template<class RetType = void>
193 class functor0
194 {
195 private:
196 typedef RetType (*StaticFunctionPtr) ();
197 typedef RetType (impl::GenericClass::*GenericMemFn) ();
198 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
199 ClosureType m_Closure;
200
201 public:
202 typedef functor0 type;
203
204 functor0 ()
205 {
206 clear ();
207 }
208
209 functor0 (const functor0 &x)
210 {
211 m_Closure = x.m_Closure;
212 }
213
214 void operator = (const functor0 &x)
215 {
216 m_Closure = x.m_Closure;
217 }
218
219 bool operator == (const functor0 &x) const
220 {
221 return m_Closure == x.m_Closure;
222 }
223
224 bool operator != (const functor0 &x) const
225 {
226 return m_Closure != x.m_Closure;
227 }
228
229 bool operator < (const functor0 &x) const
230 {
231 return m_Closure < x.m_Closure;
232 }
233
234 bool operator > (const functor0 &x) const
235 {
236 return m_Closure > x.m_Closure;
237 }
238
239 template<class X, class Y>
240 functor0 (Y *pthis, RetType (X::*function_to_bind) ())
241 {
242 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
243 }
244
245 template<class X, class Y>
246 void bind (Y *pthis, RetType (X::*function_to_bind) ())
247 {
248 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
249 }
250
251 template<class X, class Y>
252 functor0 (const Y *pthis, RetType (X::*function_to_bind) () const)
253 {
254 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
255 }
256
257 template<class X, class Y>
258 void bind (const Y *pthis, RetType (X::*function_to_bind) () const)
259 {
260 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
261 }
262
263 functor0 (RetType (*function_to_bind) ())
264 {
265 bind (function_to_bind);
266 }
267
268 void operator = (RetType (*function_to_bind) ())
269 {
270 bind (function_to_bind);
271 }
272
273 void bind (RetType (*function_to_bind) ())
274 {
275 m_Closure.bindstaticfunc (this, &functor0::InvokeStaticFunction, function_to_bind);
276 }
277
278 RetType operator () () const
279 {
280 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) ();
281 }
282
283 public:
284 bool operator == (StaticFunctionPtr funcptr) const
285 {
286 return m_Closure == funcptr;
287 }
288
289 bool operator != (StaticFunctionPtr funcptr) const
290 {
291 return m_Closure != funcptr;
292 }
293
294 bool operator ! () const
295 {
296 return !m_Closure;
297 }
298
299 void clear ()
300 {
301 m_Closure.clear ();
302 }
303
304 const impl::storage &retrieve () const
305 {
306 return m_Closure;
307 }
308
309 void store (const impl::storage &any)
310 {
311 m_Closure = any;
312 }
313
314 private:
315 RetType InvokeStaticFunction () const
316 {
317 return (*(static_cast<StaticFunctionPtr> (m_Closure))) ();
318 }
319 };
320
321 // n = 1
322
323 template<class Param1, class RetType = void>
324 class functor1
325 {
326 private:
327 typedef RetType (*StaticFunctionPtr) (Param1 p1);
328 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1);
329 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
330 ClosureType m_Closure;
331
332 public:
333 typedef functor1 type;
334
335 functor1 ()
336 {
337 clear ();
338 }
339
340 functor1 (const functor1 &x)
341 {
342 m_Closure = x.m_Closure;
343 }
344
345 void operator = (const functor1 &x)
346 {
347 m_Closure = x.m_Closure;
348 }
349
350 bool operator == (const functor1 &x) const
351 {
352 return m_Closure == x.m_Closure;
353 }
354
355 bool operator != (const functor1 &x) const
356 {
357 return m_Closure != x.m_Closure;
358 }
359
360 bool operator < (const functor1 &x) const
361 {
362 return m_Closure < x.m_Closure;
363 }
364
365 bool operator > (const functor1 &x) const
366 {
367 return m_Closure > x.m_Closure;
368 }
369
370 template<class X, class Y>
371 functor1 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1))
372 {
373 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
374 }
375
376 template<class X, class Y>
377 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1))
378 {
379 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
380 }
381
382 template<class X, class Y>
383 functor1 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1) const)
384 {
385 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
386 }
387
388 template<class X, class Y>
389 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1) const)
390 {
391 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
392 }
393
394 functor1 (RetType (*function_to_bind) (Param1 p1))
395 {
396 bind (function_to_bind);
397 }
398
399 void operator = (RetType (*function_to_bind) (Param1 p1))
400 {
401 bind (function_to_bind);
402 }
403
404 void bind (RetType (*function_to_bind) (Param1 p1))
405 {
406 m_Closure.bindstaticfunc (this, &functor1::InvokeStaticFunction, function_to_bind);
407 }
408
409 RetType operator () (Param1 p1) const
410 {
411 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1);
412 }
413
414 public:
415 bool operator == (StaticFunctionPtr funcptr) const
416 {
417 return m_Closure == funcptr;
418 }
419
420 bool operator != (StaticFunctionPtr funcptr) const
421 {
422 return m_Closure != funcptr;
423 }
424
425 bool operator ! () const
426 {
427 return !m_Closure;
428 }
429
430 void clear ()
431 {
432 m_Closure.clear ();
433 }
434
435 const impl::storage &retrieve () const
436 {
437 return m_Closure;
438 }
439
440 void store (const impl::storage &any)
441 {
442 m_Closure = any;
443 }
444
445 private:
446 RetType InvokeStaticFunction (Param1 p1) const
447 {
448 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1);
449 }
450 };
451
452 // n = 2
453
454 template<class Param1, class Param2, class RetType = void>
455 class functor2
456 {
457 private:
458 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2);
459 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2);
460 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
461 ClosureType m_Closure;
462
463 public:
464 typedef functor2 type;
465
466 functor2 ()
467 {
468 clear ();
469 }
470
471 functor2 (const functor2 &x)
472 {
473 m_Closure = x.m_Closure;
474 }
475
476 void operator = (const functor2 &x)
477 {
478 m_Closure = x.m_Closure;
479 }
480
481 bool operator == (const functor2 &x) const
482 {
483 return m_Closure == x.m_Closure;
484 }
485
486 bool operator != (const functor2 &x) const
487 {
488 return m_Closure != x.m_Closure;
489 }
490
491 bool operator < (const functor2 &x) const
492 {
493 return m_Closure < x.m_Closure;
494 }
495
496 bool operator > (const functor2 &x) const
497 {
498 return m_Closure > x.m_Closure;
499 }
500
501 template<class X, class Y>
502 functor2 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2))
503 {
504 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
505 }
506
507 template<class X, class Y>
508 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2))
509 {
510 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
511 }
512
513 template<class X, class Y>
514 functor2 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2) const)
515 {
516 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
517 }
518
519 template<class X, class Y>
520 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2) const)
521 {
522 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
523 }
524
525 functor2 (RetType (*function_to_bind) (Param1 p1, Param2 p2))
526 {
527 bind (function_to_bind);
528 }
529
530 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2))
531 {
532 bind (function_to_bind);
533 }
534
535 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2))
536 {
537 m_Closure.bindstaticfunc (this, &functor2::InvokeStaticFunction, function_to_bind);
538 }
539
540 RetType operator () (Param1 p1, Param2 p2) const
541 {
542 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2);
543 }
544
545 public:
546 bool operator == (StaticFunctionPtr funcptr) const
547 {
548 return m_Closure == funcptr;
549 }
550
551 bool operator != (StaticFunctionPtr funcptr) const
552 {
553 return m_Closure != funcptr;
554 }
555
556 bool operator ! () const
557 {
558 return !m_Closure;
559 }
560
561 void clear ()
562 {
563 m_Closure.clear ();
564 }
565
566 const impl::storage &retrieve () const
567 {
568 return m_Closure;
569 }
570
571 void store (const impl::storage &any)
572 {
573 m_Closure = any;
574 }
575
576 private:
577 RetType InvokeStaticFunction (Param1 p1, Param2 p2) const
578 {
579 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2);
580 }
581 };
582
583 // n = 3
584
585 template<class Param1, class Param2, class Param3, class RetType = void>
586 class functor3
587 {
588 private:
589 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2, Param3 p3);
590 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2, Param3 p3);
591 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
592 ClosureType m_Closure;
593
594 public:
595 typedef functor3 type;
596
597 functor3 ()
598 {
599 clear ();
600 }
601
602 functor3 (const functor3 &x)
603 {
604 m_Closure = x.m_Closure;
605 }
606
607 void operator = (const functor3 &x)
608 {
609 m_Closure = x.m_Closure;
610 }
611
612 bool operator == (const functor3 &x) const
613 {
614 return m_Closure == x.m_Closure;
615 }
616
617 bool operator != (const functor3 &x) const
618 {
619 return m_Closure != x.m_Closure;
620 }
621
622 bool operator < (const functor3 &x) const
623 {
624 return m_Closure < x.m_Closure;
625 }
626
627 bool operator > (const functor3 &x) const
628 {
629 return m_Closure > x.m_Closure;
630 }
631
632 template<class X, class Y>
633 functor3 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
634 {
635 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
636 }
637
638 template<class X, class Y>
639 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
640 {
641 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
642 }
643
644 template<class X, class Y>
645 functor3 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3) const)
646 {
647 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
648 }
649
650 template<class X, class Y>
651 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3) const)
652 {
653 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
654 }
655
656 functor3 (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
657 {
658 bind (function_to_bind);
659 }
660
661 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
662 {
663 bind (function_to_bind);
664 }
665
666 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
667 {
668 m_Closure.bindstaticfunc (this, &functor3::InvokeStaticFunction, function_to_bind);
669 }
670
671 RetType operator () (Param1 p1, Param2 p2, Param3 p3) const
672 {
673 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2, p3);
674 }
675
676 public:
677 bool operator == (StaticFunctionPtr funcptr) const
678 {
679 return m_Closure == funcptr;
680 }
681
682 bool operator != (StaticFunctionPtr funcptr) const
683 {
684 return m_Closure != funcptr;
685 }
686
687 bool operator ! () const
688 {
689 return !m_Closure;
690 }
691
692 void clear ()
693 {
694 m_Closure.clear ();
695 }
696
697 const impl::storage &retrieve () const
698 {
699 return m_Closure;
700 }
701
702 void store (const impl::storage &any)
703 {
704 m_Closure = any;
705 }
706
707 private:
708 RetType InvokeStaticFunction (Param1 p1, Param2 p2, Param3 p3) const
709 {
710 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2, p3);
711 }
712 };
713
714 // n = 4
715
716 template<class Param1, class Param2, class Param3, class Param4, class RetType = void>
717 class functor4
718 {
719 private:
720 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2, Param3 p3, Param4 p4);
721 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2, Param3 p3, Param4 p4);
722 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
723 ClosureType m_Closure;
724
725 public:
726 typedef functor4 type;
727
728 functor4 ()
729 {
730 clear ();
731 }
732
733 functor4 (const functor4 &x)
734 {
735 m_Closure = x.m_Closure;
736 }
737
738 void operator = (const functor4 &x)
739 {
740 m_Closure = x.m_Closure;
741 }
742
743 bool operator == (const functor4 &x) const
744 {
745 return m_Closure == x.m_Closure;
746 }
747
748 bool operator != (const functor4 &x) const
749 {
750 return m_Closure != x.m_Closure;
751 }
752
753 bool operator < (const functor4 &x) const
754 {
755 return m_Closure < x.m_Closure;
756 }
757
758 bool operator > (const functor4 &x) const
759 {
760 return m_Closure > x.m_Closure;
761 }
762
763 template<class X, class Y>
764 functor4 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
765 {
766 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
767 }
768
769 template<class X, class Y>
770 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
771 {
772 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
773 }
774
775 template<class X, class Y>
776 functor4 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const)
777 {
778 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
779 }
780
781 template<class X, class Y>
782 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const)
783 {
784 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
785 }
786
787 functor4 (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
788 {
789 bind (function_to_bind);
790 }
791
792 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
793 {
794 bind (function_to_bind);
795 }
796
797 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
798 {
799 m_Closure.bindstaticfunc (this, &functor4::InvokeStaticFunction, function_to_bind);
800 }
801
802 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const
803 {
804 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2, p3, p4);
805 }
806
807 public:
808 bool operator == (StaticFunctionPtr funcptr) const
809 {
810 return m_Closure == funcptr;
811 }
812
813 bool operator != (StaticFunctionPtr funcptr) const
814 {
815 return m_Closure != funcptr;
816 }
817
818 bool operator ! () const
819 {
820 return !m_Closure;
821 }
822
823 void clear ()
824 {
825 m_Closure.clear ();
826 }
827
828 const impl::storage &retrieve () const
829 {
830 return m_Closure;
831 }
832
833 void store (const impl::storage &any)
834 {
835 m_Closure = any;
836 }
837
838 private:
839 RetType InvokeStaticFunction (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const
840 {
841 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2, p3, p4);
842 }
843 };
844
845 // n = 5
846
847 template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType = void>
848 class functor5
849 {
850 private:
851 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
852 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
853 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
854 ClosureType m_Closure;
855
856 public:
857 typedef functor5 type;
858
859 functor5 ()
860 {
861 clear ();
862 }
863
864 functor5 (const functor5 &x)
865 {
866 m_Closure = x.m_Closure;
867 }
868
869 void operator = (const functor5 &x)
870 {
871 m_Closure = x.m_Closure;
872 }
873
874 bool operator == (const functor5 &x) const
875 {
876 return m_Closure == x.m_Closure;
877 }
878
879 bool operator != (const functor5 &x) const
880 {
881 return m_Closure != x.m_Closure;
882 }
883
884 bool operator < (const functor5 &x) const
885 {
886 return m_Closure < x.m_Closure;
887 }
888
889 bool operator > (const functor5 &x) const
890 {
891 return m_Closure > x.m_Closure;
892 }
893
894 template<class X, class Y>
895 functor5 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
896 {
897 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
898 }
899
900 template<class X, class Y>
901 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
902 {
903 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
904 }
905
906 template<class X, class Y>
907 functor5 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const)
908 {
909 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
910 }
911
912 template<class X, class Y>
913 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const)
914 {
915 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
916 }
917
918 functor5 (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
919 {
920 bind (function_to_bind);
921 }
922
923 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
924 {
925 bind (function_to_bind);
926 }
927
928 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
929 {
930 m_Closure.bindstaticfunc (this, &functor5::InvokeStaticFunction, function_to_bind);
931 }
932
933 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const
934 {
935 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2, p3, p4, p5);
936 }
937
938 public:
939 bool operator == (StaticFunctionPtr funcptr) const
940 {
941 return m_Closure == funcptr;
942 }
943
944 bool operator != (StaticFunctionPtr funcptr) const
945 {
946 return m_Closure != funcptr;
947 }
948
949 bool operator ! () const
950 {
951 return !m_Closure;
952 }
953
954 void clear ()
955 {
956 m_Closure.clear ();
957 }
958
959 const impl::storage &retrieve () const
960 {
961 return m_Closure;
962 }
963
964 void store (const impl::storage &any)
965 {
966 m_Closure = any;
967 }
968
969 private:
970 RetType InvokeStaticFunction (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const
971 {
972 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2, p3, p4, p5);
973 }
974 };
975
976 // n = 6
977
978 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType = void>
979 class functor6
980 {
981 private:
982 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
983 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
984 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
985 ClosureType m_Closure;
986
987 public:
988 typedef functor6 type;
989
990 functor6 ()
991 {
992 clear ();
993 }
994
995 functor6 (const functor6 &x)
996 {
997 m_Closure = x.m_Closure;
998 }
999
1000 void operator = (const functor6 &x)
1001 {
1002 m_Closure = x.m_Closure;
1003 }
1004
1005 bool operator == (const functor6 &x) const
1006 {
1007 return m_Closure == x.m_Closure;
1008 }
1009
1010 bool operator != (const functor6 &x) const
1011 {
1012 return m_Closure != x.m_Closure;
1013 }
1014
1015 bool operator < (const functor6 &x) const
1016 {
1017 return m_Closure < x.m_Closure;
1018 }
1019
1020 bool operator > (const functor6 &x) const
1021 {
1022 return m_Closure > x.m_Closure;
1023 }
1024
1025 template<class X, class Y>
1026 functor6 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1027 {
1028 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
1029 }
1030
1031 template<class X, class Y>
1032 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1033 {
1034 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
1035 }
1036
1037 template<class X, class Y>
1038 functor6 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const)
1039 {
1040 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
1041 }
1042
1043 template<class X, class Y>
1044 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const)
1045 {
1046 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
1047 }
1048
1049 functor6 (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1050 {
1051 bind (function_to_bind);
1052 }
1053
1054 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1055 {
1056 bind (function_to_bind);
1057 }
1058
1059 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1060 {
1061 m_Closure.bindstaticfunc (this, &functor6::InvokeStaticFunction, function_to_bind);
1062 }
1063
1064 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const
1065 {
1066 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2, p3, p4, p5, p6);
1067 }
1068
1069 public:
1070 bool operator == (StaticFunctionPtr funcptr) const
1071 {
1072 return m_Closure == funcptr;
1073 }
1074
1075 bool operator != (StaticFunctionPtr funcptr) const
1076 {
1077 return m_Closure != funcptr;
1078 }
1079
1080 bool operator ! () const
1081 {
1082 return !m_Closure;
1083 }
1084
1085 void clear ()
1086 {
1087 m_Closure.clear ();
1088 }
1089
1090 const impl::storage &retrieve () const
1091 {
1092 return m_Closure;
1093 }
1094
1095 void store (const impl::storage &any)
1096 {
1097 m_Closure = any;
1098 }
1099
1100 private:
1101 RetType InvokeStaticFunction (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const
1102 {
1103 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2, p3, p4, p5, p6);
1104 }
1105 };
1106
1107 // n = 7
1108
1109 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType = void>
1110 class functor7
1111 {
1112 private:
1113 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
1114 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
1115 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
1116 ClosureType m_Closure;
1117
1118 public:
1119 typedef functor7 type;
1120
1121 functor7 ()
1122 {
1123 clear ();
1124 }
1125
1126 functor7 (const functor7 &x)
1127 {
1128 m_Closure = x.m_Closure;
1129 }
1130
1131 void operator = (const functor7 &x)
1132 {
1133 m_Closure = x.m_Closure;
1134 }
1135
1136 bool operator == (const functor7 &x) const
1137 {
1138 return m_Closure == x.m_Closure;
1139 }
1140
1141 bool operator != (const functor7 &x) const
1142 {
1143 return m_Closure != x.m_Closure;
1144 }
1145
1146 bool operator < (const functor7 &x) const
1147 {
1148 return m_Closure < x.m_Closure;
1149 }
1150
1151 bool operator > (const functor7 &x) const
1152 {
1153 return m_Closure > x.m_Closure;
1154 }
1155
1156 template<class X, class Y>
1157 functor7 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1158 {
1159 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
1160 }
1161
1162 template<class X, class Y>
1163 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1164 {
1165 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
1166 }
1167
1168 template<class X, class Y>
1169 functor7 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const)
1170 {
1171 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
1172 }
1173
1174 template<class X, class Y>
1175 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const)
1176 {
1177 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
1178 }
1179
1180 functor7 (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1181 {
1182 bind (function_to_bind);
1183 }
1184
1185 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1186 {
1187 bind (function_to_bind);
1188 }
1189
1190 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1191 {
1192 m_Closure.bindstaticfunc (this, &functor7::InvokeStaticFunction, function_to_bind);
1193 }
1194
1195 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const
1196 {
1197 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2, p3, p4, p5, p6, p7);
1198 }
1199
1200 public:
1201 bool operator == (StaticFunctionPtr funcptr) const
1202 {
1203 return m_Closure == funcptr;
1204 }
1205
1206 bool operator != (StaticFunctionPtr funcptr) const
1207 {
1208 return m_Closure != funcptr;
1209 }
1210
1211 bool operator ! () const
1212 {
1213 return !m_Closure;
1214 }
1215
1216 void clear ()
1217 {
1218 m_Closure.clear ();
1219 }
1220
1221 const impl::storage &retrieve () const
1222 {
1223 return m_Closure;
1224 }
1225
1226 void store (const impl::storage &any)
1227 {
1228 m_Closure = any;
1229 }
1230
1231 private:
1232 RetType InvokeStaticFunction (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const
1233 {
1234 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2, p3, p4, p5, p6, p7);
1235 }
1236 };
1237
1238 // n = 8
1239
1240 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType = void>
1241 class functor8
1242 {
1243 private:
1244 typedef RetType (*StaticFunctionPtr) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
1245 typedef RetType (impl::GenericClass::*GenericMemFn) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
1246 typedef impl::ClosurePtr<GenericMemFn, StaticFunctionPtr> ClosureType;
1247 ClosureType m_Closure;
1248
1249 public:
1250 typedef functor8 type;
1251
1252 functor8 ()
1253 {
1254 clear ();
1255 }
1256
1257 functor8 (const functor8 &x)
1258 {
1259 m_Closure = x.m_Closure;
1260 }
1261
1262 void operator = (const functor8 &x)
1263 {
1264 m_Closure = x.m_Closure;
1265 }
1266
1267 bool operator == (const functor8 &x) const
1268 {
1269 return m_Closure == x.m_Closure;
1270 }
1271
1272 bool operator != (const functor8 &x) const
1273 {
1274 return m_Closure != x.m_Closure;
1275 }
1276
1277 bool operator < (const functor8 &x) const
1278 {
1279 return m_Closure < x.m_Closure;
1280 }
1281
1282 bool operator > (const functor8 &x) const
1283 {
1284 return m_Closure > x.m_Closure;
1285 }
1286
1287 template<class X, class Y>
1288 functor8 (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1289 {
1290 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
1291 }
1292
1293 template<class X, class Y>
1294 void bind (Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1295 {
1296 m_Closure.bindmemfunc (static_cast<X*> (pthis), function_to_bind);
1297 }
1298
1299 template<class X, class Y>
1300 functor8 (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const)
1301 {
1302 m_Closure.bindconstmemfunc (static_cast<const X*> (pthis), function_to_bind);
1303 }
1304
1305 template<class X, class Y>
1306 void bind (const Y *pthis, RetType (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const)
1307 {
1308 m_Closure.bindconstmemfunc (static_cast<const X *> (pthis), function_to_bind);
1309 }
1310
1311 functor8 (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1312 {
1313 bind (function_to_bind);
1314 }
1315
1316 void operator = (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1317 {
1318 bind (function_to_bind);
1319 }
1320
1321 void bind (RetType (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1322 {
1323 m_Closure.bindstaticfunc (this, &functor8::InvokeStaticFunction, function_to_bind);
1324 }
1325
1326 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const
1327 {
1328 return (m_Closure.GetClosureThis ()->*(m_Closure.GetClosureMemPtr ())) (p1, p2, p3, p4, p5, p6, p7, p8);
1329 }
1330
1331 public:
1332 bool operator == (StaticFunctionPtr funcptr) const
1333 {
1334 return m_Closure == funcptr;
1335 }
1336
1337 bool operator != (StaticFunctionPtr funcptr) const
1338 {
1339 return m_Closure != funcptr;
1340 }
1341
1342 bool operator ! () const
1343 {
1344 return !m_Closure;
1345 }
1346
1347 void clear ()
1348 {
1349 m_Closure.clear ();
1350 }
1351
1352 const impl::storage &retrieve () const
1353 {
1354 return m_Closure;
1355 }
1356
1357 void store (const impl::storage &any)
1358 {
1359 m_Closure = any;
1360 }
1361
1362 private:
1363 RetType InvokeStaticFunction (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const
1364 {
1365 return (*(static_cast<StaticFunctionPtr> (m_Closure))) (p1, p2, p3, p4, p5, p6, p7, p8);
1366 }
1367 };
1368
1369 // }}} End auto-generated code
1370
1371 template<typename Signature>
1372 class functor;
1373
1374 // Auto-generated code for Functors with functioncall syntax {{{
1375 // n = 0
1376
1377 template<typename R>
1378 class functor<R ()>
1379 : public functor0<R>
1380 {
1381 public:
1382 typedef functor0<R> BaseType;
1383
1384 typedef functor SelfType;
1385
1386 functor ()
1387 : BaseType ()
1388 {
1389 }
1390
1391 template<class X, class Y>
1392 functor (Y *pthis, R (X::*function_to_bind) ())
1393 : BaseType (pthis, function_to_bind)
1394 {
1395 }
1396
1397 template<class X, class Y>
1398 functor (const Y *pthis, R (X::*function_to_bind) () const)
1399 : BaseType (pthis, function_to_bind)
1400 {
1401 }
1402
1403 functor (R (*function_to_bind) ())
1404 : BaseType (function_to_bind)
1405 {
1406 }
1407
1408 void operator = (const BaseType &x)
1409 {
1410 *static_cast<BaseType*> (this) = x;
1411 }
1412 };
1413
1414 // n = 1
1415
1416 template<typename R, class Param1>
1417 class functor<R (Param1)>
1418 : public functor1<Param1, R>
1419 {
1420 public:
1421 typedef functor1<Param1, R> BaseType;
1422
1423 typedef functor SelfType;
1424
1425 functor ()
1426 : BaseType ()
1427 {
1428 }
1429
1430 template<class X, class Y>
1431 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1))
1432 : BaseType (pthis, function_to_bind)
1433 {
1434 }
1435
1436 template<class X, class Y>
1437 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1) const)
1438 : BaseType (pthis, function_to_bind)
1439 {
1440 }
1441
1442 functor (R (*function_to_bind) (Param1 p1))
1443 : BaseType (function_to_bind)
1444 {
1445 }
1446
1447 void operator = (const BaseType &x)
1448 {
1449 *static_cast<BaseType*> (this) = x;
1450 }
1451 };
1452
1453 // n = 2
1454
1455 template<typename R, class Param1, class Param2>
1456 class functor<R (Param1, Param2)>
1457 : public functor2<Param1, Param2, R>
1458 {
1459 public:
1460 typedef functor2<Param1, Param2, R> BaseType;
1461
1462 typedef functor SelfType;
1463
1464 functor ()
1465 : BaseType ()
1466 {
1467 }
1468
1469 template<class X, class Y>
1470 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2))
1471 : BaseType (pthis, function_to_bind)
1472 {
1473 }
1474
1475 template<class X, class Y>
1476 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2) const)
1477 : BaseType (pthis, function_to_bind)
1478 {
1479 }
1480
1481 functor (R (*function_to_bind) (Param1 p1, Param2 p2))
1482 : BaseType (function_to_bind)
1483 {
1484 }
1485
1486 void operator = (const BaseType &x)
1487 {
1488 *static_cast<BaseType*> (this) = x;
1489 }
1490 };
1491
1492 // n = 3
1493
1494 template<typename R, class Param1, class Param2, class Param3>
1495 class functor<R (Param1, Param2, Param3)>
1496 : public functor3<Param1, Param2, Param3, R>
1497 {
1498 public:
1499 typedef functor3<Param1, Param2, Param3, R> BaseType;
1500
1501 typedef functor SelfType;
1502
1503 functor ()
1504 : BaseType ()
1505 {
1506 }
1507
1508 template<class X, class Y>
1509 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
1510 : BaseType (pthis, function_to_bind)
1511 {
1512 }
1513
1514 template<class X, class Y>
1515 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3) const)
1516 : BaseType (pthis, function_to_bind)
1517 {
1518 }
1519
1520 functor (R (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3))
1521 : BaseType (function_to_bind)
1522 {
1523 }
1524
1525 void operator = (const BaseType &x)
1526 {
1527 *static_cast<BaseType*> (this) = x;
1528 }
1529 };
1530
1531 // n = 4
1532
1533 template<typename R, class Param1, class Param2, class Param3, class Param4>
1534 class functor<R (Param1, Param2, Param3, Param4)>
1535 : public functor4<Param1, Param2, Param3, Param4, R>
1536 {
1537 public:
1538 typedef functor4<Param1, Param2, Param3, Param4, R> BaseType;
1539
1540 typedef functor SelfType;
1541
1542 functor ()
1543 : BaseType ()
1544 {
1545 }
1546
1547 template<class X, class Y>
1548 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
1549 : BaseType (pthis, function_to_bind)
1550 {
1551 }
1552
1553 template<class X, class Y>
1554 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const)
1555 : BaseType (pthis, function_to_bind)
1556 {
1557 }
1558
1559 functor (R (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
1560 : BaseType (function_to_bind)
1561 {
1562 }
1563
1564 void operator = (const BaseType &x)
1565 {
1566 *static_cast<BaseType*> (this) = x;
1567 }
1568 };
1569
1570 // n = 5
1571
1572 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5>
1573 class functor<R (Param1, Param2, Param3, Param4, Param5)>
1574 : public functor5<Param1, Param2, Param3, Param4, Param5, R>
1575 {
1576 public:
1577 typedef functor5<Param1, Param2, Param3, Param4, Param5, R> BaseType;
1578
1579 typedef functor SelfType;
1580
1581 functor ()
1582 : BaseType ()
1583 {
1584 }
1585
1586 template<class X, class Y>
1587 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
1588 : BaseType (pthis, function_to_bind)
1589 {
1590 }
1591
1592 template<class X, class Y>
1593 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const)
1594 : BaseType (pthis, function_to_bind)
1595 {
1596 }
1597
1598 functor (R (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
1599 : BaseType (function_to_bind)
1600 {
1601 }
1602
1603 void operator = (const BaseType &x)
1604 {
1605 *static_cast<BaseType*> (this) = x;
1606 }
1607 };
1608
1609 // n = 6
1610
1611 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6>
1612 class functor<R (Param1, Param2, Param3, Param4, Param5, Param6)>
1613 : public functor6<Param1, Param2, Param3, Param4, Param5, Param6, R>
1614 {
1615 public:
1616 typedef functor6<Param1, Param2, Param3, Param4, Param5, Param6, R> BaseType;
1617
1618 typedef functor SelfType;
1619
1620 functor ()
1621 : BaseType ()
1622 {
1623 }
1624
1625 template<class X, class Y>
1626 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1627 : BaseType (pthis, function_to_bind)
1628 {
1629 }
1630
1631 template<class X, class Y>
1632 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const)
1633 : BaseType (pthis, function_to_bind)
1634 {
1635 }
1636
1637 functor (R (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1638 : BaseType (function_to_bind)
1639 {
1640 }
1641
1642 void operator = (const BaseType &x)
1643 {
1644 *static_cast<BaseType*> (this) = x;
1645 }
1646 };
1647
1648 // n = 7
1649
1650 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7>
1651 class functor<R (Param1, Param2, Param3, Param4, Param5, Param6, Param7)>
1652 : public functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, R>
1653 {
1654 public:
1655 typedef functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, R> BaseType;
1656
1657 typedef functor SelfType;
1658
1659 functor ()
1660 : BaseType ()
1661 {
1662 }
1663
1664 template<class X, class Y>
1665 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1666 : BaseType (pthis, function_to_bind)
1667 {
1668 }
1669
1670 template<class X, class Y>
1671 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const)
1672 : BaseType (pthis, function_to_bind)
1673 {
1674 }
1675
1676 functor (R (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1677 : BaseType (function_to_bind)
1678 {
1679 }
1680
1681 void operator = (const BaseType &x)
1682 {
1683 *static_cast<BaseType*> (this) = x;
1684 }
1685 };
1686
1687 // n = 8
1688
1689 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8>
1690 class functor<R (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8)>
1691 : public functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R>
1692 {
1693 public:
1694 typedef functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R> BaseType;
1695
1696 typedef functor SelfType;
1697
1698 functor ()
1699 : BaseType ()
1700 {
1701 }
1702
1703 template<class X, class Y>
1704 functor (Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1705 : BaseType (pthis, function_to_bind)
1706 {
1707 }
1708
1709 template<class X, class Y>
1710 functor (const Y *pthis, R (X::*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const)
1711 : BaseType (pthis, function_to_bind)
1712 {
1713 }
1714
1715 functor (R (*function_to_bind) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1716 : BaseType (function_to_bind)
1717 {
1718 }
1719
1720 void operator = (const BaseType &x)
1721 {
1722 *static_cast<BaseType*> (this) = x;
1723 }
1724 };
1725
1726 // }}} End auto-generated code
1727
1728 // Auto-generated code for make_functor helper function {{{
1729 // n = 0
1730
1731 template<class X, class Y, class RetType>
1732 functor0<RetType>
1733 make_functor (Y *x, RetType (X::*func) ())
1734 {
1735 return functor0<RetType> (x, func);
1736 }
1737
1738 template<class X, class Y, class RetType>
1739 functor0<RetType>
1740 make_functor (Y *x, RetType (X::*func) () const)
1741 {
1742 return functor0<RetType> (x, func);
1743 }
1744
1745 // n = 1
1746
1747 template<class X, class Y, class Param1, class RetType>
1748 functor1<Param1, RetType>
1749 make_functor (Y *x, RetType (X::*func) (Param1 p1))
1750 {
1751 return functor1<Param1, RetType> (x, func);
1752 }
1753
1754 template<class X, class Y, class Param1, class RetType>
1755 functor1<Param1, RetType>
1756 make_functor (Y *x, RetType (X::*func) (Param1 p1) const)
1757 {
1758 return functor1<Param1, RetType> (x, func);
1759 }
1760
1761 // n = 2
1762
1763 template<class X, class Y, class Param1, class Param2, class RetType>
1764 functor2<Param1, Param2, RetType>
1765 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2))
1766 {
1767 return functor2<Param1, Param2, RetType> (x, func);
1768 }
1769
1770 template<class X, class Y, class Param1, class Param2, class RetType>
1771 functor2<Param1, Param2, RetType>
1772 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2) const)
1773 {
1774 return functor2<Param1, Param2, RetType> (x, func);
1775 }
1776
1777 // n = 3
1778
1779 template<class X, class Y, class Param1, class Param2, class Param3, class RetType>
1780 functor3<Param1, Param2, Param3, RetType>
1781 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3))
1782 {
1783 return functor3<Param1, Param2, Param3, RetType> (x, func);
1784 }
1785
1786 template<class X, class Y, class Param1, class Param2, class Param3, class RetType>
1787 functor3<Param1, Param2, Param3, RetType>
1788 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3) const)
1789 {
1790 return functor3<Param1, Param2, Param3, RetType> (x, func);
1791 }
1792
1793 // n = 4
1794
1795 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
1796 functor4<Param1, Param2, Param3, Param4, RetType>
1797 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4))
1798 {
1799 return functor4<Param1, Param2, Param3, Param4, RetType> (x, func);
1800 }
1801
1802 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
1803 functor4<Param1, Param2, Param3, Param4, RetType>
1804 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const)
1805 {
1806 return functor4<Param1, Param2, Param3, Param4, RetType> (x, func);
1807 }
1808
1809 // n = 5
1810
1811 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
1812 functor5<Param1, Param2, Param3, Param4, Param5, RetType>
1813 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5))
1814 {
1815 return functor5<Param1, Param2, Param3, Param4, Param5, RetType> (x, func);
1816 }
1817
1818 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
1819 functor5<Param1, Param2, Param3, Param4, Param5, RetType>
1820 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const)
1821 {
1822 return functor5<Param1, Param2, Param3, Param4, Param5, RetType> (x, func);
1823 }
1824
1825 // n = 6
1826
1827 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
1828 functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType>
1829 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6))
1830 {
1831 return functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType> (x, func);
1832 }
1833
1834 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
1835 functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType>
1836 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const)
1837 {
1838 return functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType> (x, func);
1839 }
1840
1841 // n = 7
1842
1843 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
1844 functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType>
1845 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7))
1846 {
1847 return functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType> (x, func);
1848 }
1849
1850 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
1851 functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType>
1852 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const)
1853 {
1854 return functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType> (x, func);
1855 }
1856
1857 // n = 8
1858
1859 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
1860 functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType>
1861 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8))
1862 {
1863 return functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType> (x, func);
1864 }
1865
1866 template<class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
1867 functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType>
1868 make_functor (Y *x, RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const)
1869 {
1870 return functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType> (x, func);
1871 }
1872
1873 // }}} End auto-generated code
1874
1875 // Auto-generated code for boost::bind-like helper function {{{
1876 // n = 0
1877
1878 template<class X, class Y, class RetType>
1879 functor<RetType ()>
1880 bind (RetType (X::*func) (), Y *y, ...)
1881 {
1882 return functor<RetType ()> (y, func);
1883 }
1884
1885 template<class X, class Y, class RetType>
1886 functor<RetType ()>
1887 bind (RetType (X::*func) () const, Y *y, ...)
1888 {
1889 return functor<RetType ()> (y, func);
1890 }
1891
1892 // n = 1
1893
1894 template<class X, class Y, class RetType, class Param1>
1895 functor<RetType (Param1 p1)>
1896 bind (RetType (X::*func) (Param1 p1), Y *y, ...)
1897 {
1898 return functor<RetType (Param1 p1)> (y, func);
1899 }
1900
1901 template<class X, class Y, class RetType, class Param1>
1902 functor<RetType (Param1 p1)>
1903 bind (RetType (X::*func) (Param1 p1) const, Y *y, ...)
1904 {
1905 return functor<RetType (Param1 p1)> (y, func);
1906 }
1907
1908 // n = 2
1909
1910 template<class X, class Y, class RetType, class Param1, class Param2>
1911 functor<RetType (Param1 p1, Param2 p2)>
1912 bind (RetType (X::*func) (Param1 p1, Param2 p2), Y *y, ...)
1913 {
1914 return functor<RetType (Param1 p1, Param2 p2)> (y, func);
1915 }
1916
1917 template<class X, class Y, class RetType, class Param1, class Param2>
1918 functor<RetType (Param1 p1, Param2 p2)>
1919 bind (RetType (X::*func) (Param1 p1, Param2 p2) const, Y *y, ...)
1920 {
1921 return functor<RetType (Param1 p1, Param2 p2)> (y, func);
1922 }
1923
1924 // n = 3
1925
1926 template<class X, class Y, class RetType, class Param1, class Param2, class Param3>
1927 functor<RetType (Param1 p1, Param2 p2, Param3 p3)>
1928 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3), Y *y, ...)
1929 {
1930 return functor<RetType (Param1 p1, Param2 p2, Param3 p3)> (y, func);
1931 }
1932
1933 template<class X, class Y, class RetType, class Param1, class Param2, class Param3>
1934 functor<RetType (Param1 p1, Param2 p2, Param3 p3)>
1935 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3) const, Y *y, ...)
1936 {
1937 return functor<RetType (Param1 p1, Param2 p2, Param3 p3)> (y, func);
1938 }
1939
1940 // n = 4
1941
1942 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4>
1943 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4)>
1944 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4), Y *y, ...)
1945 {
1946 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4)> (y, func);
1947 }
1948
1949 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4>
1950 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4)>
1951 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const, Y *y, ...)
1952 {
1953 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4)> (y, func);
1954 }
1955
1956 // n = 5
1957
1958 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5>
1959 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)>
1960 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5), Y *y, ...)
1961 {
1962 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)> (y, func);
1963 }
1964
1965 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5>
1966 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)>
1967 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const, Y *y, ...)
1968 {
1969 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)> (y, func);
1970 }
1971
1972 // n = 6
1973
1974 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6>
1975 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)>
1976 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6), Y *y, ...)
1977 {
1978 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)> (y, func);
1979 }
1980
1981 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6>
1982 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)>
1983 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const, Y *y, ...)
1984 {
1985 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)> (y, func);
1986 }
1987
1988 // n = 7
1989
1990 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7>
1991 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)>
1992 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7), Y *y, ...)
1993 {
1994 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)> (y, func);
1995 }
1996
1997 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7>
1998 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)>
1999 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const, Y *y, ...)
2000 {
2001 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)> (y, func);
2002 }
2003
2004 // n = 8
2005
2006 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8>
2007 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)>
2008 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8), Y *y, ...)
2009 {
2010 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)> (y, func);
2011 }
2012
2013 template<class X, class Y, class RetType, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8>
2014 functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)>
2015 bind (RetType (X::*func) (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const, Y *y, ...)
2016 {
2017 return functor<RetType (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)> (y, func);
2018 }
2019
2020 // }}} End auto-generated code
2021
2022 namespace combiner
2023 {
2024 template<class RetType>
2025 class default_combiner
2026 {
2027 // All non-void functors need a combiner.
2028 };
2029
2030 template<>
2031 class default_combiner<bool>
2032 {
2033 typedef std::vector<bool> return_vector;
2034
2035 public:
2036 bool &operator () (return_vector &retvec)
2037 {
2038 static bool retval = true;
2039 return_vector::iterator it = retvec.begin ();
2040 return_vector::iterator et = retvec.end ();
2041
2042 while (it != et)
2043 {
2044 if ((retval = *it) == false)
2045 return retval;
2046 ++it;
2047 }
2048
2049 return retval;
2050 }
2051 };
2052
2053 template<>
2054 struct default_combiner<void>
2055 {
2056 template<class T>
2057 void operator () (std::vector<T> const &retvec)
2058 {
2059 }
2060 };
2061
2062 namespace boolean
2063 {
2064 class strongfalse
2065 {
2066 typedef std::vector<bool> return_vector;
2067
2068 public:
2069 bool &operator () (return_vector &retvec)
2070 {
2071 static bool retval = true;
2072 return_vector::iterator it = retvec.begin ();
2073 return_vector::iterator et = retvec.end ();
2074
2075 while (it != et)
2076 {
2077 if ((retval = *it) == false)
2078 return retval;
2079 ++it;
2080 }
2081
2082 return retval;
2083 }
2084 };
2085
2086 class strongtrue
2087 {
2088 typedef std::vector<bool> return_vector;
2089
2090 public:
2091 bool &operator () (return_vector &retvec)
2092 {
2093 static bool retval = false;
2094 return_vector::iterator it = retvec.begin ();
2095 return_vector::iterator et = retvec.end ();
2096
2097 while (it != et)
2098 {
2099 if ((retval = *it) == true)
2100 return retval;
2101 ++it;
2102 }
2103
2104 return retval;
2105 }
2106 };
2107 }
2108
2109 namespace integer
2110 {
2111 class min
2112 {
2113 typedef std::vector<int> return_vector;
2114
2115 public:
2116 int &operator () (return_vector &retvec)
2117 {
2118 static int retval = INT_MAX;
2119 return_vector::iterator it = retvec.begin ();
2120 return_vector::iterator et = retvec.end ();
2121
2122 while (it != et)
2123 {
2124 int val;
2125 if ((val = *it) < retval)
2126 retval = val;
2127 ++it;
2128 }
2129
2130 return retval;
2131 }
2132 };
2133
2134 class max
2135 {
2136 typedef std::vector<int> return_vector;
2137
2138 public:
2139 int &operator () (return_vector &retvec)
2140 {
2141 static int retval = INT_MIN;
2142 return_vector::iterator it = retvec.begin ();
2143 return_vector::iterator et = retvec.end ();
2144
2145 while (it != et)
2146 {
2147 int val;
2148 if ((val = *it) > retval)
2149 retval = val;
2150 ++it;
2151 }
2152
2153 return retval;
2154 }
2155 };
2156
2157 class avg
2158 {
2159 typedef std::vector<int> return_vector;
2160
2161 public:
2162 int &operator () (return_vector &retvec)
2163 {
2164 static int retval = 0;
2165 return_vector::iterator it = retvec.begin ();
2166 return_vector::iterator et = retvec.end ();
2167
2168 while (it != et)
2169 {
2170 retval += *it;
2171 ++it;
2172 }
2173
2174 retval /= retvec.size ();
2175
2176 return retval;
2177 }
2178 };
2179
2180 class sum
2181 {
2182 typedef std::vector<int> return_vector;
2183
2184 public:
2185 int &operator () (return_vector &retvec)
2186 {
2187 static int retval = 0;
2188 return_vector::iterator it = retvec.begin ();
2189 return_vector::iterator et = retvec.end ();
2190
2191 while (it != et)
2192 {
2193 retval += *it;
2194 ++it;
2195 }
2196
2197 return retval;
2198 }
2199 };
2200 }
2201 }
2202
2203 // Auto-generated code for Callbacks {{{
2204 // n = 0
2205
2206 template<class RetType, class Combiner>
2207 struct invoker0
2208 {
2209 RetType &operator () (std::vector<functor0<RetType> *> callbacks)
2210 {
2211 typename std::vector<functor0<RetType> *>::iterator it = callbacks.begin ();
2212 typename std::vector<functor0<RetType> *>::iterator et = callbacks.end ();
2213 std::vector<RetType> retvec;
2214 while (it != et)
2215 {
2216 retvec.push_back ((*(*it)) ());
2217 ++it;
2218 }
2219 return Combiner () (retvec);
2220 }
2221 };
2222
2223 template<class Combiner>
2224 struct invoker0<void, Combiner>
2225 {
2226 void operator () (std::vector<functor0<void> *> callbacks)
2227 {
2228 std::vector<functor0<void> *>::iterator it = callbacks.begin ();
2229 std::vector<functor0<void> *>::iterator et = callbacks.end ();
2230 while (it != et)
2231 {
2232 (*(*it)) ();
2233 ++it;
2234 }
2235 }
2236 };
2237
2238 template<class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2239 class callback0
2240 {
2241 typedef functor0<RetType> functor_type;
2242 typedef std::vector<functor_type *> list_type;
2243
2244 list_type callbacks;
2245
2246 public:
2247 ~callback0 ()
2248 {
2249 detach_all ();
2250 }
2251
2252 bool contains (RetType (*function) ())
2253 {
2254 typename list_type::iterator it = callbacks.begin ();
2255 typename list_type::iterator et = callbacks.end ();
2256 functor_type functor (function);
2257
2258 while (it != et)
2259 {
2260 if (*(*it) == functor)
2261 return true;
2262 ++it;
2263 }
2264
2265 return false;
2266 }
2267
2268 void attach (RetType (*function) ())
2269 {
2270 if (contains (function))
2271 return;
2272 functor_type *functor = new functor_type (function);
2273 callbacks.push_back (functor);
2274 }
2275
2276 void attach_first (RetType (*function) ())
2277 {
2278 if (contains (function))
2279 return;
2280 functor_type *functor = new functor_type (function);
2281 callbacks.insert (callbacks.begin (), functor);
2282 }
2283
2284 void detach (RetType (*function) ())
2285 {
2286 typename list_type::iterator it = callbacks.begin ();
2287 typename list_type::iterator et = callbacks.end ();
2288 functor_type functor (function);
2289
2290 while (it != et)
2291 {
2292 if (*(*it) == functor)
2293 {
2294 delete *it;
2295 callbacks.erase (it);
2296 return;
2297 }
2298 ++it;
2299 }
2300 }
2301
2302 void detach_all ()
2303 {
2304 typename list_type::iterator it = callbacks.begin ();
2305 typename list_type::iterator et = callbacks.end ();
2306
2307 while (it != et)
2308 {
2309 delete *it;
2310 ++it;
2311 }
2312
2313 callbacks.clear ();
2314 }
2315
2316 RetType invoke ()
2317 {
2318 return invoker0<RetType, Combiner> () (callbacks);
2319 }
2320
2321 RetType operator () ()
2322 {
2323 return invoke ();
2324 }
2325 };
2326
2327 // n = 1
2328
2329 template<class Param1, class RetType, class Combiner>
2330 struct invoker1
2331 {
2332 RetType &operator () (std::vector<functor1<Param1, RetType> *> callbacks, Param1 p1)
2333 {
2334 typename std::vector<functor1<Param1, RetType> *>::iterator it = callbacks.begin ();
2335 typename std::vector<functor1<Param1, RetType> *>::iterator et = callbacks.end ();
2336 std::vector<RetType> retvec;
2337 while (it != et)
2338 {
2339 retvec.push_back ((*(*it)) (p1));
2340 ++it;
2341 }
2342 return Combiner () (retvec);
2343 }
2344 };
2345
2346 template<class Param1, class Combiner>
2347 struct invoker1<Param1, void, Combiner>
2348 {
2349 void operator () (std::vector<functor1<Param1, void> *> callbacks, Param1 p1)
2350 {
2351 typename std::vector<functor1<Param1, void> *>::iterator it = callbacks.begin ();
2352 typename std::vector<functor1<Param1, void> *>::iterator et = callbacks.end ();
2353 while (it != et)
2354 {
2355 (*(*it)) (p1);
2356 ++it;
2357 }
2358 }
2359 };
2360
2361 template<class Param1, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2362 class callback1
2363 {
2364 typedef functor1<Param1, RetType> functor_type;
2365 typedef std::vector<functor_type *> list_type;
2366
2367 list_type callbacks;
2368
2369 public:
2370 ~callback1 ()
2371 {
2372 detach_all ();
2373 }
2374
2375 bool contains (RetType (*function) (Param1))
2376 {
2377 typename list_type::iterator it = callbacks.begin ();
2378 typename list_type::iterator et = callbacks.end ();
2379 functor_type functor (function);
2380
2381 while (it != et)
2382 {
2383 if (*(*it) == functor)
2384 return true;
2385 ++it;
2386 }
2387
2388 return false;
2389 }
2390
2391 void attach (RetType (*function) (Param1))
2392 {
2393 if (contains (function))
2394 return;
2395 functor_type *functor = new functor_type (function);
2396 callbacks.push_back (functor);
2397 }
2398
2399 void attach_first (RetType (*function) (Param1))
2400 {
2401 if (contains (function))
2402 return;
2403 functor_type *functor = new functor_type (function);
2404 callbacks.insert (callbacks.begin (), functor);
2405 }
2406
2407 void detach (RetType (*function) (Param1))
2408 {
2409 typename list_type::iterator it = callbacks.begin ();
2410 typename list_type::iterator et = callbacks.end ();
2411 functor_type functor (function);
2412
2413 while (it != et)
2414 {
2415 if (*(*it) == functor)
2416 {
2417 delete *it;
2418 callbacks.erase (it);
2419 return;
2420 }
2421 ++it;
2422 }
2423 }
2424
2425 void detach_all ()
2426 {
2427 typename list_type::iterator it = callbacks.begin ();
2428 typename list_type::iterator et = callbacks.end ();
2429
2430 while (it != et)
2431 {
2432 delete *it;
2433 ++it;
2434 }
2435
2436 callbacks.clear ();
2437 }
2438
2439 RetType invoke (Param1 p1)
2440 {
2441 return invoker1<Param1, RetType, Combiner> () (callbacks, p1);
2442 }
2443
2444 RetType operator () (Param1 p1)
2445 {
2446 return invoke (p1);
2447 }
2448 };
2449
2450 // n = 2
2451
2452 template<class Param1, class Param2, class RetType, class Combiner>
2453 struct invoker2
2454 {
2455 RetType &operator () (std::vector<functor2<Param1, Param2, RetType> *> callbacks, Param1 p1, Param2 p2)
2456 {
2457 typename std::vector<functor2<Param1, Param2, RetType> *>::iterator it = callbacks.begin ();
2458 typename std::vector<functor2<Param1, Param2, RetType> *>::iterator et = callbacks.end ();
2459 std::vector<RetType> retvec;
2460 while (it != et)
2461 {
2462 retvec.push_back ((*(*it)) (p1, p2));
2463 ++it;
2464 }
2465 return Combiner () (retvec);
2466 }
2467 };
2468
2469 template<class Param1, class Param2, class Combiner>
2470 struct invoker2<Param1, Param2, void, Combiner>
2471 {
2472 void operator () (std::vector<functor2<Param1, Param2, void> *> callbacks, Param1 p1, Param2 p2)
2473 {
2474 typename std::vector<functor2<Param1, Param2, void> *>::iterator it = callbacks.begin ();
2475 typename std::vector<functor2<Param1, Param2, void> *>::iterator et = callbacks.end ();
2476 while (it != et)
2477 {
2478 (*(*it)) (p1, p2);
2479 ++it;
2480 }
2481 }
2482 };
2483
2484 template<class Param1, class Param2, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2485 class callback2
2486 {
2487 typedef functor2<Param1, Param2, RetType> functor_type;
2488 typedef std::vector<functor_type *> list_type;
2489
2490 list_type callbacks;
2491
2492 public:
2493 ~callback2 ()
2494 {
2495 detach_all ();
2496 }
2497
2498 bool contains (RetType (*function) (Param1, Param2))
2499 {
2500 typename list_type::iterator it = callbacks.begin ();
2501 typename list_type::iterator et = callbacks.end ();
2502 functor_type functor (function);
2503
2504 while (it != et)
2505 {
2506 if (*(*it) == functor)
2507 return true;
2508 ++it;
2509 }
2510
2511 return false;
2512 }
2513
2514 void attach (RetType (*function) (Param1, Param2))
2515 {
2516 if (contains (function))
2517 return;
2518 functor_type *functor = new functor_type (function);
2519 callbacks.push_back (functor);
2520 }
2521
2522 void attach_first (RetType (*function) (Param1, Param2))
2523 {
2524 if (contains (function))
2525 return;
2526 functor_type *functor = new functor_type (function);
2527 callbacks.insert (callbacks.begin (), functor);
2528 }
2529
2530 void detach (RetType (*function) (Param1, Param2))
2531 {
2532 typename list_type::iterator it = callbacks.begin ();
2533 typename list_type::iterator et = callbacks.end ();
2534 functor_type functor (function);
2535
2536 while (it != et)
2537 {
2538 if (*(*it) == functor)
2539 {
2540 delete *it;
2541 callbacks.erase (it);
2542 return;
2543 }
2544 ++it;
2545 }
2546 }
2547
2548 void detach_all ()
2549 {
2550 typename list_type::iterator it = callbacks.begin ();
2551 typename list_type::iterator et = callbacks.end ();
2552
2553 while (it != et)
2554 {
2555 delete *it;
2556 ++it;
2557 }
2558
2559 callbacks.clear ();
2560 }
2561
2562 RetType invoke (Param1 p1, Param2 p2)
2563 {
2564 return invoker2<Param1, Param2, RetType, Combiner> () (callbacks, p1, p2);
2565 }
2566
2567 RetType operator () (Param1 p1, Param2 p2)
2568 {
2569 return invoke (p1, p2);
2570 }
2571 };
2572
2573 // n = 3
2574
2575 template<class Param1, class Param2, class Param3, class RetType, class Combiner>
2576 struct invoker3
2577 {
2578 RetType &operator () (std::vector<functor3<Param1, Param2, Param3, RetType> *> callbacks, Param1 p1, Param2 p2, Param3 p3)
2579 {
2580 typename std::vector<functor3<Param1, Param2, Param3, RetType> *>::iterator it = callbacks.begin ();
2581 typename std::vector<functor3<Param1, Param2, Param3, RetType> *>::iterator et = callbacks.end ();
2582 std::vector<RetType> retvec;
2583 while (it != et)
2584 {
2585 retvec.push_back ((*(*it)) (p1, p2, p3));
2586 ++it;
2587 }
2588 return Combiner () (retvec);
2589 }
2590 };
2591
2592 template<class Param1, class Param2, class Param3, class Combiner>
2593 struct invoker3<Param1, Param2, Param3, void, Combiner>
2594 {
2595 void operator () (std::vector<functor3<Param1, Param2, Param3, void> *> callbacks, Param1 p1, Param2 p2, Param3 p3)
2596 {
2597 typename std::vector<functor3<Param1, Param2, Param3, void> *>::iterator it = callbacks.begin ();
2598 typename std::vector<functor3<Param1, Param2, Param3, void> *>::iterator et = callbacks.end ();
2599 while (it != et)
2600 {
2601 (*(*it)) (p1, p2, p3);
2602 ++it;
2603 }
2604 }
2605 };
2606
2607 template<class Param1, class Param2, class Param3, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2608 class callback3
2609 {
2610 typedef functor3<Param1, Param2, Param3, RetType> functor_type;
2611 typedef std::vector<functor_type *> list_type;
2612
2613 list_type callbacks;
2614
2615 public:
2616 ~callback3 ()
2617 {
2618 detach_all ();
2619 }
2620
2621 bool contains (RetType (*function) (Param1, Param2, Param3))
2622 {
2623 typename list_type::iterator it = callbacks.begin ();
2624 typename list_type::iterator et = callbacks.end ();
2625 functor_type functor (function);
2626
2627 while (it != et)
2628 {
2629 if (*(*it) == functor)
2630 return true;
2631 ++it;
2632 }
2633
2634 return false;
2635 }
2636
2637 void attach (RetType (*function) (Param1, Param2, Param3))
2638 {
2639 if (contains (function))
2640 return;
2641 functor_type *functor = new functor_type (function);
2642 callbacks.push_back (functor);
2643 }
2644
2645 void attach_first (RetType (*function) (Param1, Param2, Param3))
2646 {
2647 if (contains (function))
2648 return;
2649 functor_type *functor = new functor_type (function);
2650 callbacks.insert (callbacks.begin (), functor);
2651 }
2652
2653 void detach (RetType (*function) (Param1, Param2, Param3))
2654 {
2655 typename list_type::iterator it = callbacks.begin ();
2656 typename list_type::iterator et = callbacks.end ();
2657 functor_type functor (function);
2658
2659 while (it != et)
2660 {
2661 if (*(*it) == functor)
2662 {
2663 delete *it;
2664 callbacks.erase (it);
2665 return;
2666 }
2667 ++it;
2668 }
2669 }
2670
2671 void detach_all ()
2672 {
2673 typename list_type::iterator it = callbacks.begin ();
2674 typename list_type::iterator et = callbacks.end ();
2675
2676 while (it != et)
2677 {
2678 delete *it;
2679 ++it;
2680 }
2681
2682 callbacks.clear ();
2683 }
2684
2685 RetType invoke (Param1 p1, Param2 p2, Param3 p3)
2686 {
2687 return invoker3<Param1, Param2, Param3, RetType, Combiner> () (callbacks, p1, p2, p3);
2688 }
2689
2690 RetType operator () (Param1 p1, Param2 p2, Param3 p3)
2691 {
2692 return invoke (p1, p2, p3);
2693 }
2694 };
2695
2696 // n = 4
2697
2698 template<class Param1, class Param2, class Param3, class Param4, class RetType, class Combiner>
2699 struct invoker4
2700 {
2701 RetType &operator () (std::vector<functor4<Param1, Param2, Param3, Param4, RetType> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4)
2702 {
2703 typename std::vector<functor4<Param1, Param2, Param3, Param4, RetType> *>::iterator it = callbacks.begin ();
2704 typename std::vector<functor4<Param1, Param2, Param3, Param4, RetType> *>::iterator et = callbacks.end ();
2705 std::vector<RetType> retvec;
2706 while (it != et)
2707 {
2708 retvec.push_back ((*(*it)) (p1, p2, p3, p4));
2709 ++it;
2710 }
2711 return Combiner () (retvec);
2712 }
2713 };
2714
2715 template<class Param1, class Param2, class Param3, class Param4, class Combiner>
2716 struct invoker4<Param1, Param2, Param3, Param4, void, Combiner>
2717 {
2718 void operator () (std::vector<functor4<Param1, Param2, Param3, Param4, void> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4)
2719 {
2720 typename std::vector<functor4<Param1, Param2, Param3, Param4, void> *>::iterator it = callbacks.begin ();
2721 typename std::vector<functor4<Param1, Param2, Param3, Param4, void> *>::iterator et = callbacks.end ();
2722 while (it != et)
2723 {
2724 (*(*it)) (p1, p2, p3, p4);
2725 ++it;
2726 }
2727 }
2728 };
2729
2730 template<class Param1, class Param2, class Param3, class Param4, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2731 class callback4
2732 {
2733 typedef functor4<Param1, Param2, Param3, Param4, RetType> functor_type;
2734 typedef std::vector<functor_type *> list_type;
2735
2736 list_type callbacks;
2737
2738 public:
2739 ~callback4 ()
2740 {
2741 detach_all ();
2742 }
2743
2744 bool contains (RetType (*function) (Param1, Param2, Param3, Param4))
2745 {
2746 typename list_type::iterator it = callbacks.begin ();
2747 typename list_type::iterator et = callbacks.end ();
2748 functor_type functor (function);
2749
2750 while (it != et)
2751 {
2752 if (*(*it) == functor)
2753 return true;
2754 ++it;
2755 }
2756
2757 return false;
2758 }
2759
2760 void attach (RetType (*function) (Param1, Param2, Param3, Param4))
2761 {
2762 if (contains (function))
2763 return;
2764 functor_type *functor = new functor_type (function);
2765 callbacks.push_back (functor);
2766 }
2767
2768 void attach_first (RetType (*function) (Param1, Param2, Param3, Param4))
2769 {
2770 if (contains (function))
2771 return;
2772 functor_type *functor = new functor_type (function);
2773 callbacks.insert (callbacks.begin (), functor);
2774 }
2775
2776 void detach (RetType (*function) (Param1, Param2, Param3, Param4))
2777 {
2778 typename list_type::iterator it = callbacks.begin ();
2779 typename list_type::iterator et = callbacks.end ();
2780 functor_type functor (function);
2781
2782 while (it != et)
2783 {
2784 if (*(*it) == functor)
2785 {
2786 delete *it;
2787 callbacks.erase (it);
2788 return;
2789 }
2790 ++it;
2791 }
2792 }
2793
2794 void detach_all ()
2795 {
2796 typename list_type::iterator it = callbacks.begin ();
2797 typename list_type::iterator et = callbacks.end ();
2798
2799 while (it != et)
2800 {
2801 delete *it;
2802 ++it;
2803 }
2804
2805 callbacks.clear ();
2806 }
2807
2808 RetType invoke (Param1 p1, Param2 p2, Param3 p3, Param4 p4)
2809 {
2810 return invoker4<Param1, Param2, Param3, Param4, RetType, Combiner> () (callbacks, p1, p2, p3, p4);
2811 }
2812
2813 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4)
2814 {
2815 return invoke (p1, p2, p3, p4);
2816 }
2817 };
2818
2819 // n = 5
2820
2821 template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType, class Combiner>
2822 struct invoker5
2823 {
2824 RetType &operator () (std::vector<functor5<Param1, Param2, Param3, Param4, Param5, RetType> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
2825 {
2826 typename std::vector<functor5<Param1, Param2, Param3, Param4, Param5, RetType> *>::iterator it = callbacks.begin ();
2827 typename std::vector<functor5<Param1, Param2, Param3, Param4, Param5, RetType> *>::iterator et = callbacks.end ();
2828 std::vector<RetType> retvec;
2829 while (it != et)
2830 {
2831 retvec.push_back ((*(*it)) (p1, p2, p3, p4, p5));
2832 ++it;
2833 }
2834 return Combiner () (retvec);
2835 }
2836 };
2837
2838 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Combiner>
2839 struct invoker5<Param1, Param2, Param3, Param4, Param5, void, Combiner>
2840 {
2841 void operator () (std::vector<functor5<Param1, Param2, Param3, Param4, Param5, void> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
2842 {
2843 typename std::vector<functor5<Param1, Param2, Param3, Param4, Param5, void> *>::iterator it = callbacks.begin ();
2844 typename std::vector<functor5<Param1, Param2, Param3, Param4, Param5, void> *>::iterator et = callbacks.end ();
2845 while (it != et)
2846 {
2847 (*(*it)) (p1, p2, p3, p4, p5);
2848 ++it;
2849 }
2850 }
2851 };
2852
2853 template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2854 class callback5
2855 {
2856 typedef functor5<Param1, Param2, Param3, Param4, Param5, RetType> functor_type;
2857 typedef std::vector<functor_type *> list_type;
2858
2859 list_type callbacks;
2860
2861 public:
2862 ~callback5 ()
2863 {
2864 detach_all ();
2865 }
2866
2867 bool contains (RetType (*function) (Param1, Param2, Param3, Param4, Param5))
2868 {
2869 typename list_type::iterator it = callbacks.begin ();
2870 typename list_type::iterator et = callbacks.end ();
2871 functor_type functor (function);
2872
2873 while (it != et)
2874 {
2875 if (*(*it) == functor)
2876 return true;
2877 ++it;
2878 }
2879
2880 return false;
2881 }
2882
2883 void attach (RetType (*function) (Param1, Param2, Param3, Param4, Param5))
2884 {
2885 if (contains (function))
2886 return;
2887 functor_type *functor = new functor_type (function);
2888 callbacks.push_back (functor);
2889 }
2890
2891 void attach_first (RetType (*function) (Param1, Param2, Param3, Param4, Param5))
2892 {
2893 if (contains (function))
2894 return;
2895 functor_type *functor = new functor_type (function);
2896 callbacks.insert (callbacks.begin (), functor);
2897 }
2898
2899 void detach (RetType (*function) (Param1, Param2, Param3, Param4, Param5))
2900 {
2901 typename list_type::iterator it = callbacks.begin ();
2902 typename list_type::iterator et = callbacks.end ();
2903 functor_type functor (function);
2904
2905 while (it != et)
2906 {
2907 if (*(*it) == functor)
2908 {
2909 delete *it;
2910 callbacks.erase (it);
2911 return;
2912 }
2913 ++it;
2914 }
2915 }
2916
2917 void detach_all ()
2918 {
2919 typename list_type::iterator it = callbacks.begin ();
2920 typename list_type::iterator et = callbacks.end ();
2921
2922 while (it != et)
2923 {
2924 delete *it;
2925 ++it;
2926 }
2927
2928 callbacks.clear ();
2929 }
2930
2931 RetType invoke (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
2932 {
2933 return invoker5<Param1, Param2, Param3, Param4, Param5, RetType, Combiner> () (callbacks, p1, p2, p3, p4, p5);
2934 }
2935
2936 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)
2937 {
2938 return invoke (p1, p2, p3, p4, p5);
2939 }
2940 };
2941
2942 // n = 6
2943
2944 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType, class Combiner>
2945 struct invoker6
2946 {
2947 RetType &operator () (std::vector<functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)
2948 {
2949 typename std::vector<functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType> *>::iterator it = callbacks.begin ();
2950 typename std::vector<functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType> *>::iterator et = callbacks.end ();
2951 std::vector<RetType> retvec;
2952 while (it != et)
2953 {
2954 retvec.push_back ((*(*it)) (p1, p2, p3, p4, p5, p6));
2955 ++it;
2956 }
2957 return Combiner () (retvec);
2958 }
2959 };
2960
2961 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Combiner>
2962 struct invoker6<Param1, Param2, Param3, Param4, Param5, Param6, void, Combiner>
2963 {
2964 void operator () (std::vector<functor6<Param1, Param2, Param3, Param4, Param5, Param6, void> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)
2965 {
2966 typename std::vector<functor6<Param1, Param2, Param3, Param4, Param5, Param6, void> *>::iterator it = callbacks.begin ();
2967 typename std::vector<functor6<Param1, Param2, Param3, Param4, Param5, Param6, void> *>::iterator et = callbacks.end ();
2968 while (it != et)
2969 {
2970 (*(*it)) (p1, p2, p3, p4, p5, p6);
2971 ++it;
2972 }
2973 }
2974 };
2975
2976 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
2977 class callback6
2978 {
2979 typedef functor6<Param1, Param2, Param3, Param4, Param5, Param6, RetType> functor_type;
2980 typedef std::vector<functor_type *> list_type;
2981
2982 list_type callbacks;
2983
2984 public:
2985 ~callback6 ()
2986 {
2987 detach_all ();
2988 }
2989
2990 bool contains (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6))
2991 {
2992 typename list_type::iterator it = callbacks.begin ();
2993 typename list_type::iterator et = callbacks.end ();
2994 functor_type functor (function);
2995
2996 while (it != et)
2997 {
2998 if (*(*it) == functor)
2999 return true;
3000 ++it;
3001 }
3002
3003 return false;
3004 }
3005
3006 void attach (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6))
3007 {
3008 if (contains (function))
3009 return;
3010 functor_type *functor = new functor_type (function);
3011 callbacks.push_back (functor);
3012 }
3013
3014 void attach_first (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6))
3015 {
3016 if (contains (function))
3017 return;
3018 functor_type *functor = new functor_type (function);
3019 callbacks.insert (callbacks.begin (), functor);
3020 }
3021
3022 void detach (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6))
3023 {
3024 typename list_type::iterator it = callbacks.begin ();
3025 typename list_type::iterator et = callbacks.end ();
3026 functor_type functor (function);
3027
3028 while (it != et)
3029 {
3030 if (*(*it) == functor)
3031 {
3032 delete *it;
3033 callbacks.erase (it);
3034 return;
3035 }
3036 ++it;
3037 }
3038 }
3039
3040 void detach_all ()
3041 {
3042 typename list_type::iterator it = callbacks.begin ();
3043 typename list_type::iterator et = callbacks.end ();
3044
3045 while (it != et)
3046 {
3047 delete *it;
3048 ++it;
3049 }
3050
3051 callbacks.clear ();
3052 }
3053
3054 RetType invoke (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)
3055 {
3056 return invoker6<Param1, Param2, Param3, Param4, Param5, Param6, RetType, Combiner> () (callbacks, p1, p2, p3, p4, p5, p6);
3057 }
3058
3059 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)
3060 {
3061 return invoke (p1, p2, p3, p4, p5, p6);
3062 }
3063 };
3064
3065 // n = 7
3066
3067 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType, class Combiner>
3068 struct invoker7
3069 {
3070 RetType &operator () (std::vector<functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)
3071 {
3072 typename std::vector<functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType> *>::iterator it = callbacks.begin ();
3073 typename std::vector<functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType> *>::iterator et = callbacks.end ();
3074 std::vector<RetType> retvec;
3075 while (it != et)
3076 {
3077 retvec.push_back ((*(*it)) (p1, p2, p3, p4, p5, p6, p7));
3078 ++it;
3079 }
3080 return Combiner () (retvec);
3081 }
3082 };
3083
3084 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Combiner>
3085 struct invoker7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, void, Combiner>
3086 {
3087 void operator () (std::vector<functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, void> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)
3088 {
3089 typename std::vector<functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, void> *>::iterator it = callbacks.begin ();
3090 typename std::vector<functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, void> *>::iterator et = callbacks.end ();
3091 while (it != et)
3092 {
3093 (*(*it)) (p1, p2, p3, p4, p5, p6, p7);
3094 ++it;
3095 }
3096 }
3097 };
3098
3099 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
3100 class callback7
3101 {
3102 typedef functor7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType> functor_type;
3103 typedef std::vector<functor_type *> list_type;
3104
3105 list_type callbacks;
3106
3107 public:
3108 ~callback7 ()
3109 {
3110 detach_all ();
3111 }
3112
3113 bool contains (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7))
3114 {
3115 typename list_type::iterator it = callbacks.begin ();
3116 typename list_type::iterator et = callbacks.end ();
3117 functor_type functor (function);
3118
3119 while (it != et)
3120 {
3121 if (*(*it) == functor)
3122 return true;
3123 ++it;
3124 }
3125
3126 return false;
3127 }
3128
3129 void attach (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7))
3130 {
3131 if (contains (function))
3132 return;
3133 functor_type *functor = new functor_type (function);
3134 callbacks.push_back (functor);
3135 }
3136
3137 void attach_first (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7))
3138 {
3139 if (contains (function))
3140 return;
3141 functor_type *functor = new functor_type (function);
3142 callbacks.insert (callbacks.begin (), functor);
3143 }
3144
3145 void detach (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7))
3146 {
3147 typename list_type::iterator it = callbacks.begin ();
3148 typename list_type::iterator et = callbacks.end ();
3149 functor_type functor (function);
3150
3151 while (it != et)
3152 {
3153 if (*(*it) == functor)
3154 {
3155 delete *it;
3156 callbacks.erase (it);
3157 return;
3158 }
3159 ++it;
3160 }
3161 }
3162
3163 void detach_all ()
3164 {
3165 typename list_type::iterator it = callbacks.begin ();
3166 typename list_type::iterator et = callbacks.end ();
3167
3168 while (it != et)
3169 {
3170 delete *it;
3171 ++it;
3172 }
3173
3174 callbacks.clear ();
3175 }
3176
3177 RetType invoke (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)
3178 {
3179 return invoker7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, RetType, Combiner> () (callbacks, p1, p2, p3, p4, p5, p6, p7);
3180 }
3181
3182 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)
3183 {
3184 return invoke (p1, p2, p3, p4, p5, p6, p7);
3185 }
3186 };
3187
3188 // n = 8
3189
3190 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType, class Combiner>
3191 struct invoker8
3192 {
3193 RetType &operator () (std::vector<functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)
3194 {
3195 typename std::vector<functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType> *>::iterator it = callbacks.begin ();
3196 typename std::vector<functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType> *>::iterator et = callbacks.end ();
3197 std::vector<RetType> retvec;
3198 while (it != et)
3199 {
3200 retvec.push_back ((*(*it)) (p1, p2, p3, p4, p5, p6, p7, p8));
3201 ++it;
3202 }
3203 return Combiner () (retvec);
3204 }
3205 };
3206
3207 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class Combiner>
3208 struct invoker8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, void, Combiner>
3209 {
3210 void operator () (std::vector<functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, void> *> callbacks, Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)
3211 {
3212 typename std::vector<functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, void> *>::iterator it = callbacks.begin ();
3213 typename std::vector<functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, void> *>::iterator et = callbacks.end ();
3214 while (it != et)
3215 {
3216 (*(*it)) (p1, p2, p3, p4, p5, p6, p7, p8);
3217 ++it;
3218 }
3219 }
3220 };
3221
3222 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType = void, class Combiner = combiner::default_combiner<RetType> >
3223 class callback8
3224 {
3225 typedef functor8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType> functor_type;
3226 typedef std::vector<functor_type *> list_type;
3227
3228 list_type callbacks;
3229
3230 public:
3231 ~callback8 ()
3232 {
3233 detach_all ();
3234 }
3235
3236 bool contains (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8))
3237 {
3238 typename list_type::iterator it = callbacks.begin ();
3239 typename list_type::iterator et = callbacks.end ();
3240 functor_type functor (function);
3241
3242 while (it != et)
3243 {
3244 if (*(*it) == functor)
3245 return true;
3246 ++it;
3247 }
3248
3249 return false;
3250 }
3251
3252 void attach (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8))
3253 {
3254 if (contains (function))
3255 return;
3256 functor_type *functor = new functor_type (function);
3257 callbacks.push_back (functor);
3258 }
3259
3260 void attach_first (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8))
3261 {
3262 if (contains (function))
3263 return;
3264 functor_type *functor = new functor_type (function);
3265 callbacks.insert (callbacks.begin (), functor);
3266 }
3267
3268 void detach (RetType (*function) (Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8))
3269 {
3270 typename list_type::iterator it = callbacks.begin ();
3271 typename list_type::iterator et = callbacks.end ();
3272 functor_type functor (function);
3273
3274 while (it != et)
3275 {
3276 if (*(*it) == functor)
3277 {
3278 delete *it;
3279 callbacks.erase (it);
3280 return;
3281 }
3282 ++it;
3283 }
3284 }
3285
3286 void detach_all ()
3287 {
3288 typename list_type::iterator it = callbacks.begin ();
3289 typename list_type::iterator et = callbacks.end ();
3290
3291 while (it != et)
3292 {
3293 delete *it;
3294 ++it;
3295 }
3296
3297 callbacks.clear ();
3298 }
3299
3300 RetType invoke (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)
3301 {
3302 return invoker8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, RetType, Combiner> () (callbacks, p1, p2, p3, p4, p5, p6, p7, p8);
3303 }
3304
3305 RetType operator () (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)
3306 {
3307 return invoke (p1, p2, p3, p4, p5, p6, p7, p8);
3308 }
3309 };
3310
3311 // }}} End auto-generated code
3312 }
3313
3314 #endif
3315
3316 #if TEST_FUNCTOR
3317
3318 static void
3319 static_function (int num, char *str)
3320 {
3321 myprintf ("In static_function. num = %s%d, str = %s\n", num < 10 ? " " : "", num, str);
3322 }
3323
3324 static void
3325 void_function (void)
3326 {
3327 myprintf ("In void_function with no parameters.");
3328 }
3329
3330 #if TEST_CALLBACKS
3331 static bool
3332 bool_function (void)
3333 {
3334 myputs ("In bool_function with no parameters.");
3335 return true;
3336 }
3337
3338 static bool
3339 bool_function2 (void)
3340 {
3341 myputs ("In bool_function2 with no parameters.");
3342 return true;
3343 }
3344
3345 static bool
3346 bool_function_false (void)
3347 {
3348 myputs ("In bool_function_false with no parameters.");
3349 return false;
3350 }
3351
3352 static int
3353 int_function1 (void)
3354 {
3355 int i = 150;
3356 myprintf ("In int_function1. i = %d\n", i);
3357 return i;
3358 }
3359
3360 static int
3361 int_function2 (void)
3362 {
3363 int i = 100;
3364 myprintf ("In int_function2. i = %d\n", i);
3365 return i;
3366 }
3367
3368 static int
3369 int_function3 (void)
3370 {
3371 int i = 50;
3372 myprintf ("In int_function3. i = %d\n", i);
3373 return i;
3374 }
3375
3376 static void
3377 void_function2 (void)
3378 {
3379 myputs ("In void_function2 with no parameters.");
3380 }
3381 #endif
3382
3383 class base
3384 {
3385 protected:
3386 char const * const m_name;
3387
3388 public:
3389 base (char const * const name)
3390 : m_name (name)
3391 {
3392 }
3393
3394 virtual ~base ()
3395 {
3396 }
3397
3398 void member_function (int num, char *str)
3399 {
3400 myprintf ("In member_function in %s. num = %s%d, str = %s\n", m_name, num < 10 ? " " : "", num, str);
3401 }
3402
3403 int int_member_function (int num, char *str)
3404 {
3405 myprintf ("In member_function in %s. num = %s%d, str = %s\n", m_name, num < 10 ? " " : "", num, str);
3406 return -1;
3407 }
3408
3409 void const_member_function (int num, char *str) const
3410 {
3411 myprintf ("In const_member_function in %s. num = %s%d, str = %s\n", m_name, num < 10 ? " " : "", num, str);
3412 }
3413
3414 virtual void virtual_function (int num, char *str)
3415 {
3416 myprintf ("In virtual_function in %s. num = %s%d, str = %s\n", m_name, num < 10 ? " " : "", num, str);
3417 }
3418
3419 static void static_member_function (int num, char *str)
3420 {
3421 myprintf ("In static_member_function. num = %s%d, str = %s\n", num < 10 ? " " : "", num, str);
3422 }
3423 };
3424
3425 class other
3426 {
3427 double rubbish;
3428 public:
3429 virtual ~other () { }
3430 virtual void empty_virtual_function (void) { }
3431 virtual void pure_virtual_function (int num, char *str) = 0;
3432 };
3433
3434 class huge
3435 {
3436 int largemember[400];
3437 };
3438
3439 class derived : public huge, virtual public other, virtual public base
3440 {
3441 double m_somemember[8];
3442
3443 public:
3444 derived ()
3445 : base ("Base of Derived")
3446 {
3447 m_somemember[0] = 1.2345;
3448 }
3449
3450 void derived_function (int num, char *str)
3451 {
3452 myprintf ("In SimpleDerived. num = %s%d, str = %s\n", num < 10 ? " " : "", num, str);
3453 }
3454
3455 virtual void empty_virtual_function2 (int num, char *str)
3456 {
3457 }
3458
3459 virtual void pure_virtual_function (volatile int num, char *str)
3460 {
3461 myprintf ("In Derived pure_virtual_function. num = %s%d, str = %s\n", num < 10 ? " " : "", num, str);
3462 }
3463 };
3464
3465 static void othertest ();
3466
3467 #if BENCHMARK
3468 #include <sys/time.h>
3469
3470 static double
3471 now ()
3472 {
3473 struct timeval tv;
3474
3475 gettimeofday (&tv, 0);
3476 return double (tv.tv_sec) + double (tv.tv_usec) * double (1e-6);
3477 }
3478 #endif
3479
3480 int main (void)
3481 {
3482 #if TIMER
3483 for (int m = 0; m < 100000; m++)
3484 {
3485 #endif
3486 myputs ("-- functor demo --\nA no-parameter functor is declared using functor0\n");
3487
3488 myprintf ("0 :");
3489 functor::functor0<> noparameterfunctor (void_function);
3490
3491 noparameterfunctor ();
3492
3493 myputs ("\n-- Examples using two-parameter functors (int, char *) --\n");
3494
3495 typedef functor::functor2<int, char *> myfunctor;
3496
3497 typedef functor::functor2<int, char *, int> intfunctor;
3498
3499 myfunctor funclist[12];
3500 base a ("Base Class (A)");
3501 base b ("Base Class (B)");
3502 derived d;
3503 derived c;
3504
3505 intfunctor newfunc;
3506 newfunc = functor::make_functor (&a, &base::int_member_function);
3507
3508 funclist[0].bind (&a, &base::member_function);
3509
3510 funclist[1].bind (&static_function);
3511 funclist[2].bind (&base::static_member_function);
3512 funclist[11].bind ( (const base *) &a, &base::const_member_function);
3513 funclist[3].bind (&a, &base::const_member_function);
3514 funclist[4].bind (&b, &base::virtual_function);
3515
3516 funclist[5] = &base::static_member_function;
3517
3518 funclist[6] = functor::make_functor (&d, &base::virtual_function);
3519
3520 funclist[7].bind (&c, &derived::pure_virtual_function);
3521 funclist[8].bind (&c, &other::pure_virtual_function);
3522 funclist[9] = functor::make_functor (&c, &derived::derived_function);
3523
3524 myfunctor dg (&b, &base::virtual_function);
3525
3526 for (int i = 0; i < 12; i++)
3527 {
3528 myprintf (i < 9 ? "%d :" : "%d :", i + 1);
3529 char const *msg = funclist[i] == dg
3530 ? "\033[1;32mFound equal functor\033[0m"
3531 : "\033[0;33mLooking for equal functor\033[0m";
3532 if (!funclist[i])
3533 {
3534 myputs ("Functor is empty");
3535 }
3536 else
3537 funclist[i] (i, const_cast<char *> (msg));
3538 }
3539
3540 #if TEST_CALLBACKS
3541 myputs ("");
3542 functor::callback0<> cb;
3543 functor::callback0<bool> boolcb;
3544 boolcb.attach (bool_function);
3545 boolcb.attach (bool_function_false);
3546 boolcb.attach (bool_function2);
3547 cb.attach (void_function);
3548 cb.attach (void_function2);
3549 cb.attach (void_function);
3550 cb.attach (void_function2);
3551 cb ();
3552 bool success = boolcb ();
3553 myprintf ("bool callback combiner returned %s\n\n", success ? "true" : "false");
3554 cb.detach (void_function);
3555 cb ();
3556
3557 myputs ("\nTrying to calculate the average of a few numbers using callbacks:");
3558 functor::callback0<int, functor::combiner::integer::avg> intavgcb;
3559 intavgcb.attach (int_function1);
3560 intavgcb.attach (int_function2);
3561 intavgcb.attach (int_function3);
3562 myprintf ("Average: %d\n", intavgcb ());
3563
3564 myputs ("\nTrying to calculate the sum of a few numbers using callbacks:");
3565 functor::callback0<int, functor::combiner::integer::sum> intsumcb;
3566 intsumcb.attach (int_function1);
3567 intsumcb.attach (int_function2);
3568 intsumcb.attach (int_function3);
3569 myprintf ("Sum: %d\n", intsumcb ());
3570
3571 myputs ("\nTrying to calculate the max of a few numbers using callbacks:");
3572 functor::callback0<int, functor::combiner::integer::max> intmaxcb;
3573 intmaxcb.attach (int_function1);
3574 intmaxcb.attach (int_function2);
3575 intmaxcb.attach (int_function3);
3576 myprintf ("Max: %d\n", intmaxcb ());
3577
3578 myputs ("\nTrying to calculate the min of a few numbers using callbacks:");
3579 functor::callback0<int, functor::combiner::integer::min> intmincb;
3580 intmincb.attach (int_function1);
3581 intmincb.attach (int_function2);
3582 intmincb.attach (int_function3);
3583 myprintf ("Min: %d\n", intmincb ());
3584 #endif
3585 #if TIMER
3586 }
3587 #endif
3588 myprintf ("\nsizeof (functor0<>) == %ld\n", sizeof (functor::functor0<>));
3589 myprintf ("sizeof (functor1<int>) == %ld\n", sizeof (functor::functor1<int>));
3590
3591 othertest ();
3592
3593 #if BENCHMARK
3594 typedef functor::functor2<int, char *> myfunctor;
3595 derived c2;
3596 myfunctor somefunctor (&c, &derived::pure_virtual_function);
3597
3598 size_t ctr;
3599 double start, end;
3600
3601 start = now ();
3602 ctr = 300000000;
3603 while (ctr--)
3604 somefunctor (2, const_cast<char *> ("moo"));
3605 end = now ();
3606 printf ("%f seconds (functor)\n", end - start);
3607
3608 void (derived::*funcptr) (int, char *) = &derived::pure_virtual_function;
3609 start = now ();
3610 ctr = 300000000;
3611 while (ctr--)
3612 (c2.*funcptr) (2, const_cast<char *> ("moo"));
3613 end = now ();
3614 printf ("%f seconds (function pointer)\n", end - start);
3615
3616 start = now ();
3617 ctr = 300000000;
3618 while (ctr--)
3619 c2.pure_virtual_function (2, const_cast<char *> ("moo"));
3620 end = now ();
3621 printf ("%f seconds (native call)\n", end - start);
3622 #endif
3623
3624 return 0;
3625 }
3626
3627
3628 static bool
3629 allow1 (int num)
3630 {
3631 return num == 3;
3632 }
3633
3634 static bool
3635 allow2 (int num)
3636 {
3637 return num == 3;
3638 }
3639
3640 static bool
3641 allow3 (int num)
3642 {
3643 return num == 3;
3644 }
3645
3646 static bool
3647 deny (int num)
3648 {
3649 return num == 2;
3650 }
3651
3652 static void
3653 othertest ()
3654 {
3655 functor::callback1<int, bool> cb;
3656
3657 myputs ("\nOther test\n");
3658
3659 cb.attach (allow1);
3660 cb.attach (allow2);
3661 cb.attach (allow3);
3662 myputs (cb (3) ? "allowed" : "denied");
3663
3664 cb.attach (deny);
3665 myputs (cb (3) ? "allowed" : "denied");
3666 }
3667
3668 #endif
3669
3670 // Generating this file took 0 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)