00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #ifndef FASTDELEGATE_H
00049 #define FASTDELEGATE_H
00050 #if _MSC_VER > 1000
00051 #pragma once
00052 #endif // _MSC_VER > 1000
00053
00054 #include <memory.h>
00055
00057
00058
00060
00061
00062
00063
00064
00065
00066
00067 #define FASTDELEGATE_USESTATICFUNCTIONHACK
00068
00069
00070
00071
00072
00074
00075
00077
00078
00079
00080 #if defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__VECTOR_C) && !defined(__ICL) && !defined(__BORLANDC__)
00081 #define FASTDLGT_ISMSVC
00082
00083 #if (_MSC_VER <1300) // Many workarounds are required for VC6.
00084 #define FASTDLGT_VC6
00085 #pragma warning(disable:4786) // disable this ridiculous warning
00086 #endif
00087
00088 #endif
00089
00090
00091
00092
00093
00094 #if defined(_MSC_VER) && !defined(__MWERKS__)
00095 #define FASTDLGT_MICROSOFT_MFP
00096
00097 #if !defined(__VECTOR_C)
00098
00099 #define FASTDLGT_HASINHERITANCE_KEYWORDS
00100 #endif
00101 #endif
00102
00103
00104 #if defined(FASTDLGT_ISMSVC) && (_MSC_VER >=1310) // VC 7.1
00105 #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
00106 #endif
00107
00108
00109 #if defined (__DMC__) || defined(__GNUC__) || defined(__ICL) || defined(__COMO__)
00110 #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
00111 #endif
00112
00113
00114 #if defined (__MWERKS__)
00115 #define FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
00116 #endif
00117
00118 #ifdef __GNUC__ // Workaround GCC bug #8271
00119
00120 #define FASTDELEGATE_GCC_BUG_8271
00121 #endif
00122
00123
00124
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00137
00138
00140
00141
00142 namespace fastdelegate {
00143 namespace detail {
00144
00145
00146
00147
00148
00149
00150
00151 template <class OutputClass, class InputClass>
00152 inline OutputClass implicit_cast(InputClass input){
00153 return input;
00154 }
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166 template <class OutputClass, class InputClass>
00167 union horrible_union{
00168 OutputClass out;
00169 InputClass in;
00170 };
00171
00172 template <class OutputClass, class InputClass>
00173 inline OutputClass horrible_cast(const InputClass input){
00174 horrible_union<OutputClass, InputClass> u;
00175
00176
00177
00178 typedef int ERROR_CantUseHorrible_cast[sizeof(InputClass)==sizeof(u)
00179 && sizeof(InputClass)==sizeof(OutputClass) ? 1 : -1];
00180 u.in = input;
00181 return u.out;
00182 }
00183
00185
00186
00188
00189
00190
00191 #define FASTDELEGATEDECLARE(CLASSNAME) class CLASSNAME;
00192
00193
00194 #ifdef __MEDIUM__
00195 #undef FASTDELEGATE_USESTATICFUNCTIONHACK
00196 #endif
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 #ifdef FASTDLGT_VC6
00216
00217 typedef const void * DefaultVoid;
00218 #else
00219
00220 typedef void DefaultVoid;
00221 #endif
00222
00223
00224
00225 template <class T>
00226 struct DefaultVoidToVoid { typedef T type; };
00227
00228 template <>
00229 struct DefaultVoidToVoid<DefaultVoid> { typedef void type; };
00230
00231
00232
00233 template <class T>
00234 struct VoidToDefaultVoid { typedef T type; };
00235
00236 template <>
00237 struct VoidToDefaultVoid<void> { typedef DefaultVoid type; };
00238
00239
00240
00242
00243
00244
00245
00247
00248
00249
00250
00251
00252
00253
00254 #ifdef FASTDLGT_MICROSOFT_MFP
00255
00256 #ifdef FASTDLGT_HASINHERITANCE_KEYWORDS
00257
00258
00259
00260 class __single_inheritance GenericClass;
00261 #endif
00262
00263
00264
00265
00266
00267
00268 class GenericClass {};
00269 #else
00270 class GenericClass;
00271 #endif
00272
00273
00274 const int SINGLE_MEMFUNCPTR_SIZE = sizeof(void (GenericClass::*)());
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 template <int N>
00289 struct SimplifyMemFunc {
00290 template <class X, class XFuncType, class GenericMemFuncType>
00291 inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
00292 GenericMemFuncType &bound_func) {
00293
00294
00295 typedef char ERROR_Unsupported_member_function_pointer_on_this_compiler[N-100];
00296 return 0;
00297 }
00298 };
00299
00300
00301
00302 template <>
00303 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE> {
00304 template <class X, class XFuncType, class GenericMemFuncType>
00305 inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
00306 GenericMemFuncType &bound_func) {
00307 #if defined __DMC__
00308
00309
00310
00311 bound_func = horrible_cast<GenericMemFuncType>(function_to_bind);
00312 #else
00313 bound_func = reinterpret_cast<GenericMemFuncType>(function_to_bind);
00314 #endif
00315 return reinterpret_cast<GenericClass *>(pthis);
00316 }
00317 };
00318
00320
00321
00322
00323
00325
00326
00327
00328
00329 #ifdef FASTDLGT_MICROSOFT_MFP
00330
00331
00332
00333
00334
00335
00336
00337 template<>
00338 struct SimplifyMemFunc< SINGLE_MEMFUNCPTR_SIZE + sizeof(int) > {
00339 template <class X, class XFuncType, class GenericMemFuncType>
00340 inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
00341 GenericMemFuncType &bound_func) {
00342
00343
00344 union {
00345 XFuncType func;
00346 struct {
00347 GenericMemFuncType funcaddress;
00348 int delta;
00349 }s;
00350 } u;
00351
00352 typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)? 1 : -1];
00353 u.func = function_to_bind;
00354 bound_func = u.s.funcaddress;
00355 return reinterpret_cast<GenericClass *>(reinterpret_cast<char *>(pthis) + u.s.delta);
00356 }
00357 };
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369 struct MicrosoftVirtualMFP {
00370 void (GenericClass::*codeptr)();
00371 int delta;
00372 int vtable_index;
00373 };
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 struct GenericVirtualClass : virtual public GenericClass
00384 {
00385 typedef GenericVirtualClass * (GenericVirtualClass::*ProbePtrType)();
00386 GenericVirtualClass * GetThis() { return this; }
00387 };
00388
00389
00390 template <>
00391 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 2*sizeof(int) >
00392 {
00393
00394 template <class X, class XFuncType, class GenericMemFuncType>
00395 inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
00396 GenericMemFuncType &bound_func) {
00397 union {
00398 XFuncType func;
00399 GenericClass* (X::*ProbeFunc)();
00400 MicrosoftVirtualMFP s;
00401 } u;
00402 u.func = function_to_bind;
00403 bound_func = reinterpret_cast<GenericMemFuncType>(u.s.codeptr);
00404 union {
00405 GenericVirtualClass::ProbePtrType virtfunc;
00406 MicrosoftVirtualMFP s;
00407 } u2;
00408
00409 typedef int ERROR_CantUsehorrible_cast[sizeof(function_to_bind)==sizeof(u.s)
00410 && sizeof(function_to_bind)==sizeof(u.ProbeFunc)
00411 && sizeof(u2.virtfunc)==sizeof(u2.s) ? 1 : -1];
00412
00413
00414 u2.virtfunc = &GenericVirtualClass::GetThis;
00415 u.s.codeptr = u2.s.codeptr;
00416 return (pthis->*u.ProbeFunc)();
00417 }
00418 };
00419
00420 #if (_MSC_VER <1300)
00421
00422
00423
00424
00425 template <>
00426 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) >
00427 {
00428 template <class X, class XFuncType, class GenericMemFuncType>
00429 inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
00430 GenericMemFuncType &bound_func) {
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455 typedef char ERROR_VC6CompilerBug[-100];
00456 return 0;
00457 }
00458 };
00459
00460
00461 #else
00462
00463
00464
00465
00466
00467 template <>
00468 struct SimplifyMemFunc<SINGLE_MEMFUNCPTR_SIZE + 3*sizeof(int) >
00469 {
00470 template <class X, class XFuncType, class GenericMemFuncType>
00471 inline static GenericClass *Convert(X *pthis, XFuncType function_to_bind,
00472 GenericMemFuncType &bound_func) {
00473
00474
00475 union {
00476 XFuncType func;
00477
00478
00479 struct {
00480 GenericMemFuncType m_funcaddress;
00481 int delta;
00482 int vtordisp;
00483 int vtable_index;
00484 } s;
00485 } u;
00486
00487 typedef int ERROR_CantUsehorrible_cast[sizeof(XFuncType)==sizeof(u.s)? 1 : -1];
00488 u.func = function_to_bind;
00489 bound_func = u.s.funcaddress;
00490 int virtual_delta = 0;
00491 if (u.s.vtable_index) {
00492
00493
00494 const int * vtable = *reinterpret_cast<const int *const*>(
00495 reinterpret_cast<const char *>(pthis) + u.s.vtordisp );
00496
00497
00498 virtual_delta = u.s.vtordisp + *reinterpret_cast<const int *>(
00499 reinterpret_cast<const char *>(vtable) + u.s.vtable_index);
00500 }
00501
00502
00503 return reinterpret_cast<GenericClass *>(
00504 reinterpret_cast<char *>(pthis) + u.s.delta + virtual_delta);
00505 };
00506 };
00507 #endif // MSVC 7 and greater
00508
00509 #endif // MS/Intel hacks
00510
00511 }
00512
00514
00515
00516
00517
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559 class DelegateMemento {
00560 protected:
00561
00562
00563 typedef void (detail::GenericClass::*GenericMemFuncType)();
00564 detail::GenericClass *m_pthis;
00565 GenericMemFuncType m_pFunction;
00566
00567 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00568 typedef void (*GenericFuncPtr)();
00569 GenericFuncPtr m_pStaticFunction;
00570 #endif
00571
00572 public:
00573 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00574 DelegateMemento() : m_pthis(0), m_pFunction(0), m_pStaticFunction(0) {};
00575 void clear() {
00576 m_pthis=0; m_pFunction=0; m_pStaticFunction=0;
00577 }
00578 #else
00579 DelegateMemento() : m_pthis(0), m_pFunction(0) {};
00580 void clear() { m_pthis=0; m_pFunction=0; }
00581 #endif
00582 public:
00583 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00584 inline bool IsEqual (const DelegateMemento &x) const{
00585
00586 if (m_pFunction!=x.m_pFunction) return false;
00587
00588 if (m_pStaticFunction!=x.m_pStaticFunction) return false;
00589 if (m_pStaticFunction!=0) return m_pthis==x.m_pthis;
00590 else return true;
00591 }
00592 #else // Evil Method
00593 inline bool IsEqual (const DelegateMemento &x) const{
00594 return m_pthis==x.m_pthis && m_pFunction==x.m_pFunction;
00595 }
00596 #endif
00597
00598 inline bool IsLess(const DelegateMemento &right) const {
00599
00600 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00601 if (m_pStaticFunction !=0 || right.m_pStaticFunction!=0)
00602 return m_pStaticFunction < right.m_pStaticFunction;
00603 #endif
00604 if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis;
00605
00606
00607
00608 return memcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0;
00609
00610 }
00611
00612
00613
00614 inline bool operator ! () const
00615 { return m_pthis==0 && m_pFunction==0; }
00616 inline bool empty() const
00617 { return m_pthis==0 && m_pFunction==0; }
00618 public:
00619 DelegateMemento & operator = (const DelegateMemento &right) {
00620 SetMementoFrom(right);
00621 return *this;
00622 }
00623 inline bool operator <(const DelegateMemento &right) {
00624 return IsLess(right);
00625 }
00626 inline bool operator >(const DelegateMemento &right) {
00627 return right.IsLess(*this);
00628 }
00629 DelegateMemento (const DelegateMemento &right) :
00630 m_pFunction(right.m_pFunction), m_pthis(right.m_pthis)
00631 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00632 , m_pStaticFunction (right.m_pStaticFunction)
00633 #endif
00634 {}
00635 protected:
00636 void SetMementoFrom(const DelegateMemento &right) {
00637 m_pFunction = right.m_pFunction;
00638 m_pthis = right.m_pthis;
00639 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00640 m_pStaticFunction = right.m_pStaticFunction;
00641 #endif
00642 }
00643 };
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661 namespace detail {
00662
00663 template < class GenericMemFunc, class StaticFuncPtr, class UnvoidStaticFuncPtr>
00664 class ClosurePtr : public DelegateMemento {
00665 public:
00666
00667
00668
00669
00670
00671 template < class X, class XMemFunc >
00672 inline void bindmemfunc(X *pthis, XMemFunc function_to_bind ) {
00673 m_pthis = SimplifyMemFunc< sizeof(function_to_bind) >
00674 ::Convert(pthis, function_to_bind, m_pFunction);
00675 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00676 m_pStaticFunction = 0;
00677 #endif
00678 }
00679
00680
00681
00682
00683 template < class X, class XMemFunc>
00684 inline void bindconstmemfunc(const X *pthis, XMemFunc function_to_bind) {
00685 m_pthis= SimplifyMemFunc< sizeof(function_to_bind) >
00686 ::Convert(const_cast<X*>(pthis), function_to_bind, m_pFunction);
00687 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00688 m_pStaticFunction = 0;
00689 #endif
00690 }
00691 #ifdef FASTDELEGATE_GCC_BUG_8271 // At present, GCC doesn't recognize constness of MFPs in templates
00692 template < class X, class XMemFunc>
00693 inline void bindmemfunc(const X *pthis, XMemFunc function_to_bind) {
00694 bindconstmemfunc(pthis, function_to_bind);
00695 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00696 m_pStaticFunction = 0;
00697 #endif
00698 }
00699 #endif
00700
00701 inline GenericClass *GetClosureThis() const { return m_pthis; }
00702 inline GenericMemFunc GetClosureMemPtr() const { return reinterpret_cast<GenericMemFunc>(m_pFunction); }
00703
00704
00705
00706
00707
00708
00709
00710 #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00711
00712
00713
00714
00715
00716
00717
00718 public:
00719
00720
00721
00722 template< class DerivedClass >
00723 inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &x) {
00724 SetMementoFrom(x);
00725 if (m_pStaticFunction!=0) {
00726
00727 m_pthis=reinterpret_cast<GenericClass *>(pParent);
00728 }
00729 }
00730
00731
00732
00733 template < class DerivedClass, class ParentInvokerSig >
00734 inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker,
00735 StaticFuncPtr function_to_bind ) {
00736 if (function_to_bind==0) {
00737 m_pFunction=0;
00738 } else {
00739 bindmemfunc(pParent, static_function_invoker);
00740 }
00741 m_pStaticFunction=reinterpret_cast<GenericFuncPtr>(function_to_bind);
00742 }
00743 inline UnvoidStaticFuncPtr GetStaticFunction() const {
00744 return reinterpret_cast<UnvoidStaticFuncPtr>(m_pStaticFunction);
00745 }
00746 #else
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758 template< class DerivedClass >
00759 inline void CopyFrom (DerivedClass *pParent, const DelegateMemento &right) {
00760 SetMementoFrom(right);
00761 }
00762
00763
00764
00765
00766 template < class DerivedClass, class ParentInvokerSig>
00767 inline void bindstaticfunc(DerivedClass *pParent, ParentInvokerSig static_function_invoker,
00768 StaticFuncPtr function_to_bind) {
00769 if (function_to_bind==0) {
00770 m_pFunction=0;
00771 } else {
00772
00773
00774 bindmemfunc(pParent, static_function_invoker);
00775 }
00776
00777
00778
00779
00780
00781 typedef int ERROR_CantUseEvilMethod[sizeof(GenericClass *)==sizeof(function_to_bind) ? 1 : -1];
00782 m_pthis = horrible_cast<GenericClass *>(function_to_bind);
00783
00784
00785
00786
00787 }
00788
00789
00790
00791
00792 inline UnvoidStaticFuncPtr GetStaticFunction() const {
00793
00794
00795
00796 typedef int ERROR_CantUseEvilMethod[sizeof(UnvoidStaticFuncPtr)==sizeof(this) ? 1 : -1];
00797 return horrible_cast<UnvoidStaticFuncPtr>(this);
00798 }
00799 #endif // !defined(FASTDELEGATE_USESTATICFUNCTIONHACK)
00800
00801
00802 inline bool IsEqualToStaticFuncPtr(StaticFuncPtr funcptr){
00803 if (funcptr==0) return empty();
00804
00805
00806 else return funcptr==reinterpret_cast<StaticFuncPtr>(GetStaticFunction());
00807 }
00808 };
00809
00810
00811 }
00812
00814
00815
00816
00817
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853 template<class RetType=detail::DefaultVoid>
00854 class FastDelegate0 {
00855 private:
00856 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
00857 typedef DesiredRetType (*StaticFunctionPtr)();
00858 typedef RetType (*UnvoidStaticFunctionPtr)();
00859 typedef RetType (detail::GenericClass::*GenericMemFn)();
00860 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
00861 ClosureType m_Closure;
00862 public:
00863
00864 typedef FastDelegate0 type;
00865
00866
00867 FastDelegate0() { clear(); }
00868 FastDelegate0(const FastDelegate0 &x) {
00869 m_Closure.CopyFrom(this, x.m_Closure); }
00870 void operator = (const FastDelegate0 &x) {
00871 m_Closure.CopyFrom(this, x.m_Closure); }
00872 bool operator ==(const FastDelegate0 &x) const {
00873 return m_Closure.IsEqual(x.m_Closure); }
00874 bool operator !=(const FastDelegate0 &x) const {
00875 return !m_Closure.IsEqual(x.m_Closure); }
00876 bool operator <(const FastDelegate0 &x) const {
00877 return m_Closure.IsLess(x.m_Closure); }
00878 bool operator >(const FastDelegate0 &x) const {
00879 return x.m_Closure.IsLess(m_Closure); }
00880
00881 template < class X, class Y >
00882 FastDelegate0(Y *pthis, DesiredRetType (X::* function_to_bind)() ) {
00883 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
00884 template < class X, class Y >
00885 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)()) {
00886 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
00887
00888 template < class X, class Y >
00889 FastDelegate0(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) {
00890 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
00891 template < class X, class Y >
00892 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)() const) {
00893 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
00894
00895
00896 FastDelegate0(DesiredRetType (*function_to_bind)() ) {
00897 bind(function_to_bind); }
00898
00899 void operator = (DesiredRetType (*function_to_bind)() ) {
00900 bind(function_to_bind); }
00901 inline void bind(DesiredRetType (*function_to_bind)()) {
00902 m_Closure.bindstaticfunc(this, &FastDelegate0::InvokeStaticFunction,
00903 function_to_bind); }
00904
00905 RetType operator() () const {
00906 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(); }
00907
00908 private:
00909 typedef struct SafeBoolStruct {
00910 int a_data_pointer_to_this_is_0_on_buggy_compilers;
00911 StaticFunctionPtr m_nonzero;
00912 } UselessTypedef;
00913 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
00914 public:
00915 operator unspecified_bool_type() const {
00916 return empty()? 0: &SafeBoolStruct::m_nonzero;
00917 }
00918
00919 inline bool operator==(StaticFunctionPtr funcptr) {
00920 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
00921 inline bool operator!=(StaticFunctionPtr funcptr) {
00922 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
00923 inline bool operator ! () const {
00924 return !m_Closure; }
00925 inline bool empty() const {
00926 return !m_Closure; }
00927 void clear() { m_Closure.clear();}
00928
00929 const DelegateMemento & GetMemento() { return m_Closure; }
00930 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
00931
00932 private:
00933 RetType InvokeStaticFunction() const {
00934 return (*(m_Closure.GetStaticFunction()))(); }
00935 };
00936
00937
00938 template<class Param1, class RetType=detail::DefaultVoid>
00939 class FastDelegate1 {
00940 private:
00941 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
00942 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1);
00943 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1);
00944 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1);
00945 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
00946 ClosureType m_Closure;
00947 public:
00948
00949 typedef FastDelegate1 type;
00950
00951
00952 FastDelegate1() { clear(); }
00953 FastDelegate1(const FastDelegate1 &x) {
00954 m_Closure.CopyFrom(this, x.m_Closure); }
00955 void operator = (const FastDelegate1 &x) {
00956 m_Closure.CopyFrom(this, x.m_Closure); }
00957 bool operator ==(const FastDelegate1 &x) const {
00958 return m_Closure.IsEqual(x.m_Closure); }
00959 bool operator !=(const FastDelegate1 &x) const {
00960 return !m_Closure.IsEqual(x.m_Closure); }
00961 bool operator <(const FastDelegate1 &x) const {
00962 return m_Closure.IsLess(x.m_Closure); }
00963 bool operator >(const FastDelegate1 &x) const {
00964 return x.m_Closure.IsLess(m_Closure); }
00965
00966 template < class X, class Y >
00967 FastDelegate1(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) ) {
00968 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
00969 template < class X, class Y >
00970 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1)) {
00971 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
00972
00973 template < class X, class Y >
00974 FastDelegate1(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) {
00975 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
00976 template < class X, class Y >
00977 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1) const) {
00978 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
00979
00980
00981 FastDelegate1(DesiredRetType (*function_to_bind)(Param1 p1) ) {
00982 bind(function_to_bind); }
00983
00984 void operator = (DesiredRetType (*function_to_bind)(Param1 p1) ) {
00985 bind(function_to_bind); }
00986 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1)) {
00987 m_Closure.bindstaticfunc(this, &FastDelegate1::InvokeStaticFunction,
00988 function_to_bind); }
00989
00990 RetType operator() (Param1 p1) const {
00991 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1); }
00992
00993 private:
00994 typedef struct SafeBoolStruct {
00995 int a_data_pointer_to_this_is_0_on_buggy_compilers;
00996 StaticFunctionPtr m_nonzero;
00997 } UselessTypedef;
00998 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
00999 public:
01000 operator unspecified_bool_type() const {
01001 return empty()? 0: &SafeBoolStruct::m_nonzero;
01002 }
01003
01004 inline bool operator==(StaticFunctionPtr funcptr) {
01005 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01006 inline bool operator!=(StaticFunctionPtr funcptr) {
01007 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01008 inline bool operator ! () const {
01009 return !m_Closure; }
01010 inline bool empty() const {
01011 return !m_Closure; }
01012 void clear() { m_Closure.clear();}
01013
01014 const DelegateMemento & GetMemento() { return m_Closure; }
01015 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01016
01017 private:
01018 RetType InvokeStaticFunction(Param1 p1) const {
01019 return (*(m_Closure.GetStaticFunction()))(p1); }
01020 };
01021
01022
01023 template<class Param1, class Param2, class RetType=detail::DefaultVoid>
01024 class FastDelegate2 {
01025 private:
01026 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01027 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2);
01028 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2);
01029 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2);
01030 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01031 ClosureType m_Closure;
01032 public:
01033
01034 typedef FastDelegate2 type;
01035
01036
01037 FastDelegate2() { clear(); }
01038 FastDelegate2(const FastDelegate2 &x) {
01039 m_Closure.CopyFrom(this, x.m_Closure); }
01040 void operator = (const FastDelegate2 &x) {
01041 m_Closure.CopyFrom(this, x.m_Closure); }
01042 bool operator ==(const FastDelegate2 &x) const {
01043 return m_Closure.IsEqual(x.m_Closure); }
01044 bool operator !=(const FastDelegate2 &x) const {
01045 return !m_Closure.IsEqual(x.m_Closure); }
01046 bool operator <(const FastDelegate2 &x) const {
01047 return m_Closure.IsLess(x.m_Closure); }
01048 bool operator >(const FastDelegate2 &x) const {
01049 return x.m_Closure.IsLess(m_Closure); }
01050
01051 template < class X, class Y >
01052 FastDelegate2(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) ) {
01053 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01054 template < class X, class Y >
01055 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2)) {
01056 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01057
01058 template < class X, class Y >
01059 FastDelegate2(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) {
01060 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01061 template < class X, class Y >
01062 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2) const) {
01063 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01064
01065
01066 FastDelegate2(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) {
01067 bind(function_to_bind); }
01068
01069 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2) ) {
01070 bind(function_to_bind); }
01071 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2)) {
01072 m_Closure.bindstaticfunc(this, &FastDelegate2::InvokeStaticFunction,
01073 function_to_bind); }
01074
01075 RetType operator() (Param1 p1, Param2 p2) const {
01076 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2); }
01077
01078 private:
01079 typedef struct SafeBoolStruct {
01080 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01081 StaticFunctionPtr m_nonzero;
01082 } UselessTypedef;
01083 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01084 public:
01085 operator unspecified_bool_type() const {
01086 return empty()? 0: &SafeBoolStruct::m_nonzero;
01087 }
01088
01089 inline bool operator==(StaticFunctionPtr funcptr) {
01090 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01091 inline bool operator!=(StaticFunctionPtr funcptr) {
01092 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01093 inline bool operator ! () const {
01094 return !m_Closure; }
01095 inline bool empty() const {
01096 return !m_Closure; }
01097 void clear() { m_Closure.clear();}
01098
01099 const DelegateMemento & GetMemento() { return m_Closure; }
01100 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01101
01102 private:
01103 RetType InvokeStaticFunction(Param1 p1, Param2 p2) const {
01104 return (*(m_Closure.GetStaticFunction()))(p1, p2); }
01105 };
01106
01107
01108 template<class Param1, class Param2, class Param3, class RetType=detail::DefaultVoid>
01109 class FastDelegate3 {
01110 private:
01111 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01112 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3);
01113 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3);
01114 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3);
01115 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01116 ClosureType m_Closure;
01117 public:
01118
01119 typedef FastDelegate3 type;
01120
01121
01122 FastDelegate3() { clear(); }
01123 FastDelegate3(const FastDelegate3 &x) {
01124 m_Closure.CopyFrom(this, x.m_Closure); }
01125 void operator = (const FastDelegate3 &x) {
01126 m_Closure.CopyFrom(this, x.m_Closure); }
01127 bool operator ==(const FastDelegate3 &x) const {
01128 return m_Closure.IsEqual(x.m_Closure); }
01129 bool operator !=(const FastDelegate3 &x) const {
01130 return !m_Closure.IsEqual(x.m_Closure); }
01131 bool operator <(const FastDelegate3 &x) const {
01132 return m_Closure.IsLess(x.m_Closure); }
01133 bool operator >(const FastDelegate3 &x) const {
01134 return x.m_Closure.IsLess(m_Closure); }
01135
01136 template < class X, class Y >
01137 FastDelegate3(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
01138 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01139 template < class X, class Y >
01140 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) {
01141 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01142
01143 template < class X, class Y >
01144 FastDelegate3(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) {
01145 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01146 template < class X, class Y >
01147 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3) const) {
01148 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01149
01150
01151 FastDelegate3(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
01152 bind(function_to_bind); }
01153
01154 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3) ) {
01155 bind(function_to_bind); }
01156 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3)) {
01157 m_Closure.bindstaticfunc(this, &FastDelegate3::InvokeStaticFunction,
01158 function_to_bind); }
01159
01160 RetType operator() (Param1 p1, Param2 p2, Param3 p3) const {
01161 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3); }
01162
01163 private:
01164 typedef struct SafeBoolStruct {
01165 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01166 StaticFunctionPtr m_nonzero;
01167 } UselessTypedef;
01168 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01169 public:
01170 operator unspecified_bool_type() const {
01171 return empty()? 0: &SafeBoolStruct::m_nonzero;
01172 }
01173
01174 inline bool operator==(StaticFunctionPtr funcptr) {
01175 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01176 inline bool operator!=(StaticFunctionPtr funcptr) {
01177 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01178 inline bool operator ! () const {
01179 return !m_Closure; }
01180 inline bool empty() const {
01181 return !m_Closure; }
01182 void clear() { m_Closure.clear();}
01183
01184 const DelegateMemento & GetMemento() { return m_Closure; }
01185 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01186
01187 private:
01188 RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3) const {
01189 return (*(m_Closure.GetStaticFunction()))(p1, p2, p3); }
01190 };
01191
01192
01193 template<class Param1, class Param2, class Param3, class Param4, class RetType=detail::DefaultVoid>
01194 class FastDelegate4 {
01195 private:
01196 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01197 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
01198 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
01199 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4);
01200 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01201 ClosureType m_Closure;
01202 public:
01203
01204 typedef FastDelegate4 type;
01205
01206
01207 FastDelegate4() { clear(); }
01208 FastDelegate4(const FastDelegate4 &x) {
01209 m_Closure.CopyFrom(this, x.m_Closure); }
01210 void operator = (const FastDelegate4 &x) {
01211 m_Closure.CopyFrom(this, x.m_Closure); }
01212 bool operator ==(const FastDelegate4 &x) const {
01213 return m_Closure.IsEqual(x.m_Closure); }
01214 bool operator !=(const FastDelegate4 &x) const {
01215 return !m_Closure.IsEqual(x.m_Closure); }
01216 bool operator <(const FastDelegate4 &x) const {
01217 return m_Closure.IsLess(x.m_Closure); }
01218 bool operator >(const FastDelegate4 &x) const {
01219 return x.m_Closure.IsLess(m_Closure); }
01220
01221 template < class X, class Y >
01222 FastDelegate4(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
01223 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01224 template < class X, class Y >
01225 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
01226 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01227
01228 template < class X, class Y >
01229 FastDelegate4(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
01230 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01231 template < class X, class Y >
01232 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
01233 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01234
01235
01236 FastDelegate4(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
01237 bind(function_to_bind); }
01238
01239 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) ) {
01240 bind(function_to_bind); }
01241 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
01242 m_Closure.bindstaticfunc(this, &FastDelegate4::InvokeStaticFunction,
01243 function_to_bind); }
01244
01245 RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4) const {
01246 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4); }
01247
01248 private:
01249 typedef struct SafeBoolStruct {
01250 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01251 StaticFunctionPtr m_nonzero;
01252 } UselessTypedef;
01253 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01254 public:
01255 operator unspecified_bool_type() const {
01256 return empty()? 0: &SafeBoolStruct::m_nonzero;
01257 }
01258
01259 inline bool operator==(StaticFunctionPtr funcptr) {
01260 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01261 inline bool operator!=(StaticFunctionPtr funcptr) {
01262 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01263 inline bool operator ! () const {
01264 return !m_Closure; }
01265 inline bool empty() const {
01266 return !m_Closure; }
01267 void clear() { m_Closure.clear();}
01268
01269 const DelegateMemento & GetMemento() { return m_Closure; }
01270 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01271
01272 private:
01273 RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const {
01274 return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4); }
01275 };
01276
01277
01278 template<class Param1, class Param2, class Param3, class Param4, class Param5, class RetType=detail::DefaultVoid>
01279 class FastDelegate5 {
01280 private:
01281 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01282 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
01283 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
01284 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5);
01285 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01286 ClosureType m_Closure;
01287 public:
01288
01289 typedef FastDelegate5 type;
01290
01291
01292 FastDelegate5() { clear(); }
01293 FastDelegate5(const FastDelegate5 &x) {
01294 m_Closure.CopyFrom(this, x.m_Closure); }
01295 void operator = (const FastDelegate5 &x) {
01296 m_Closure.CopyFrom(this, x.m_Closure); }
01297 bool operator ==(const FastDelegate5 &x) const {
01298 return m_Closure.IsEqual(x.m_Closure); }
01299 bool operator !=(const FastDelegate5 &x) const {
01300 return !m_Closure.IsEqual(x.m_Closure); }
01301 bool operator <(const FastDelegate5 &x) const {
01302 return m_Closure.IsLess(x.m_Closure); }
01303 bool operator >(const FastDelegate5 &x) const {
01304 return x.m_Closure.IsLess(m_Closure); }
01305
01306 template < class X, class Y >
01307 FastDelegate5(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
01308 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01309 template < class X, class Y >
01310 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
01311 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01312
01313 template < class X, class Y >
01314 FastDelegate5(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
01315 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01316 template < class X, class Y >
01317 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
01318 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01319
01320
01321 FastDelegate5(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
01322 bind(function_to_bind); }
01323
01324 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) ) {
01325 bind(function_to_bind); }
01326 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
01327 m_Closure.bindstaticfunc(this, &FastDelegate5::InvokeStaticFunction,
01328 function_to_bind); }
01329
01330 RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const {
01331 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5); }
01332
01333 private:
01334 typedef struct SafeBoolStruct {
01335 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01336 StaticFunctionPtr m_nonzero;
01337 } UselessTypedef;
01338 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01339 public:
01340 operator unspecified_bool_type() const {
01341 return empty()? 0: &SafeBoolStruct::m_nonzero;
01342 }
01343
01344 inline bool operator==(StaticFunctionPtr funcptr) {
01345 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01346 inline bool operator!=(StaticFunctionPtr funcptr) {
01347 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01348 inline bool operator ! () const {
01349 return !m_Closure; }
01350 inline bool empty() const {
01351 return !m_Closure; }
01352 void clear() { m_Closure.clear();}
01353
01354 const DelegateMemento & GetMemento() { return m_Closure; }
01355 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01356
01357 private:
01358 RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const {
01359 return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5); }
01360 };
01361
01362
01363 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType=detail::DefaultVoid>
01364 class FastDelegate6 {
01365 private:
01366 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01367 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
01368 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
01369 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6);
01370 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01371 ClosureType m_Closure;
01372 public:
01373
01374 typedef FastDelegate6 type;
01375
01376
01377 FastDelegate6() { clear(); }
01378 FastDelegate6(const FastDelegate6 &x) {
01379 m_Closure.CopyFrom(this, x.m_Closure); }
01380 void operator = (const FastDelegate6 &x) {
01381 m_Closure.CopyFrom(this, x.m_Closure); }
01382 bool operator ==(const FastDelegate6 &x) const {
01383 return m_Closure.IsEqual(x.m_Closure); }
01384 bool operator !=(const FastDelegate6 &x) const {
01385 return !m_Closure.IsEqual(x.m_Closure); }
01386 bool operator <(const FastDelegate6 &x) const {
01387 return m_Closure.IsLess(x.m_Closure); }
01388 bool operator >(const FastDelegate6 &x) const {
01389 return x.m_Closure.IsLess(m_Closure); }
01390
01391 template < class X, class Y >
01392 FastDelegate6(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
01393 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01394 template < class X, class Y >
01395 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
01396 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01397
01398 template < class X, class Y >
01399 FastDelegate6(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
01400 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01401 template < class X, class Y >
01402 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
01403 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01404
01405
01406 FastDelegate6(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
01407 bind(function_to_bind); }
01408
01409 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) ) {
01410 bind(function_to_bind); }
01411 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
01412 m_Closure.bindstaticfunc(this, &FastDelegate6::InvokeStaticFunction,
01413 function_to_bind); }
01414
01415 RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const {
01416 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6); }
01417
01418 private:
01419 typedef struct SafeBoolStruct {
01420 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01421 StaticFunctionPtr m_nonzero;
01422 } UselessTypedef;
01423 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01424 public:
01425 operator unspecified_bool_type() const {
01426 return empty()? 0: &SafeBoolStruct::m_nonzero;
01427 }
01428
01429 inline bool operator==(StaticFunctionPtr funcptr) {
01430 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01431 inline bool operator!=(StaticFunctionPtr funcptr) {
01432 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01433 inline bool operator ! () const {
01434 return !m_Closure; }
01435 inline bool empty() const {
01436 return !m_Closure; }
01437 void clear() { m_Closure.clear();}
01438
01439 const DelegateMemento & GetMemento() { return m_Closure; }
01440 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01441
01442 private:
01443 RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const {
01444 return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6); }
01445 };
01446
01447
01448 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType=detail::DefaultVoid>
01449 class FastDelegate7 {
01450 private:
01451 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01452 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
01453 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
01454 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7);
01455 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01456 ClosureType m_Closure;
01457 public:
01458
01459 typedef FastDelegate7 type;
01460
01461
01462 FastDelegate7() { clear(); }
01463 FastDelegate7(const FastDelegate7 &x) {
01464 m_Closure.CopyFrom(this, x.m_Closure); }
01465 void operator = (const FastDelegate7 &x) {
01466 m_Closure.CopyFrom(this, x.m_Closure); }
01467 bool operator ==(const FastDelegate7 &x) const {
01468 return m_Closure.IsEqual(x.m_Closure); }
01469 bool operator !=(const FastDelegate7 &x) const {
01470 return !m_Closure.IsEqual(x.m_Closure); }
01471 bool operator <(const FastDelegate7 &x) const {
01472 return m_Closure.IsLess(x.m_Closure); }
01473 bool operator >(const FastDelegate7 &x) const {
01474 return x.m_Closure.IsLess(m_Closure); }
01475
01476 template < class X, class Y >
01477 FastDelegate7(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
01478 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01479 template < class X, class Y >
01480 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
01481 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01482
01483 template < class X, class Y >
01484 FastDelegate7(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
01485 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01486 template < class X, class Y >
01487 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
01488 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01489
01490
01491 FastDelegate7(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
01492 bind(function_to_bind); }
01493
01494 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) ) {
01495 bind(function_to_bind); }
01496 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
01497 m_Closure.bindstaticfunc(this, &FastDelegate7::InvokeStaticFunction,
01498 function_to_bind); }
01499
01500 RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const {
01501 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7); }
01502
01503 private:
01504 typedef struct SafeBoolStruct {
01505 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01506 StaticFunctionPtr m_nonzero;
01507 } UselessTypedef;
01508 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01509 public:
01510 operator unspecified_bool_type() const {
01511 return empty()? 0: &SafeBoolStruct::m_nonzero;
01512 }
01513
01514 inline bool operator==(StaticFunctionPtr funcptr) {
01515 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01516 inline bool operator!=(StaticFunctionPtr funcptr) {
01517 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01518 inline bool operator ! () const {
01519 return !m_Closure; }
01520 inline bool empty() const {
01521 return !m_Closure; }
01522 void clear() { m_Closure.clear();}
01523
01524 const DelegateMemento & GetMemento() { return m_Closure; }
01525 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01526
01527 private:
01528 RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const {
01529 return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7); }
01530 };
01531
01532
01533 template<class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType=detail::DefaultVoid>
01534 class FastDelegate8 {
01535 private:
01536 typedef typename detail::DefaultVoidToVoid<RetType>::type DesiredRetType;
01537 typedef DesiredRetType (*StaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
01538 typedef RetType (*UnvoidStaticFunctionPtr)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
01539 typedef RetType (detail::GenericClass::*GenericMemFn)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8);
01540 typedef detail::ClosurePtr<GenericMemFn, StaticFunctionPtr, UnvoidStaticFunctionPtr> ClosureType;
01541 ClosureType m_Closure;
01542 public:
01543
01544 typedef FastDelegate8 type;
01545
01546
01547 FastDelegate8() { clear(); }
01548 FastDelegate8(const FastDelegate8 &x) {
01549 m_Closure.CopyFrom(this, x.m_Closure); }
01550 void operator = (const FastDelegate8 &x) {
01551 m_Closure.CopyFrom(this, x.m_Closure); }
01552 bool operator ==(const FastDelegate8 &x) const {
01553 return m_Closure.IsEqual(x.m_Closure); }
01554 bool operator !=(const FastDelegate8 &x) const {
01555 return !m_Closure.IsEqual(x.m_Closure); }
01556 bool operator <(const FastDelegate8 &x) const {
01557 return m_Closure.IsLess(x.m_Closure); }
01558 bool operator >(const FastDelegate8 &x) const {
01559 return x.m_Closure.IsLess(m_Closure); }
01560
01561 template < class X, class Y >
01562 FastDelegate8(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
01563 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01564 template < class X, class Y >
01565 inline void bind(Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
01566 m_Closure.bindmemfunc(detail::implicit_cast<X*>(pthis), function_to_bind); }
01567
01568 template < class X, class Y >
01569 FastDelegate8(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
01570 m_Closure.bindconstmemfunc(detail::implicit_cast<const X*>(pthis), function_to_bind); }
01571 template < class X, class Y >
01572 inline void bind(const Y *pthis, DesiredRetType (X::* function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
01573 m_Closure.bindconstmemfunc(detail::implicit_cast<const X *>(pthis), function_to_bind); }
01574
01575
01576 FastDelegate8(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
01577 bind(function_to_bind); }
01578
01579 void operator = (DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) ) {
01580 bind(function_to_bind); }
01581 inline void bind(DesiredRetType (*function_to_bind)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
01582 m_Closure.bindstaticfunc(this, &FastDelegate8::InvokeStaticFunction,
01583 function_to_bind); }
01584
01585 RetType operator() (Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const {
01586 return (m_Closure.GetClosureThis()->*(m_Closure.GetClosureMemPtr()))(p1, p2, p3, p4, p5, p6, p7, p8); }
01587
01588 private:
01589 typedef struct SafeBoolStruct {
01590 int a_data_pointer_to_this_is_0_on_buggy_compilers;
01591 StaticFunctionPtr m_nonzero;
01592 } UselessTypedef;
01593 typedef StaticFunctionPtr SafeBoolStruct::*unspecified_bool_type;
01594 public:
01595 operator unspecified_bool_type() const {
01596 return empty()? 0: &SafeBoolStruct::m_nonzero;
01597 }
01598
01599 inline bool operator==(StaticFunctionPtr funcptr) {
01600 return m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01601 inline bool operator!=(StaticFunctionPtr funcptr) {
01602 return !m_Closure.IsEqualToStaticFuncPtr(funcptr); }
01603 inline bool operator ! () const {
01604 return !m_Closure; }
01605 inline bool empty() const {
01606 return !m_Closure; }
01607 void clear() { m_Closure.clear();}
01608
01609 const DelegateMemento & GetMemento() { return m_Closure; }
01610 void SetMemento(const DelegateMemento &any) { m_Closure.CopyFrom(this, any); }
01611
01612 private:
01613 RetType InvokeStaticFunction(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const {
01614 return (*(m_Closure.GetStaticFunction()))(p1, p2, p3, p4, p5, p6, p7, p8); }
01615 };
01616
01617
01619
01620
01621
01622
01623
01624
01625
01626
01628
01629 #ifdef FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
01630
01631
01632
01633 template <typename Signature>
01634 class FastDelegate;
01635
01636
01637
01638
01639
01640
01641 template<typename R>
01642 class FastDelegate< R ( ) >
01643
01644 : public FastDelegate0 < R >
01645 {
01646 public:
01647
01648 typedef FastDelegate0 < R > BaseType;
01649
01650
01651 typedef FastDelegate SelfType;
01652
01653
01654 FastDelegate() : BaseType() { }
01655
01656 template < class X, class Y >
01657 FastDelegate(Y * pthis,
01658 R (X::* function_to_bind)( ))
01659 : BaseType(pthis, function_to_bind) { }
01660
01661 template < class X, class Y >
01662 FastDelegate(const Y *pthis,
01663 R (X::* function_to_bind)( ) const)
01664 : BaseType(pthis, function_to_bind)
01665 { }
01666
01667 FastDelegate(R (*function_to_bind)( ))
01668 : BaseType(function_to_bind) { }
01669 void operator = (const BaseType &x) {
01670 *static_cast<BaseType*>(this) = x; }
01671 };
01672
01673
01674
01675
01676
01677
01678 template<typename R, class Param1>
01679 class FastDelegate< R ( Param1 ) >
01680
01681 : public FastDelegate1 < Param1, R >
01682 {
01683 public:
01684
01685 typedef FastDelegate1 < Param1, R > BaseType;
01686
01687
01688 typedef FastDelegate SelfType;
01689
01690
01691 FastDelegate() : BaseType() { }
01692
01693 template < class X, class Y >
01694 FastDelegate(Y * pthis,
01695 R (X::* function_to_bind)( Param1 p1 ))
01696 : BaseType(pthis, function_to_bind) { }
01697
01698 template < class X, class Y >
01699 FastDelegate(const Y *pthis,
01700 R (X::* function_to_bind)( Param1 p1 ) const)
01701 : BaseType(pthis, function_to_bind)
01702 { }
01703
01704 FastDelegate(R (*function_to_bind)( Param1 p1 ))
01705 : BaseType(function_to_bind) { }
01706 void operator = (const BaseType &x) {
01707 *static_cast<BaseType*>(this) = x; }
01708 };
01709
01710
01711
01712
01713
01714
01715 template<typename R, class Param1, class Param2>
01716 class FastDelegate< R ( Param1, Param2 ) >
01717
01718 : public FastDelegate2 < Param1, Param2, R >
01719 {
01720 public:
01721
01722 typedef FastDelegate2 < Param1, Param2, R > BaseType;
01723
01724
01725 typedef FastDelegate SelfType;
01726
01727
01728 FastDelegate() : BaseType() { }
01729
01730 template < class X, class Y >
01731 FastDelegate(Y * pthis,
01732 R (X::* function_to_bind)( Param1 p1, Param2 p2 ))
01733 : BaseType(pthis, function_to_bind) { }
01734
01735 template < class X, class Y >
01736 FastDelegate(const Y *pthis,
01737 R (X::* function_to_bind)( Param1 p1, Param2 p2 ) const)
01738 : BaseType(pthis, function_to_bind)
01739 { }
01740
01741 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2 ))
01742 : BaseType(function_to_bind) { }
01743 void operator = (const BaseType &x) {
01744 *static_cast<BaseType*>(this) = x; }
01745 };
01746
01747
01748
01749
01750
01751
01752 template<typename R, class Param1, class Param2, class Param3>
01753 class FastDelegate< R ( Param1, Param2, Param3 ) >
01754
01755 : public FastDelegate3 < Param1, Param2, Param3, R >
01756 {
01757 public:
01758
01759 typedef FastDelegate3 < Param1, Param2, Param3, R > BaseType;
01760
01761
01762 typedef FastDelegate SelfType;
01763
01764
01765 FastDelegate() : BaseType() { }
01766
01767 template < class X, class Y >
01768 FastDelegate(Y * pthis,
01769 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ))
01770 : BaseType(pthis, function_to_bind) { }
01771
01772 template < class X, class Y >
01773 FastDelegate(const Y *pthis,
01774 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ) const)
01775 : BaseType(pthis, function_to_bind)
01776 { }
01777
01778 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3 ))
01779 : BaseType(function_to_bind) { }
01780 void operator = (const BaseType &x) {
01781 *static_cast<BaseType*>(this) = x; }
01782 };
01783
01784
01785
01786
01787
01788
01789 template<typename R, class Param1, class Param2, class Param3, class Param4>
01790 class FastDelegate< R ( Param1, Param2, Param3, Param4 ) >
01791
01792 : public FastDelegate4 < Param1, Param2, Param3, Param4, R >
01793 {
01794 public:
01795
01796 typedef FastDelegate4 < Param1, Param2, Param3, Param4, R > BaseType;
01797
01798
01799 typedef FastDelegate SelfType;
01800
01801
01802 FastDelegate() : BaseType() { }
01803
01804 template < class X, class Y >
01805 FastDelegate(Y * pthis,
01806 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ))
01807 : BaseType(pthis, function_to_bind) { }
01808
01809 template < class X, class Y >
01810 FastDelegate(const Y *pthis,
01811 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ) const)
01812 : BaseType(pthis, function_to_bind)
01813 { }
01814
01815 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4 ))
01816 : BaseType(function_to_bind) { }
01817 void operator = (const BaseType &x) {
01818 *static_cast<BaseType*>(this) = x; }
01819 };
01820
01821
01822
01823
01824
01825
01826 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5>
01827 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5 ) >
01828
01829 : public FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R >
01830 {
01831 public:
01832
01833 typedef FastDelegate5 < Param1, Param2, Param3, Param4, Param5, R > BaseType;
01834
01835
01836 typedef FastDelegate SelfType;
01837
01838
01839 FastDelegate() : BaseType() { }
01840
01841 template < class X, class Y >
01842 FastDelegate(Y * pthis,
01843 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ))
01844 : BaseType(pthis, function_to_bind) { }
01845
01846 template < class X, class Y >
01847 FastDelegate(const Y *pthis,
01848 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ) const)
01849 : BaseType(pthis, function_to_bind)
01850 { }
01851
01852 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5 ))
01853 : BaseType(function_to_bind) { }
01854 void operator = (const BaseType &x) {
01855 *static_cast<BaseType*>(this) = x; }
01856 };
01857
01858
01859
01860
01861
01862
01863 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6>
01864 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6 ) >
01865
01866 : public FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R >
01867 {
01868 public:
01869
01870 typedef FastDelegate6 < Param1, Param2, Param3, Param4, Param5, Param6, R > BaseType;
01871
01872
01873 typedef FastDelegate SelfType;
01874
01875
01876 FastDelegate() : BaseType() { }
01877
01878 template < class X, class Y >
01879 FastDelegate(Y * pthis,
01880 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ))
01881 : BaseType(pthis, function_to_bind) { }
01882
01883 template < class X, class Y >
01884 FastDelegate(const Y *pthis,
01885 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ) const)
01886 : BaseType(pthis, function_to_bind)
01887 { }
01888
01889 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6 ))
01890 : BaseType(function_to_bind) { }
01891 void operator = (const BaseType &x) {
01892 *static_cast<BaseType*>(this) = x; }
01893 };
01894
01895
01896
01897
01898
01899
01900 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7>
01901 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7 ) >
01902
01903 : public FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R >
01904 {
01905 public:
01906
01907 typedef FastDelegate7 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, R > BaseType;
01908
01909
01910 typedef FastDelegate SelfType;
01911
01912
01913 FastDelegate() : BaseType() { }
01914
01915 template < class X, class Y >
01916 FastDelegate(Y * pthis,
01917 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ))
01918 : BaseType(pthis, function_to_bind) { }
01919
01920 template < class X, class Y >
01921 FastDelegate(const Y *pthis,
01922 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ) const)
01923 : BaseType(pthis, function_to_bind)
01924 { }
01925
01926 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7 ))
01927 : BaseType(function_to_bind) { }
01928 void operator = (const BaseType &x) {
01929 *static_cast<BaseType*>(this) = x; }
01930 };
01931
01932
01933
01934
01935
01936
01937 template<typename R, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8>
01938 class FastDelegate< R ( Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8 ) >
01939
01940 : public FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R >
01941 {
01942 public:
01943
01944 typedef FastDelegate8 < Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, R > BaseType;
01945
01946
01947 typedef FastDelegate SelfType;
01948
01949
01950 FastDelegate() : BaseType() { }
01951
01952 template < class X, class Y >
01953 FastDelegate(Y * pthis,
01954 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ))
01955 : BaseType(pthis, function_to_bind) { }
01956
01957 template < class X, class Y >
01958 FastDelegate(const Y *pthis,
01959 R (X::* function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ) const)
01960 : BaseType(pthis, function_to_bind)
01961 { }
01962
01963 FastDelegate(R (*function_to_bind)( Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8 ))
01964 : BaseType(function_to_bind) { }
01965 void operator = (const BaseType &x) {
01966 *static_cast<BaseType*>(this) = x; }
01967 };
01968
01969
01970 #endif //FASTDELEGATE_ALLOW_FUNCTION_TYPE_SYNTAX
01971
01973
01974
01975
01976
01977
01978
01979
01980
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996 #ifdef FASTDLGT_VC6
01997 #define FASTDLGT_RETTYPE detail::VoidToDefaultVoid<RetType>::type
01998 #else
01999 #define FASTDLGT_RETTYPE RetType
02000 #endif
02001
02002
02003 template <class X, class Y, class RetType>
02004 FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)()) {
02005 return FastDelegate0<FASTDLGT_RETTYPE>(x, func);
02006 }
02007
02008 template <class X, class Y, class RetType>
02009 FastDelegate0<FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)() const) {
02010 return FastDelegate0<FASTDLGT_RETTYPE>(x, func);
02011 }
02012
02013
02014 template <class X, class Y, class Param1, class RetType>
02015 FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1)) {
02016 return FastDelegate1<Param1, FASTDLGT_RETTYPE>(x, func);
02017 }
02018
02019 template <class X, class Y, class Param1, class RetType>
02020 FastDelegate1<Param1, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1) const) {
02021 return FastDelegate1<Param1, FASTDLGT_RETTYPE>(x, func);
02022 }
02023
02024
02025 template <class X, class Y, class Param1, class Param2, class RetType>
02026 FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2)) {
02027 return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(x, func);
02028 }
02029
02030 template <class X, class Y, class Param1, class Param2, class RetType>
02031 FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2) const) {
02032 return FastDelegate2<Param1, Param2, FASTDLGT_RETTYPE>(x, func);
02033 }
02034
02035
02036 template <class X, class Y, class Param1, class Param2, class Param3, class RetType>
02037 FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3)) {
02038 return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(x, func);
02039 }
02040
02041 template <class X, class Y, class Param1, class Param2, class Param3, class RetType>
02042 FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3) const) {
02043 return FastDelegate3<Param1, Param2, Param3, FASTDLGT_RETTYPE>(x, func);
02044 }
02045
02046
02047 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
02048 FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4)) {
02049 return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(x, func);
02050 }
02051
02052 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class RetType>
02053 FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4) const) {
02054 return FastDelegate4<Param1, Param2, Param3, Param4, FASTDLGT_RETTYPE>(x, func);
02055 }
02056
02057
02058 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
02059 FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5)) {
02060 return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(x, func);
02061 }
02062
02063 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class RetType>
02064 FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5) const) {
02065 return FastDelegate5<Param1, Param2, Param3, Param4, Param5, FASTDLGT_RETTYPE>(x, func);
02066 }
02067
02068
02069 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
02070 FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6)) {
02071 return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(x, func);
02072 }
02073
02074 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class RetType>
02075 FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6) const) {
02076 return FastDelegate6<Param1, Param2, Param3, Param4, Param5, Param6, FASTDLGT_RETTYPE>(x, func);
02077 }
02078
02079
02080 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
02081 FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7)) {
02082 return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(x, func);
02083 }
02084
02085 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class RetType>
02086 FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7) const) {
02087 return FastDelegate7<Param1, Param2, Param3, Param4, Param5, Param6, Param7, FASTDLGT_RETTYPE>(x, func);
02088 }
02089
02090
02091 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
02092 FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8)) {
02093 return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(x, func);
02094 }
02095
02096 template <class X, class Y, class Param1, class Param2, class Param3, class Param4, class Param5, class Param6, class Param7, class Param8, class RetType>
02097 FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE> MakeDelegate(Y* x, RetType (X::*func)(Param1 p1, Param2 p2, Param3 p3, Param4 p4, Param5 p5, Param6 p6, Param7 p7, Param8 p8) const) {
02098 return FastDelegate8<Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, FASTDLGT_RETTYPE>(x, func);
02099 }
02100
02101
02102
02103 #undef FASTDLGT_RETTYPE
02104
02105 }
02106
02107 #endif // !defined(FASTDELEGATE_H)
02108