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