Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5830 for code


Ignore:
Timestamp:
Sep 28, 2009, 10:05:08 PM (15 years ago)
Author:
landauf
Message:

extended createFunctor(&A::f, object) to accept also objects of other classes than A (but only if they're children of A)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/Functor.h

    r5828 r5830  
    191191
    192192
    193 #define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams
    194 #define FUNCTOR_TEMPLATE000
    195 #define FUNCTOR_TEMPLATE001 template <class P1>
    196 #define FUNCTOR_TEMPLATE002 template <class P1, class P2>
    197 #define FUNCTOR_TEMPLATE003 template <class P1, class P2, class P3>
    198 #define FUNCTOR_TEMPLATE004 template <class P1, class P2, class P3, class P4>
    199 #define FUNCTOR_TEMPLATE005 template <class P1, class P2, class P3, class P4, class P5>
    200 #define FUNCTOR_TEMPLATE010 template <class R>
    201 #define FUNCTOR_TEMPLATE011 template <class R, class P1>
    202 #define FUNCTOR_TEMPLATE012 template <class R, class P1, class P2>
    203 #define FUNCTOR_TEMPLATE013 template <class R, class P1, class P2, class P3>
    204 #define FUNCTOR_TEMPLATE014 template <class R, class P1, class P2, class P3, class P4>
    205 #define FUNCTOR_TEMPLATE015 template <class R, class P1, class P2, class P3, class P4, class P5>
    206 #define FUNCTOR_TEMPLATE100 template <class T>
    207 #define FUNCTOR_TEMPLATE101 template <class T, class P1>
    208 #define FUNCTOR_TEMPLATE102 template <class T, class P1, class P2>
    209 #define FUNCTOR_TEMPLATE103 template <class T, class P1, class P2, class P3>
    210 #define FUNCTOR_TEMPLATE104 template <class T, class P1, class P2, class P3, class P4>
    211 #define FUNCTOR_TEMPLATE105 template <class T, class P1, class P2, class P3, class P4, class P5>
    212 #define FUNCTOR_TEMPLATE110 template <class T, class R>
    213 #define FUNCTOR_TEMPLATE111 template <class T, class R, class P1>
    214 #define FUNCTOR_TEMPLATE112 template <class T, class R, class P1, class P2>
    215 #define FUNCTOR_TEMPLATE113 template <class T, class R, class P1, class P2, class P3>
    216 #define FUNCTOR_TEMPLATE114 template <class T, class R, class P1, class P2, class P3, class P4>
    217 #define FUNCTOR_TEMPLATE115 template <class T, class R, class P1, class P2, class P3, class P4, class P5>
     193#define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams, additionalobject) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams(additionalobject)
     194#define FUNCTOR_TEMPLATE000(additionalobject)
     195#define FUNCTOR_TEMPLATE001(additionalobject) template <class P1>
     196#define FUNCTOR_TEMPLATE002(additionalobject) template <class P1, class P2>
     197#define FUNCTOR_TEMPLATE003(additionalobject) template <class P1, class P2, class P3>
     198#define FUNCTOR_TEMPLATE004(additionalobject) template <class P1, class P2, class P3, class P4>
     199#define FUNCTOR_TEMPLATE005(additionalobject) template <class P1, class P2, class P3, class P4, class P5>
     200#define FUNCTOR_TEMPLATE010(additionalobject) template <class R>
     201#define FUNCTOR_TEMPLATE011(additionalobject) template <class R, class P1>
     202#define FUNCTOR_TEMPLATE012(additionalobject) template <class R, class P1, class P2>
     203#define FUNCTOR_TEMPLATE013(additionalobject) template <class R, class P1, class P2, class P3>
     204#define FUNCTOR_TEMPLATE014(additionalobject) template <class R, class P1, class P2, class P3, class P4>
     205#define FUNCTOR_TEMPLATE015(additionalobject) template <class R, class P1, class P2, class P3, class P4, class P5>
     206#define FUNCTOR_TEMPLATE100(additionalobject) template <class T FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     207#define FUNCTOR_TEMPLATE101(additionalobject) template <class T, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     208#define FUNCTOR_TEMPLATE102(additionalobject) template <class T, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     209#define FUNCTOR_TEMPLATE103(additionalobject) template <class T, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     210#define FUNCTOR_TEMPLATE104(additionalobject) template <class T, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     211#define FUNCTOR_TEMPLATE105(additionalobject) template <class T, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     212#define FUNCTOR_TEMPLATE110(additionalobject) template <class T, class R FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     213#define FUNCTOR_TEMPLATE111(additionalobject) template <class T, class R, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     214#define FUNCTOR_TEMPLATE112(additionalobject) template <class T, class R, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     215#define FUNCTOR_TEMPLATE113(additionalobject) template <class T, class R, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     216#define FUNCTOR_TEMPLATE114(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     217#define FUNCTOR_TEMPLATE115(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
     218
     219
     220
     221#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT##additionalobject
     222#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT0
     223#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT1 , class O
    218224
    219225
     
    317323
    318324#define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
    319     FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
     325    FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
    320326    class FunctorStatic##returnvalue##numparams : public FunctorStatic \
    321327    { \
     
    347353    \
    348354    \
    349     FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
     355    FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
    350356    inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
    351357    { \
     
    358364
    359365#define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \
    360     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     366    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    361367    class FunctorMember##returnvalue##numparams : public FunctorMember<T> \
    362368    { \
     
    391397    \
    392398    \
    393     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     399    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    394400    class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \
    395401    { \
     
    423429    \
    424430    \
    425     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     431    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    426432    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
    427433    { \
     
    430436    \
    431437    \
    432     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
     438    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
    433439    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
    434440    { \
     
    436442    } \
    437443    \
    438     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
    439     inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), T* object) \
     444    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
     445    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), O* object) \
    440446    { \
    441447        FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
     
    445451    \
    446452    \
    447     FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
    448     inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, T* object) \
     453    FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
     454    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, O* object) \
    449455    { \
    450456        FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
Note: See TracChangeset for help on using the changeset viewer.