Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/consolecommands3/src/libraries/core/command/Functor.h @ 7235

Last change on this file since 7235 was 7214, checked in by landauf, 14 years ago

progress on the new console command interface.
enhanced possibilities to compare Functors and to manipulate Executors

  • Property svn:eol-style set to native
File size: 39.2 KB
RevLine 
[1505]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#ifndef _Functor_H__
30#define _Functor_H__
31
[7179]32#include <typeinfo>
33
[7203]34#include "core/CorePrereqs.h"
[1505]35
[3196]36#include "util/Debug.h"
[1747]37#include "util/MultiType.h"
[7196]38#include "FunctorPtr.h"
[1505]39
40namespace orxonox
41{
[1786]42    const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
[1784]43
[1505]44    template <class T>
[7212]45    inline std::string _typeToString() { return "unknown"; }
[1505]46
[7212]47    template <> inline std::string _typeToString<void>()               { return ""; }
48    template <> inline std::string _typeToString<int>()                { return "int"; }
49    template <> inline std::string _typeToString<unsigned int>()       { return "uint"; }
50    template <> inline std::string _typeToString<char>()               { return "char"; }
51    template <> inline std::string _typeToString<unsigned char>()      { return "uchar"; }
52    template <> inline std::string _typeToString<short>()              { return "short"; }
53    template <> inline std::string _typeToString<unsigned short>()     { return "ushort"; }
54    template <> inline std::string _typeToString<long>()               { return "long"; }
55    template <> inline std::string _typeToString<unsigned long>()      { return "ulong"; }
56    template <> inline std::string _typeToString<long long>()          { return "longlong"; }
57    template <> inline std::string _typeToString<unsigned long long>() { return "ulonglong"; }
58    template <> inline std::string _typeToString<float>()              { return "float"; }
59    template <> inline std::string _typeToString<double>()             { return "double"; }
60    template <> inline std::string _typeToString<long double>()        { return "longdouble"; }
61    template <> inline std::string _typeToString<bool>()               { return "bool"; }
62    template <> inline std::string _typeToString<std::string>()        { return "string"; }
63    template <> inline std::string _typeToString<Vector2>()            { return "Vector2"; }
64    template <> inline std::string _typeToString<Vector3>()            { return "Vector3"; }
65    template <> inline std::string _typeToString<Quaternion>()         { return "Quaternion"; }
66    template <> inline std::string _typeToString<ColourValue>()        { return "ColourValue"; }
67    template <> inline std::string _typeToString<Radian>()             { return "Radian"; }
68    template <> inline std::string _typeToString<Degree>()             { return "Degree"; }
[1505]69
[7212]70    template <class T>
71    inline std::string typeToString() { return _typeToString<typename Loki::TypeTraits<T>::UnqualifiedReferredType>(); }
[1505]72
73    class _CoreExport Functor
74    {
75        public:
[7188]76            struct Type
77            {
78                enum Enum
79                {
80                    Static,
[7212]81                    Member
[7188]82                };
83            };
84
85        public:
[7189]86            virtual 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) = 0;
[1505]87
[7188]88            virtual Type::Enum getType() const = 0;
89            virtual unsigned int getParamCount() const = 0;
90            virtual bool hasReturnvalue() const = 0;
[1505]91
[7188]92            virtual std::string getTypenameParam(unsigned int param) const = 0;
93            virtual std::string getTypenameReturnvalue() const = 0;
94
[1747]95            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
[1505]96
[7179]97            virtual void setRawObjectPointer(void* object) {}
98            virtual void* getRawObjectPointer() const { return 0; }
99
[7212]100            template <class F>
101            inline bool setFunction(F* function)
102            {
103                if (this->getFullIdentifier() == typeid(F*))
104                {
105                    modifyFunctor(this, function);
106                    return true;
107                }
108                return false;
109            }
110
111            virtual const std::type_info& getFullIdentifier() const = 0;
[7179]112            virtual const std::type_info& getHeaderIdentifier() const = 0;
[7214]113            virtual const std::type_info& getHeaderIdentifier(unsigned int params) const = 0;
[1505]114    };
115
[7213]116    namespace detail
117    {
118        template <class O>
119        struct FunctorTypeStatic
120        { enum { result = false }; };
121        template <>
122        struct FunctorTypeStatic<void>
123        { enum { result = true }; };
124    }
125
[7212]126    template <class O>
[1505]127    class FunctorMember : public Functor
128    {
129        public:
[7212]130            FunctorMember(O* object = 0) : object_(object) {}
[1505]131
[7212]132            virtual MultiType operator()(O* 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;
[1505]133
[7212]134            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)
[1505]135            {
[7213]136                if (detail::FunctorTypeStatic<O>::result || this->object_)
[7189]137                    return (*this)(this->object_, param1, param2, param3, param4, param5);
[1505]138                else
139                {
[7212]140                    COUT(1) << "Error: Can't execute FunctorMember, no object set." << std::endl;
[7189]141                    return MT_Type::Null;
[1505]142                }
143            }
144
[7212]145            Functor::Type::Enum getType() const
[7213]146                { return detail::FunctorTypeStatic<O>::result ? Functor::Type::Static : Functor::Type::Member; }
[1505]147
[7212]148            inline void setObject(O* object)
149                { this->object_ = object;}
150            inline O* getObject() const
151                { return this->object_; }
[1505]152
[7212]153            inline void setRawObjectPointer(void* object)
154                { this->object_ = (O*)object; }
155            inline void* getRawObjectPointer() const
156                { return this->object_; }
[7179]157
[7212]158        protected:
159            O* object_;
160    };
[7179]161
[7212]162    typedef FunctorMember<void> FunctorStatic;
[1505]163
[7213]164    template <class F, class O = void>
[7212]165    class FunctorPointer : public FunctorMember<O>
166    {
167        public:
168            FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {}
[1505]169
[7212]170            inline void setFunction(F functionPointer)
171                { this->functionPointer_ = functionPointer; }
172            inline F getFunction() const
173                { return this->functionPointer_; }
[7179]174
[7212]175            const std::type_info& getFullIdentifier() const
176                { return typeid(F); }
[7179]177
[7212]178        protected:
179            F functionPointer_;
180    };
[7179]181
[7212]182    namespace detail
[7179]183    {
[7212]184        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer                                            { typedef R (O::*Type)(P1, P2, P3, P4, P5); };
185        template <class R, class O, class P1, class P2, class P3, class P4, class P5>               struct FunctionPointer<R, O, false, P1, P2, P3, P4, P5>           { typedef R (O::*Type)(P1, P2, P3, P4, P5); };
186        template <class R, class O, class P1, class P2, class P3, class P4>                         struct FunctionPointer<R, O, false, P1, P2, P3, P4, void>         { typedef R (O::*Type)(P1, P2, P3, P4); };
187        template <class R, class O, class P1, class P2, class P3>                                   struct FunctionPointer<R, O, false, P1, P2, P3, void, void>       { typedef R (O::*Type)(P1, P2, P3); };
188        template <class R, class O, class P1, class P2>                                             struct FunctionPointer<R, O, false, P1, P2, void, void, void>     { typedef R (O::*Type)(P1, P2); };
189        template <class R, class O, class P1>                                                       struct FunctionPointer<R, O, false, P1, void, void, void, void>   { typedef R (O::*Type)(P1); };
190        template <class R, class O>                                                                 struct FunctionPointer<R, O, false, void, void, void, void, void> { typedef R (O::*Type)(); };
191        template <class R, class O, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, O, true, P1, P2, P3, P4, P5>           { typedef R (O::*Type)(P1, P2, P3, P4, P5) const; };
192        template <class R, class O, class P1, class P2, class P3, class P4>           struct FunctionPointer<R, O, true, P1, P2, P3, P4, void>         { typedef R (O::*Type)(P1, P2, P3, P4) const; };
193        template <class R, class O, class P1, class P2, class P3>                     struct FunctionPointer<R, O, true, P1, P2, P3, void, void>       { typedef R (O::*Type)(P1, P2, P3) const; };
194        template <class R, class O, class P1, class P2>                               struct FunctionPointer<R, O, true, P1, P2, void, void, void>     { typedef R (O::*Type)(P1, P2) const; };
195        template <class R, class O, class P1>                                         struct FunctionPointer<R, O, true, P1, void, void, void, void>   { typedef R (O::*Type)(P1) const; };
196        template <class R, class O>                                                   struct FunctionPointer<R, O, true, void, void, void, void, void> { typedef R (O::*Type)() const; };
197        template <class R, class P1, class P2, class P3, class P4, class P5> struct FunctionPointer<R, void, false, P1, P2, P3, P4, P5>           { typedef R (*Type)(P1, P2, P3, P4, P5); };
198        template <class R, class P1, class P2, class P3, class P4>           struct FunctionPointer<R, void, false, P1, P2, P3, P4, void>         { typedef R (*Type)(P1, P2, P3, P4); };
199        template <class R, class P1, class P2, class P3>                     struct FunctionPointer<R, void, false, P1, P2, P3, void, void>       { typedef R (*Type)(P1, P2, P3); };
200        template <class R, class P1, class P2>                               struct FunctionPointer<R, void, false, P1, P2, void, void, void>     { typedef R (*Type)(P1, P2); };
201        template <class R, class P1>                                         struct FunctionPointer<R, void, false, P1, void, void, void, void>   { typedef R (*Type)(P1); };
202        template <class R>                                                   struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); };
[7179]203
[7212]204        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller                                              { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } };
205        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4); } };
206        template <class R, class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3); } };
207        template <class R, class O, bool isconst, class P1, class P2>                               struct FunctorCaller<R, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2); } };
208        template <class R, class O, bool isconst, class P1>                                         struct FunctorCaller<R, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1); } };
209        template <class R, class O, bool isconst>                                                   struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(); } };
210        template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
211        template <class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
212        template <class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
213        template <class O, bool isconst, class P1, class P2>                               struct FunctorCaller<void, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2); return MT_Type::Null; } };
214        template <class O, bool isconst, class P1>                                         struct FunctorCaller<void, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1); return MT_Type::Null; } };
215        template <class O, bool isconst>                                                   struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(); return MT_Type::Null; } };
216        template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } };
217        template <class R, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4); } };
218        template <class R, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3); } };
219        template <class R, bool isconst, class P1, class P2>                               struct FunctorCaller<R, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2); } };
220        template <class R, bool isconst, class P1>                                         struct FunctorCaller<R, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1); } };
221        template <class R, bool isconst>                                                   struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(); } };
222        template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
223        template <bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
224        template <bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
225        template <bool isconst, class P1, class P2>                               struct FunctorCaller<void, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2); return MT_Type::Null; } };
226        template <bool isconst, class P1>                                         struct FunctorCaller<void, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1); return MT_Type::Null; } };
227        template <bool isconst>                                                   struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(); return MT_Type::Null; } };
[7179]228
[7212]229        template <class R, class P1, class P2, class P3, class P4, class P5>
230        struct FunctorHeaderIdentifier
231        {};
[7179]232
[7213]233        template <class T>
[7212]234        struct FunctorHasReturnvalue
235        { enum { result = true }; };
236        template <>
237        struct FunctorHasReturnvalue<void>
238        { enum { result = false }; };
[1505]239
[7212]240        template <class P1, class P2, class P3, class P4, class P5>
241        struct FunctorParamCount
242        { enum { result = 5 }; };
243        template <class P1, class P2, class P3, class P4>
244        struct FunctorParamCount<P1, P2, P3, P4, void>
245        { enum { result = 4 }; };
246        template <class P1, class P2, class P3>
247        struct FunctorParamCount<P1, P2, P3, void, void>
248        { enum { result = 3 }; };
249        template <class P1, class P2>
250        struct FunctorParamCount<P1, P2, void, void, void>
251        { enum { result = 2 }; };
252        template <class P1>
253        struct FunctorParamCount<P1, void, void, void, void>
254        { enum { result = 1 }; };
255        template <>
256        struct FunctorParamCount<void, void, void, void, void>
257        { enum { result = 0 }; };
[1505]258    }
259
[7212]260    template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5>
261    class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>
262    {
263        public:
264            FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object = 0) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {}
[1505]265
[7212]266            MultiType operator()(O* 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)
267            {
268                return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
269            }
[1505]270
[7212]271            void evaluateParam(unsigned int index, MultiType& param) const
272            {
273                switch (index)
274                {
275                    case 0: param.convert<P1>(); break;
276                    case 1: param.convert<P2>(); break;
277                    case 2: param.convert<P3>(); break;
278                    case 3: param.convert<P4>(); break;
279                    case 4: param.convert<P5>(); break;
280                }
281            }
[1505]282
[7212]283            unsigned int getParamCount() const
284            {
285                return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;
286            }
[1505]287
[7212]288            bool hasReturnvalue() const
289            {
290                return detail::FunctorHasReturnvalue<R>::result;
291            }
[1505]292
[7212]293            std::string getTypenameParam(unsigned int param) const
294            {
295                switch (param)
296                {
[7214]297                    case 0:  return typeToString<P1>();
298                    case 1:  return typeToString<P2>();
299                    case 2:  return typeToString<P3>();
300                    case 3:  return typeToString<P4>();
301                    case 4:  return typeToString<P5>();
[7212]302                    default: return "";
303                }
304            }
[1505]305
[7212]306            std::string getTypenameReturnvalue() const
307            {
308                return typeToString<R>();
309            }
[7179]310
[7212]311            const std::type_info& getHeaderIdentifier() const
312            {
313                return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
314            }
[7214]315
316            const std::type_info& getHeaderIdentifier(unsigned int params) const
317            {
318                switch (params)
319                {
320                    case 0:  return typeid(detail::FunctorHeaderIdentifier<R, void, void, void, void, void>);
321                    case 1:  return typeid(detail::FunctorHeaderIdentifier<R, P1, void, void, void, void>);
322                    case 2:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, void, void, void>);
323                    case 3:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, void, void>);
324                    case 4:  return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, void>);
325                    default: return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
326                }
327            }
[7212]328    };
[1505]329
[7212]330    template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>,           FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, P3, P4, P5>::Type, O> >           createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5), OO* object) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer, object); }
331    template <class R, class O, class OO, class P1, class P2, class P3, class P4>           SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, P3, P4, void>,         FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, P3, P4, void>::Type, O> >         createFunctor(R (O::*functionPointer)(P1, P2, P3, P4), OO* object)     { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer, object); }
332    template <class R, class O, class OO, class P1, class P2, class P3>                     SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, P3, void, void>,       FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, P3, void, void>::Type, O> >       createFunctor(R (O::*functionPointer)(P1, P2, P3), OO* object)         { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer, object); }
333    template <class R, class O, class OO, class P1, class P2>                               SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, void, void, void>,     FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, void, void, void>::Type, O> >     createFunctor(R (O::*functionPointer)(P1, P2), OO* object)             { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer, object); }
334    template <class R, class O, class OO, class P1>                                         SharedChildPtr<FunctorTemplate<R, O, false, P1, void, void, void, void>,   FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, void, void, void, void>::Type, O> >   createFunctor(R (O::*functionPointer)(P1), OO* object)                 { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer, object); }
335    template <class R, class O, class OO>                                                   SharedChildPtr<FunctorTemplate<R, O, false, void, void, void, void, void>, FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, void, void, void, void, void>::Type, O> > createFunctor(R (O::*functionPointer)(), OO* object)                   { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer, object); }
336    template <class R, class O, class OO, class P1, class P2, class P3, class P4, class P5> SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>,           FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, P3, P4, P5>::Type, O> >           createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const, OO* object) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer, object); }
337    template <class R, class O, class OO, class P1, class P2, class P3, class P4>           SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, P3, P4, void>,         FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, P3, P4, void>::Type, O> >         createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const, OO* object)     { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer, object); }
338    template <class R, class O, class OO, class P1, class P2, class P3>                     SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, P3, void, void>,       FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, P3, void, void>::Type, O> >       createFunctor(R (O::*functionPointer)(P1, P2, P3) const, OO* object)         { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer, object); }
339    template <class R, class O, class OO, class P1, class P2>                               SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, void, void, void>,     FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, void, void, void>::Type, O> >     createFunctor(R (O::*functionPointer)(P1, P2) const, OO* object)             { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer, object); }
340    template <class R, class O, class OO, class P1>                                         SharedChildPtr<FunctorTemplate<R, O, true, P1, void, void, void, void>,   FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, void, void, void, void>::Type, O> >   createFunctor(R (O::*functionPointer)(P1) const, OO* object)                 { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer, object); }
341    template <class R, class O, class OO>                                                   SharedChildPtr<FunctorTemplate<R, O, true, void, void, void, void, void>, FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, void, void, void, void, void>::Type, O> > createFunctor(R (O::*functionPointer)() const, OO* object)                   { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer, object); }
[1505]342
[7212]343    template <class R, class O, class P1, class P2, class P3, class P4, class P5> SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>,           FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, P3, P4, P5>::Type, O> >           createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, P5>(functionPointer); }
344    template <class R, class O, class P1, class P2, class P3, class P4>           SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, P3, P4, void>,         FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, P3, P4, void>::Type, O> >         createFunctor(R (O::*functionPointer)(P1, P2, P3, P4))     { return new FunctorTemplate<R, O, false, P1, P2, P3, P4, void>(functionPointer); }
345    template <class R, class O, class P1, class P2, class P3>                     SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, P3, void, void>,       FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, P3, void, void>::Type, O> >       createFunctor(R (O::*functionPointer)(P1, P2, P3))         { return new FunctorTemplate<R, O, false, P1, P2, P3, void, void>(functionPointer); }
346    template <class R, class O, class P1, class P2>                               SharedChildPtr<FunctorTemplate<R, O, false, P1, P2, void, void, void>,     FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, P2, void, void, void>::Type, O> >     createFunctor(R (O::*functionPointer)(P1, P2))             { return new FunctorTemplate<R, O, false, P1, P2, void, void, void>(functionPointer); }
347    template <class R, class O, class P1>                                         SharedChildPtr<FunctorTemplate<R, O, false, P1, void, void, void, void>,   FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, P1, void, void, void, void>::Type, O> >   createFunctor(R (O::*functionPointer)(P1))                 { return new FunctorTemplate<R, O, false, P1, void, void, void, void>(functionPointer); }
348    template <class R, class O>                                                   SharedChildPtr<FunctorTemplate<R, O, false, void, void, void, void, void>, FunctorPointerPtr<typename detail::FunctionPointer<R, O, false, void, void, void, void, void>::Type, O> > createFunctor(R (O::*functionPointer)())                   { return new FunctorTemplate<R, O, false, void, void, void, void, void>(functionPointer); }
349    template <class R, class O, class P1, class P2, class P3, class P4, class P5> SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>,           FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, P3, P4, P5>::Type, O> >           createFunctor(R (O::*functionPointer)(P1, P2, P3, P4, P5) const) { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, P5>(functionPointer); }
350    template <class R, class O, class P1, class P2, class P3, class P4>           SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, P3, P4, void>,         FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, P3, P4, void>::Type, O> >         createFunctor(R (O::*functionPointer)(P1, P2, P3, P4) const)     { return new FunctorTemplate<R, O, true, P1, P2, P3, P4, void>(functionPointer); }
351    template <class R, class O, class P1, class P2, class P3>                     SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, P3, void, void>,       FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, P3, void, void>::Type, O> >       createFunctor(R (O::*functionPointer)(P1, P2, P3) const)         { return new FunctorTemplate<R, O, true, P1, P2, P3, void, void>(functionPointer); }
352    template <class R, class O, class P1, class P2>                               SharedChildPtr<FunctorTemplate<R, O, true, P1, P2, void, void, void>,     FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, P2, void, void, void>::Type, O> >     createFunctor(R (O::*functionPointer)(P1, P2) const)             { return new FunctorTemplate<R, O, true, P1, P2, void, void, void>(functionPointer); }
353    template <class R, class O, class P1>                                         SharedChildPtr<FunctorTemplate<R, O, true, P1, void, void, void, void>,   FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, P1, void, void, void, void>::Type, O> >   createFunctor(R (O::*functionPointer)(P1) const)                 { return new FunctorTemplate<R, O, true, P1, void, void, void, void>(functionPointer); }
354    template <class R, class O>                                                   SharedChildPtr<FunctorTemplate<R, O, true, void, void, void, void, void>, FunctorPointerPtr<typename detail::FunctionPointer<R, O, true, void, void, void, void, void>::Type, O> > createFunctor(R (O::*functionPointer)() const)                   { return new FunctorTemplate<R, O, true, void, void, void, void, void>(functionPointer); }
[1505]355
[7212]356    template <class R, class P1, class P2, class P3, class P4, class P5> SharedChildPtr<FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>,           FunctorPointerPtr<typename detail::FunctionPointer<R, void, false, P1, P2, P3, P4, P5>::Type, void> >           createFunctor(R (*functionPointer)(P1, P2, P3, P4, P5)) { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, P5>(functionPointer); }
357    template <class R, class P1, class P2, class P3, class P4>           SharedChildPtr<FunctorTemplate<R, void, false, P1, P2, P3, P4, void>,         FunctorPointerPtr<typename detail::FunctionPointer<R, void, false, P1, P2, P3, P4, void>::Type, void> >         createFunctor(R (*functionPointer)(P1, P2, P3, P4))     { return new FunctorTemplate<R, void, false, P1, P2, P3, P4, void>(functionPointer); }
358    template <class R, class P1, class P2, class P3>                     SharedChildPtr<FunctorTemplate<R, void, false, P1, P2, P3, void, void>,       FunctorPointerPtr<typename detail::FunctionPointer<R, void, false, P1, P2, P3, void, void>::Type, void> >       createFunctor(R (*functionPointer)(P1, P2, P3))         { return new FunctorTemplate<R, void, false, P1, P2, P3, void, void>(functionPointer); }
359    template <class R, class P1, class P2>                               SharedChildPtr<FunctorTemplate<R, void, false, P1, P2, void, void, void>,     FunctorPointerPtr<typename detail::FunctionPointer<R, void, false, P1, P2, void, void, void>::Type, void> >     createFunctor(R (*functionPointer)(P1, P2))             { return new FunctorTemplate<R, void, false, P1, P2, void, void, void>(functionPointer); }
360    template <class R, class P1>                                         SharedChildPtr<FunctorTemplate<R, void, false, P1, void, void, void, void>,   FunctorPointerPtr<typename detail::FunctionPointer<R, void, false, P1, void, void, void, void>::Type, void> >   createFunctor(R (*functionPointer)(P1))                 { return new FunctorTemplate<R, void, false, P1, void, void, void, void>(functionPointer); }
361    template <class R>                                                   SharedChildPtr<FunctorTemplate<R, void, false, void, void, void, void, void>, FunctorPointerPtr<typename detail::FunctionPointer<R, void, false, void, void, void, void, void>::Type, void> > createFunctor(R (*functionPointer)())                   { return new FunctorTemplate<R, void, false, void, void, void, void, void>(functionPointer); }
[1505]362}
363
364#endif /* _Functor_H__ */
Note: See TracBrowser for help on using the repository browser.