OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
functor.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1996 by Borland International, All Rights Reserved
4// Copyright (c) 1998 by Yura Bidus, All Rights Reserved
5//
6/// \file
7/// C++ Functor template implementation
8///
9/// The templates meant for actual end use are:
10///
11/// Void return, N arguments
12/// \code
13/// TFunctorV0
14/// TFunctorV1<P1>
15/// TFunctorV2<P1,P2>
16/// TFunctorV3<P1,P2,P3>
17/// TFunctorV4<P1,P2,P3,P4>
18/// TFunctorV5<P1,P2,P3,P4,P5>
19/// \endcode
20///
21/// Return R, N arguments
22/// \code
23/// TFunctor0<R>
24/// TFunctor1<R,P1>
25/// TFunctor2<R,P1,P2>
26/// TFunctor3<R,P1,P2,P3>
27/// TFunctor4<R,P1,P2,P3,P4>
28/// TFunctor5<R,P1,P2,P3,P4,P5>
29/// \endcode
30///
31/// The Functor() template function is invoked to create a temporary translator
32/// to initialize the actual functor. Currently, the first argument to Functor()
33/// must be a dummy pointer to the desired TFunctor template. When templatized
34/// member functions are available, this arg will be eliminated.
35///
36/// Based on Functors described in
37/// Rich Hickey's 'Callbacks in C++ using template functors' Feb 95 C++ Report
38//
39//------------------------------------------------------------------------------
40
41#if !defined(BDTF_H) && !defined(OWL_FUNCTOR_H)
42#define BDTF_H
43#define OWL_FUNCTOR_H
44
45#include <owl/private/defs.h>
46#if defined(BI_HAS_PRAGMA_ONCE)
47# pragma once
48#endif
49
50#include <ctype.h> // get size_t definition
51
52#if defined(BI_NO_LVAL_CASTS)
53#define THUNKREF(th) th
54#else
55#define THUNKREF(th) const th &
56#endif
57
60
61namespace owl {
62
63#include <owl/preclass.h>
64
65//
66/// Base functor class holds all of the actual data
67//
69 public:
70 operator bool() const {return Func || Callee;}
71 typedef void (TFunctorBase::*TMemberFunc)();
72
74 : Func(nullptr),Callee(nullptr) {}
75 TFunctorBase(const void* c, const void* f, size_t sz);
76
77 union {
78 const void* Func;
79 char MemberFunc[sizeof(TMemberFunc)]; ///< ASSUMES this is always enough space
80 };
81 void* Callee;
82};
83
84//------------------------------------------------------------------------------
85/// Functor with 0 parameters, void return
86
87class TFunctorV0 : public TFunctorBase {
88 public:
90 void operator()() const {
91 Thunk(*this);
92 }
93
94 protected:
95 typedef void (*TThunk)(const TFunctorBase&);
96 TFunctorV0(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
97 : TFunctorBase(c,f,sz), Thunk(t) {}
98
99 private:
100 TThunk Thunk;
101};
102
103template <class Funct>
105 public:
107
108 static void Thunk(const TFunctorBase& ftor)
109 {
110 (Funct(ftor.Func))();
111 }
112};
113
114template <class TCallee, class TMemFunc>
116 public:
119
120 static void Thunk(const TFunctorBase& ftor)
121 {
122 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
123 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
124 (callee->*memFunc)();
125 }
126};
127
128template <class TRT>
129inline TFunctorV0
131{
133}
134
135template <class TCallee, class TRT, class TCallType>
136inline TFunctorV0
138{
139 typedef TRT (TCallType::*TMemFunc)();
141}
142
143template <class TCallee, class TRT, class TCallType>
144inline TFunctorV0
145Functor(TFunctorV0*, const TCallee& c, TRT(TCallType::* const& f)() const)
146{
147 typedef TRT (TCallType::*TMemFunc)() const;
149}
150
151//------------------------------------------------------------------------------
152/// Functor with 0 parameters, return R
153
154template <class R>
155class TFunctor0 : public TFunctorBase{
156 public:
158
159 R operator()() const {
160 return Thunk(*this);
161 }
162
163 protected:
164 typedef R (*TThunk)(const TFunctorBase&);
165 TFunctor0(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
166 : TFunctorBase(c,f,sz), Thunk(t) {}
167
168 private:
169 TThunk Thunk;
170};
171
172template <class R, class Funct>
174 public:
176
177 static R Thunk(const TFunctorBase& ftor)
178 {
179 return (Funct(ftor.Func))();
180 }
181};
182
183template <class R, class TCallee, class TMemFunc>
185 public:
188
189 static R Thunk(const TFunctorBase& ftor)
190 {
191 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
192 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
193 return (callee->*memFunc)();
194 }
195};
196
197template <class R, class TRT>
198inline TFunctor0<R>
203
204template <class R, class TCallee, class TRT, class TCallType>
205inline TFunctor0<R>
207{
208 typedef TRT (TCallType::*TMemFunc)();
210}
211
212template <class R, class TCallee, class TRT, class TCallType>
213inline TFunctor0<R>
214Functor(TFunctor0<R>*, const TCallee& c, TRT(TCallType::* const& f)() const)
215{
216 typedef TRT (TCallType::*TMemFunc)() const;
218}
219
220//------------------------------------------------------------------------------
221/// Functor with 1 parameter, void return
222
223template <class P1>
225 public:
227
228 void operator()(P1 p1) const
229 {
230 Thunk(*this, p1);
231 }
232
233 protected:
234 typedef void (*TThunk)(const TFunctorBase&, P1);
235 TFunctorV1(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
236 : TFunctorBase(c,f,sz), Thunk(t) {}
237
238 private:
239 TThunk Thunk;
240};
241
242template <class P1, class Funct>
244 public:
246
247 static void Thunk(const TFunctorBase& ftor, P1 p1)
248 {
249 (Funct(ftor.Func))(p1);
250 }
251};
252
253template <class P1, class TCallee, class TMemFunc>
255 public:
258
259 static void Thunk(const TFunctorBase& ftor, P1 p1)
260 {
261 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
262 TMemFunc& memFunc(*reinterpret_cast<TMemFunc*>((void*)ftor.MemberFunc));
263 (callee->*memFunc)(p1);
264 }
265};
266
267template <class P1, class TRT, class TP1>
268inline TFunctorV1<P1>
273
274template <class P1, class TCallee, class TRT, class TCallType, class TP1>
275inline TFunctorV1<P1>
277{
278 typedef TRT (TCallType::*TMemFunc)(TP1);
280}
281
282template <class P1, class TCallee, class TRT, class TCallType, class TP1>
283inline TFunctorV1<P1>
284Functor(TFunctorV1<P1>*, const TCallee& c, TRT(TCallType::* const& f)(TP1) const)
285{
286 typedef TRT (TCallType::*TMemFunc)(TP1) const;
288}
289
290//------------------------------------------------------------------------------
291/// Functor with 1 parameter, return R
292
293template <class R, class P1>
294class TFunctor1 : public TFunctorBase{
295 public:
297
299 {
300 return Thunk(*this, p1);
301 }
302
303 protected:
304 typedef R (*TThunk)(const TFunctorBase&, P1);
305 TFunctor1(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
306 : TFunctorBase(c,f,sz), Thunk(t) {}
307
308 private:
309 TThunk Thunk;
310};
311
312template <class R, class P1, class Funct>
313class TFunctionTranslator1 : public TFunctor1<R,P1>{
314 public:
316
317 static R Thunk(const TFunctorBase& ftor, P1 p1)
318 {
319 return (Funct(ftor.Func))(p1);
320 }
321};
322
323template <class R, class P1, class TCallee, class TMemFunc>
324class TMemberTranslator1 : public TFunctor1<R,P1>{
325 public:
328
329 static R Thunk(const TFunctorBase& ftor, P1 p1)
330 {
331 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
332 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
333 return (callee->*memFunc)(p1);
334 }
335};
336
337template <class R, class P1, class TRT, class TP1>
338inline TFunctor1<R,P1>
343
344template <class R, class P1, class TCallee, class TRT, class TCallType, class TP1>
345inline TFunctor1<R,P1>
351
352template <class R, class P1, class TCallee, class TRT, class TCallType, class TP1>
353inline TFunctor1<R,P1>
354Functor(TFunctor1<R,P1>*, const TCallee& c, TRT(TCallType::* const& f)(TP1) const)
355{
356 typedef TRT (TCallType::*TMemFunc)(TP1) const;
358}
359
360//------------------------------------------------------------------------------
361/// Functor with 2 parameters, void return
362
363template <class P1, class P2>
365 public:
367
368 void operator()(P1 p1, P2 p2) const
369 {
370 Thunk(*this, p1, p2);
371 }
372
373 protected:
374 typedef void (*TThunk)(const TFunctorBase&, P1, P2);
375 TFunctorV2(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
376 : TFunctorBase(c,f,sz), Thunk(t) {}
377
378 private:
379 TThunk Thunk;
380};
381
382template <class P1, class P2, class Funct>
383class TFunctionTranslatorV2 : public TFunctorV2<P1,P2>{
384 public:
386
387 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2)
388 {
389 (Funct(ftor.Func))(p1, p2);
390 }
391};
392
393template <class P1, class P2, class TCallee, class TMemFunc>
394class TMemberTranslatorV2 : public TFunctorV2<P1,P2>{
395 public:
398
399 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2)
400 {
401 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
402 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
403 (callee->*memFunc)(p1, p2);
404 }
405};
406
407template <class P1, class P2, class TRT, class TP1, class TP2>
413
414template <class P1, class P2,
415 class TCallee, class TRT, class TCallType,
416 class TP1, class TP2>
423
424template <class P1, class P2,
425 class TCallee, class TRT, class TCallType,
426 class TP1, class TP2>
428Functor(TFunctorV2<P1,P2>*, const TCallee& c, TRT(TCallType::* const& f)(TP1,TP2) const)
429{
430 typedef TRT (TCallType::*TMemFunc)(TP1,TP2) const;
432}
433
434//------------------------------------------------------------------------------
435/// Functor with 2 parameters, return R
436
437template <class R, class P1, class P2>
438class TFunctor2 : public TFunctorBase{
439 public:
441
443 {
444 return Thunk(*this, p1, p2);
445 }
446
447 operator bool() const {return bool();} //JJH exported for COOLEDIT
448
449 protected:
450 typedef R (*TThunk)(const TFunctorBase&, P1, P2);
451 TFunctor2(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
452 : TFunctorBase(c,f,sz), Thunk(t) {}
453
454 private:
455 TThunk Thunk;
456};
457
458template <class R, class P1, class P2, class Funct>
459class TFunctionTranslator2 : public TFunctor2<R,P1,P2>{
460 public:
462
463 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2)
464 {
465 return (Funct(ftor.Func))(p1, p2);
466 }
467};
468
469template <class R, class P1, class P2, class TCallee, class TMemFunc>
470class TMemberTranslator2 : public TFunctor2<R,P1,P2>{
471 public:
474
475 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2)
476 {
477 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
478 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
479 return (callee->*memFunc)(p1, p2);
480 }
481};
482
483template <class R, class P1, class P2, class TRT, class TP1, class TP2>
489
490template <class R, class P1, class P2,
491 class TCallee, class TRT, class TCallType,
492 class TP1, class TP2>
499
500template <class R, class P1, class P2,
501 class TCallee, class TRT, class TCallType,
502 class TP1, class TP2>
504Functor(TFunctor2<R,P1,P2>*, const TCallee& c, TRT(TCallType::* const& f)(TP1,TP2) const)
505{
506 typedef TRT (TCallType::*TMemFunc)(TP1,TP2) const;
508}
509
510//------------------------------------------------------------------------------
511/// Functor with 3 parameters, void return
512
513template <class P1, class P2, class P3>
515 public:
517
518 void operator()(P1 p1, P2 p2, P3 p3) const
519 {
520 Thunk(*this, p1, p2, p3);
521 }
522
523 protected:
524 typedef void (*TThunk)(const TFunctorBase&, P1, P2, P3);
525 TFunctorV3(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
526 : TFunctorBase(c,f,sz), Thunk(t) {}
527
528 private:
529 TThunk Thunk;
530};
531
532template <class P1, class P2, class P3, class Funct>
533class TFunctionTranslatorV3 : public TFunctorV3<P1,P2,P3>{
534 public:
536
537 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3)
538 {
539 (Funct(ftor.Func))(p1, p2, p3);
540 }
541};
542
543template <class P1, class P2, class P3, class TCallee, class TMemFunc>
544class TMemberTranslatorV3 : public TFunctorV3<P1,P2,P3>{
545 public:
548
549 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3)
550 {
551 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
552 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
553 (callee->*memFunc)(p1, p2, p3);
554 }
555};
556
557template <class P1, class P2, class P3,
558 class TRT, class TP1, class TP2, class TP3>
564
565template <class P1, class P2, class P3,
566 class TCallee, class TRT, class CallType,
567 class TP1, class TP2, class TP3>
574
575template <class P1, class P2, class P3,
576 class TCallee, class TRT, class CallType,
577 class TP1, class TP2, class TP3>
580{
581 typedef TRT (CallType::*TMemFunc)(TP1,TP2,TP3) const;
583}
584
585//------------------------------------------------------------------------------
586/// Functor with 3 parameters, return R
587
588template <class R, class P1, class P2, class P3>
589class TFunctor3 : public TFunctorBase{
590 public:
592
594 {
595 return Thunk(*this, p1, p2, p3);
596 }
597
598 protected:
599 typedef R (*TThunk)(const TFunctorBase&, P1, P2, P3);
600 TFunctor3(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
601 : TFunctorBase(c,f,sz), Thunk(t) {}
602
603 private:
604 TThunk Thunk;
605};
606
607template <class R, class P1, class P2, class P3, class Funct>
608class TFunctionTranslator3 : public TFunctor3<R,P1,P2,P3>{
609 public:
611
612 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3)
613 {
614 return (Funct(ftor.Func))(p1, p2, p3);
615 }
616};
617
618template <class R, class P1, class P2, class P3, class TCallee, class TMemFunc>
619class TMemberTranslator3 : public TFunctor3<R,P1,P2,P3>{
620 public:
623
624 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3)
625 {
626 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
627 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
628 return (callee->*memFunc)(p1, p2, p3);
629 }
630};
631
632template <class R, class P1, class P2, class P3,
633 class TRT, class TP1, class TP2, class TP3>
639
640template <class R, class P1, class P2, class P3,
641 class TCallee, class TRT, class CallType,
642 class TP1, class TP2, class TP3>
649
650template <class R, class P1, class P2, class P3,
651 class TCallee, class TRT, class CallType,
652 class TP1, class TP2, class TP3>
659
660//------------------------------------------------------------------------------
661/// Functor with 4 parameters, void return
662
663template <class P1, class P2, class P3, class P4>
665 public:
667
668 void operator()(P1 p1, P2 p2, P3 p3, P4 p4) const
669 {
670 Thunk(*this, p1, p2, p3, p4);
671 }
672
673 protected:
674 typedef void (*TThunk)(const TFunctorBase&, P1, P2, P3, P4);
675 TFunctorV4(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
676 : TFunctorBase(c,f,sz), Thunk(t) {}
677
678 private:
679 TThunk Thunk;
680};
681
682template <class P1, class P2, class P3, class P4, class Funct>
683class TFunctionTranslatorV4 : public TFunctorV4<P1,P2,P3,P4>{
684 public:
686
687 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4)
688 {
689 (Funct(ftor.Func))(p1, p2, p3, p4);
690 }
691};
692
693template <class P1, class P2, class P3, class P4, class TCallee, class TMemFunc>
694class TMemberTranslatorV4 : public TFunctorV4<P1,P2,P3,P4>{
695 public:
698
699 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4)
700 {
701 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
702 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
703 (callee->*memFunc)(p1, p2, p3, p4);
704 }
705};
706
707template <class P1, class P2, class P3, class P4,
708 class TRT, class TP1, class TP2, class TP3, class TP4>
714
715template <class P1, class P2, class P3, class P4, class TCallee,
716 class TRT, class CallType,
717 class TP1, class TP2, class TP3, class TP4>
724
725template <class P1, class P2, class P3, class P4,
726 class TCallee, class TRT, class CallType,
727 class TP1, class TP2, class TP3, class TP4>
734
735//------------------------------------------------------------------------------
736/// Functor with 4 parameters, return R
737
738template <class R, class P1, class P2, class P3, class P4>
739class TFunctor4 : public TFunctorBase{
740 public:
742
744 {
745 return Thunk(*this, p1, p2, p3, p4);
746 }
747
748 protected:
749 typedef R (*TThunk)(const TFunctorBase&, P1, P2, P3, P4);
750 TFunctor4(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
751 : TFunctorBase(c,f,sz), Thunk(t) {}
752
753 private:
754 TThunk Thunk;
755};
756
757template <class R, class P1, class P2, class P3, class P4, class Funct>
758class TFunctionTranslator4 : public TFunctor4<R,P1,P2,P3,P4>{
759 public:
761
762 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4)
763 {
764 return (Funct(ftor.Func))(p1, p2, p3, p4);
765 }
766};
767
768template <class R, class P1, class P2, class P3, class P4, class TCallee, class TMemFunc>
769class TMemberTranslator4 : public TFunctor4<R,P1,P2,P3,P4>{
770 public:
773
774 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4)
775 {
776 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
777 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
778 return (callee->*memFunc)(p1, p2, p3, p4);
779 }
780};
781
782template <class R, class P1, class P2, class P3, class P4,
783 class TRT, class TP1, class TP2, class TP3, class TP4>
789
790template <class R, class P1, class P2, class P3, class P4,
791 class TCallee, class TRT, class CallType,
792 class TP1, class TP2, class TP3, class TP4>
799
800template <class R, class P1, class P2, class P3, class P4,
801 class TCallee, class TRT, class CallType,
802 class TP1, class TP2, class TP3, class TP4>
809
810//------------------------------------------------------------------------------
811/// Functor with 5 parameters, void return
812
813template <class P1, class P2, class P3, class P4, class P5>
815 public:
817
818 void operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
819 {
820 Thunk(*this, p1, p2, p3, p4, p5);
821 }
822
823 protected:
824 typedef void (*TThunk)(const TFunctorBase&, P1, P2, P3, P4, P5);
825 TFunctorV5(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
826 : TFunctorBase(c,f,sz), Thunk(t) {}
827
828 private:
829 TThunk Thunk;
830};
831
832template <class P1, class P2, class P3, class P4, class P5, class Funct>
833class TFunctionTranslatorV5 : public TFunctorV5<P1,P2,P3,P4,P5>{
834 public:
836
837 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
838 {
839 (Funct(ftor.Func))(p1, p2, p3, p4, p5);
840 }
841};
842
843template <class P1, class P2, class P3, class P4, class P5, class TCallee, class TMemFunc>
844class TMemberTranslatorV5 : public TFunctorV5<P1,P2,P3,P4,P5>{
845 public:
848
849 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
850 {
851 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
852 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
853 (callee->*memFunc)(p1, p2, p3, p4, p5);
854 }
855};
856
857template <class P1, class P2, class P3, class P4, class P5,
858 class TRT, class TP1, class TP2, class TP3, class TP4, class TP5>
864
865template <class P1, class P2, class P3, class P4, class P5,
866 class TCallee, class TRT, class CallType,
867 class TP1, class TP2, class TP3, class TP4, class TP5>
874
875template <class P1, class P2, class P3, class P4, class P5,
876 class TCallee, class TRT, class CallType,
877 class TP1, class TP2, class TP3, class TP4, class TP5>
884
885//------------------------------------------------------------------------------
886/// Functor with 5 parameters, return R
887
888template <class R, class P1, class P2, class P3, class P4, class P5>
889class TFunctor5 : public TFunctorBase{
890 public:
892
894 {
895 return Thunk(*this, p1, p2, p3, p4, p5);
896 }
897
898 protected:
899 typedef R (*TThunk)(const TFunctorBase&, P1, P2, P3, P4, P5);
900 TFunctor5(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
901 : TFunctorBase(c,f,sz), Thunk(t) {}
902
903 private:
904 TThunk Thunk;
905};
906
907template <class R, class P1, class P2, class P3, class P4, class P5, class Funct>
908class TFunctionTranslator5 : public TFunctor5<R,P1,P2,P3,P4,P5>{
909 public:
911
912 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
913 {
914 return (Funct(ftor.Func))(p1, p2, p3, p4, p5);
915 }
916};
917
918template <class R, class P1, class P2, class P3, class P4, class P5, class TCallee, class TMemFunc>
919class TMemberTranslator5 : public TFunctor5<R,P1,P2,P3,P4,P5>{
920 public:
923
924 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
925 {
926 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
927 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
928 return (callee->*memFunc)(p1, p2, p3, p4, p5);
929 }
930};
931
932template <class R, class P1, class P2, class P3, class P4, class P5,
933 class TRT, class TP1, class TP2, class TP3, class TP4, class TP5>
939
940template <class R, class P1, class P2, class P3, class P4, class P5,
941 class TCallee, class TRT, class CallType,
942 class TP1, class TP2, class TP3, class TP4, class TP5>
949
950template <class R, class P1, class P2, class P3, class P4, class P5,
951 class TCallee, class TRT, class CallType,
952 class TP1, class TP2, class TP3, class TP4, class TP5>
959
960//------------------------------------------------------------------------------
961/// Functor with 6 parameters, void return
962
963template <class P1, class P2, class P3, class P4, class P5, class P6>
965 public:
967
968 void operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
969 {
970 Thunk(*this, p1, p2, p3, p4, p5, p6);
971 }
972
973 protected:
974 typedef void (*TThunk)(const TFunctorBase&, P1, P2, P3, P4, P5, P6);
975 TFunctorV6(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
976 : TFunctorBase(c,f,sz), Thunk(t) {}
977
978 private:
979 TThunk Thunk;
980};
981
982template <class P1, class P2, class P3, class P4, class P5, class P6, class Funct>
983class TFunctionTranslatorV6 : public TFunctorV6<P1,P2,P3,P4,P5,P6>{
984 public:
986
987 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
988 {
989 (Funct(ftor.Func))(p1, p2, p3, p4, p5, p6);
990 }
991};
992
993template <class P1, class P2, class P3, class P4, class P5, class P6, class TCallee, class TMemFunc>
994class TMemberTranslatorV6 : public TFunctorV6<P1,P2,P3,P4,P5,P6>{
995 public:
998
999 static void Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
1000 {
1001 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
1002 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
1003 (callee->*memFunc)(p1, p2, p3, p4, p5, p6);
1004 }
1005};
1006
1007template <class P1, class P2, class P3, class P4, class P5, class P6,
1008 class TRT, class TP1, class TP2, class TP3, class TP4, class TP5, class TP6>
1014
1015template <class P1, class P2, class P3, class P4, class P5, class P6,
1016 class TCallee, class TRT, class CallType,
1017 class TP1, class TP2, class TP3, class TP4, class TP5, class TP6>
1024
1025template <class P1, class P2, class P3, class P4, class P5, class P6,
1026 class TCallee, class TRT, class CallType,
1027 class TP1, class TP2, class TP3, class TP4, class TP5, class TP6>
1034
1035//------------------------------------------------------------------------------
1036/// Functor with 6 parameters, return R
1037
1038template <class R, class P1, class P2, class P3, class P4, class P5, class P6>
1040 public:
1042
1044 {
1045 return Thunk(*this, p1, p2, p3, p4, p5, p6);
1046 }
1047
1048 protected:
1049 typedef R (*TThunk)(const TFunctorBase&, P1, P2, P3, P4, P5, P6);
1050 TFunctor6(THUNKREF(TThunk) t, const void* c, const void* f, size_t sz)
1051 : TFunctorBase(c,f,sz), Thunk(t) {}
1052
1053 private:
1054 TThunk Thunk;
1055};
1056
1057template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class Funct>
1058class TFunctionTranslator6 : public TFunctor6<R,P1,P2,P3,P4,P5,P6>{
1059 public:
1061
1062 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
1063 {
1064 return (Funct(ftor.Func))(p1, p2, p3, p4, p5, p6);
1065 }
1066};
1067
1068template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class TCallee, class TMemFunc>
1069class TMemberTranslator6 : public TFunctor6<R,P1,P2,P3,P4,P5,P6>{
1070 public:
1073
1074 static R Thunk(const TFunctorBase& ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
1075 {
1076 TCallee* callee = reinterpret_cast<TCallee*>(ftor.Callee);
1077 TMemFunc& memFunc(*(TMemFunc*)(void*)ftor.MemberFunc);
1078 return (callee->*memFunc)(p1, p2, p3, p4, p5, p6);
1079 }
1080};
1081
1082template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
1083 class TRT, class TP1, class TP2, class TP3, class TP4, class TP5, class TP6>
1089
1090template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
1091 class TCallee, class TRT, class CallType,
1092 class TP1, class TP2, class TP3, class TP4, class TP5, class TP6>
1099
1100template <class R, class P1, class P2, class P3, class P4, class P5, class P6,
1101 class TCallee, class TRT, class CallType,
1102 class TP1, class TP2, class TP3, class TP4, class TP5, class TP6>
1109
1110#include <owl/posclass.h>
1111
1112} // OWL namespace
1113
1115
1116#endif // BDTF_H
static R Thunk(const TFunctorBase &ftor)
Definition functor.h:177
TFunctionTranslator0(Funct f)
Definition functor.h:175
TFunctionTranslator1(Funct f)
Definition functor.h:315
static R Thunk(const TFunctorBase &ftor, P1 p1)
Definition functor.h:317
TFunctionTranslator2(Funct f)
Definition functor.h:461
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2)
Definition functor.h:463
TFunctionTranslator3(Funct f)
Definition functor.h:610
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3)
Definition functor.h:612
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4)
Definition functor.h:762
TFunctionTranslator4(Funct f)
Definition functor.h:760
TFunctionTranslator5(Funct f)
Definition functor.h:910
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
Definition functor.h:912
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
Definition functor.h:1062
static void Thunk(const TFunctorBase &ftor)
Definition functor.h:108
static void Thunk(const TFunctorBase &ftor, P1 p1)
Definition functor.h:247
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2)
Definition functor.h:387
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3)
Definition functor.h:537
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4)
Definition functor.h:687
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
Definition functor.h:837
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
Definition functor.h:987
Functor with 0 parameters, return R.
Definition functor.h:155
R operator()() const
Definition functor.h:159
R(* TThunk)(const TFunctorBase &)
Definition functor.h:164
TFunctor0(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:165
Functor with 1 parameter, return R.
Definition functor.h:294
R(* TThunk)(const TFunctorBase &, P1)
Definition functor.h:304
R operator()(P1 p1) const
Definition functor.h:298
TFunctor1(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:305
Functor with 2 parameters, return R.
Definition functor.h:438
R(* TThunk)(const TFunctorBase &, P1, P2)
Definition functor.h:450
TFunctor2(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:451
R operator()(P1 p1, P2 p2) const
Definition functor.h:442
Functor with 3 parameters, return R.
Definition functor.h:589
R(* TThunk)(const TFunctorBase &, P1, P2, P3)
Definition functor.h:599
R operator()(P1 p1, P2 p2, P3 p3) const
Definition functor.h:593
TFunctor3(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:600
Functor with 4 parameters, return R.
Definition functor.h:739
R operator()(P1 p1, P2 p2, P3 p3, P4 p4) const
Definition functor.h:743
R(* TThunk)(const TFunctorBase &, P1, P2, P3, P4)
Definition functor.h:749
TFunctor4(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:750
Functor with 5 parameters, return R.
Definition functor.h:889
R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
Definition functor.h:893
R(* TThunk)(const TFunctorBase &, P1, P2, P3, P4, P5)
Definition functor.h:899
TFunctor5(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:900
Functor with 6 parameters, return R.
Definition functor.h:1039
R(* TThunk)(const TFunctorBase &, P1, P2, P3, P4, P5, P6)
Definition functor.h:1049
R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
Definition functor.h:1043
TFunctor6(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:1050
Base functor class holds all of the actual data.
Definition functor.h:68
const void * Func
Definition functor.h:78
Functor with 0 parameters, void return.
Definition functor.h:87
void operator()() const
Definition functor.h:90
TFunctorV0(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:96
void(* TThunk)(const TFunctorBase &)
Definition functor.h:95
Functor with 1 parameter, void return.
Definition functor.h:224
void(* TThunk)(const TFunctorBase &, P1)
Definition functor.h:234
TFunctorV1(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:235
void operator()(P1 p1) const
Definition functor.h:228
Functor with 2 parameters, void return.
Definition functor.h:364
TFunctorV2(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:375
void operator()(P1 p1, P2 p2) const
Definition functor.h:368
void(* TThunk)(const TFunctorBase &, P1, P2)
Definition functor.h:374
Functor with 3 parameters, void return.
Definition functor.h:514
void operator()(P1 p1, P2 p2, P3 p3) const
Definition functor.h:518
void(* TThunk)(const TFunctorBase &, P1, P2, P3)
Definition functor.h:524
TFunctorV3(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:525
Functor with 4 parameters, void return.
Definition functor.h:664
void operator()(P1 p1, P2 p2, P3 p3, P4 p4) const
Definition functor.h:668
TFunctorV4(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:675
void(* TThunk)(const TFunctorBase &, P1, P2, P3, P4)
Definition functor.h:674
Functor with 5 parameters, void return.
Definition functor.h:814
void(* TThunk)(const TFunctorBase &, P1, P2, P3, P4, P5)
Definition functor.h:824
void operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) const
Definition functor.h:818
TFunctorV5(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:825
Functor with 6 parameters, void return.
Definition functor.h:964
void(* TThunk)(const TFunctorBase &, P1, P2, P3, P4, P5, P6)
Definition functor.h:974
TFunctorV6(THUNKREF(TThunk) t, const void *c, const void *f, size_t sz)
Definition functor.h:975
void operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) const
Definition functor.h:968
static R Thunk(const TFunctorBase &ftor)
Definition functor.h:189
TMemberTranslator0(TCallee &c, const TMemFunc &mf)
Definition functor.h:186
static R Thunk(const TFunctorBase &ftor, P1 p1)
Definition functor.h:329
TMemberTranslator1(TCallee &c, const TMemFunc &mf)
Definition functor.h:326
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2)
Definition functor.h:475
TMemberTranslator2(TCallee &c, const TMemFunc &mf)
Definition functor.h:472
TMemberTranslator3(TCallee &c, const TMemFunc &mf)
Definition functor.h:621
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3)
Definition functor.h:624
TMemberTranslator4(TCallee &c, const TMemFunc &mf)
Definition functor.h:771
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4)
Definition functor.h:774
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
Definition functor.h:924
TMemberTranslator5(TCallee &c, const TMemFunc &mf)
Definition functor.h:921
static R Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
Definition functor.h:1074
TMemberTranslator6(TCallee &c, const TMemFunc &mf)
Definition functor.h:1071
TMemberTranslatorV0(TCallee &c, const TMemFunc &mf)
Definition functor.h:117
static void Thunk(const TFunctorBase &ftor)
Definition functor.h:120
static void Thunk(const TFunctorBase &ftor, P1 p1)
Definition functor.h:259
TMemberTranslatorV1(TCallee &c, const TMemFunc &mf)
Definition functor.h:256
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2)
Definition functor.h:399
TMemberTranslatorV2(TCallee &c, const TMemFunc &mf)
Definition functor.h:396
TMemberTranslatorV3(TCallee &c, const TMemFunc &mf)
Definition functor.h:546
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3)
Definition functor.h:549
TMemberTranslatorV4(TCallee &c, const TMemFunc &mf)
Definition functor.h:696
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4)
Definition functor.h:699
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
Definition functor.h:849
TMemberTranslatorV5(TCallee &c, const TMemFunc &mf)
Definition functor.h:846
TMemberTranslatorV6(TCallee &c, const TMemFunc &mf)
Definition functor.h:996
static void Thunk(const TFunctorBase &ftor, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6)
Definition functor.h:999
#define THUNKREF(th)
Definition functor.h:55
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
TFunctorV0 Functor(TFunctorV0 *, TRT(*f)())
Definition functor.h:130
#define OWL_DISABLE_WARNING_POP
Definition defs.h:156
#define _OWLCLASS
Definition defs.h:338
#define OWL_DISABLE_WARNING_PUSH
Definition defs.h:155
#define OWL_DISABLE_WARNING_OLD_STYLE_CAST
Definition defs.h:161