- Timestamp:
- Aug 24, 2010, 11:26:14 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/consolecommands3/src/libraries/core/command/Functor.h
r7212 r7213 34 34 #include "core/CorePrereqs.h" 35 35 36 #include "util/Convert.h"37 36 #include "util/Debug.h" 38 37 #include "util/MultiType.h" … … 114 113 }; 115 114 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 116 125 template <class O> 117 126 class FunctorMember : public Functor … … 124 133 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) 125 134 { 126 if ( this->object_)135 if (detail::FunctorTypeStatic<O>::result || this->object_) 127 136 return (*this)(this->object_, param1, param2, param3, param4, param5); 128 137 else … … 134 143 135 144 Functor::Type::Enum getType() const 136 { return Functor::Type::Member; }145 { return detail::FunctorTypeStatic<O>::result ? Functor::Type::Static : Functor::Type::Member; } 137 146 138 147 inline void setObject(O* object) … … 150 159 }; 151 160 152 template <>153 class _CoreExport FunctorMember<void> : public Functor154 {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() const166 { return Functor::Type::Static; }167 };168 169 161 typedef FunctorMember<void> FunctorStatic; 170 162 171 template <class F, class O >163 template <class F, class O = void> 172 164 class FunctorPointer : public FunctorMember<O> 173 165 { … … 238 230 {}; 239 231 240 template < typenameT>232 template <class T> 241 233 struct FunctorHasReturnvalue 242 234 { enum { result = true }; };
Note: See TracChangeset
for help on using the changeset viewer.