Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7213


Ignore:
Timestamp:
Aug 24, 2010, 11:26:14 PM (14 years ago)
Author:
landauf
Message:

small changes in Functor, removed specialization for FunctorStatic (FunctorMember<void>) to gain cast-ability to FunctorPointer<F>

File:
1 edited

Legend:

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

    r7212 r7213  
    3434#include "core/CorePrereqs.h"
    3535
    36 #include "util/Convert.h"
    3736#include "util/Debug.h"
    3837#include "util/MultiType.h"
     
    114113    };
    115114
     115    namespace detail
     116    {
     117        template <class O>
     118        struct FunctorTypeStatic
     119        { enum { result = false }; };
     120        template <>
     121        struct FunctorTypeStatic<void>
     122        { enum { result = true }; };
     123    }
     124
    116125    template <class O>
    117126    class FunctorMember : public Functor
     
    124133            MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
    125134            {
    126                 if (this->object_)
     135                if (detail::FunctorTypeStatic<O>::result || this->object_)
    127136                    return (*this)(this->object_, param1, param2, param3, param4, param5);
    128137                else
     
    134143
    135144            Functor::Type::Enum getType() const
    136                 { return Functor::Type::Member; }
     145                { return detail::FunctorTypeStatic<O>::result ? Functor::Type::Static : Functor::Type::Member; }
    137146
    138147            inline void setObject(O* object)
     
    150159    };
    151160
    152     template <>
    153     class _CoreExport FunctorMember<void> : public Functor
    154     {
    155         public:
    156             FunctorMember(void* = 0) {}
    157 
    158             virtual MultiType operator()(void* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
    159 
    160             MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
    161             {
    162                 return (*this)(0, param1, param2, param3, param4, param5);
    163             }
    164 
    165             Functor::Type::Enum getType() const
    166                 { return Functor::Type::Static; }
    167     };
    168 
    169161    typedef FunctorMember<void> FunctorStatic;
    170162
    171     template <class F, class O>
     163    template <class F, class O = void>
    172164    class FunctorPointer : public FunctorMember<O>
    173165    {
     
    238230        {};
    239231
    240         template <typename T>
     232        template <class T>
    241233        struct FunctorHasReturnvalue
    242234        { enum { result = true }; };
Note: See TracChangeset for help on using the changeset viewer.