[Orxonox-commit 2505] r7212 - in code/branches/consolecommands3/src/libraries: core core/command util
landauf at orxonox.net
landauf at orxonox.net
Tue Aug 24 16:56:37 CEST 2010
Author: landauf
Date: 2010-08-24 16:56:37 +0200 (Tue, 24 Aug 2010)
New Revision: 7212
Modified:
code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
code/branches/consolecommands3/src/libraries/core/XMLPort.h
code/branches/consolecommands3/src/libraries/core/command/Executor.cc
code/branches/consolecommands3/src/libraries/core/command/Executor.h
code/branches/consolecommands3/src/libraries/core/command/Functor.h
code/branches/consolecommands3/src/libraries/core/command/FunctorPtr.h
code/branches/consolecommands3/src/libraries/util/MultiType.h
code/branches/consolecommands3/src/libraries/util/SharedPtr.h
Log:
re-implemented Functor - without macros!
Modified: code/branches/consolecommands3/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/CorePrereqs.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/core/CorePrereqs.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -199,9 +199,11 @@
class ExecutorMember;
class ExecutorStatic;
class Functor;
- template <class T>
+ template <class O>
class FunctorMember;
- class FunctorStatic;
+ typedef FunctorMember<void> FunctorStatic;
+ template <class F, class O>
+ class FunctorPointer;
class IOConsole;
class IRC;
class Shell;
Modified: code/branches/consolecommands3/src/libraries/core/XMLPort.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/XMLPort.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/core/XMLPort.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -109,7 +109,7 @@
You don't have to use this, if there exist only one function with the given name.
*/
#define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
- static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+ static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
@@ -134,7 +134,7 @@
@brief This is the same as XMLPortParamTemplate, but for load-only attributes (see XMLPortParamLoadOnly).
*/
#define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
- static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+ static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
// ------------------
@@ -167,7 +167,7 @@
@brief This is the same as XMLPortParamTemplate, but for extern attributes (see XMLPortParamExtern).
*/
#define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
- static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
+ static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \
static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \
XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
@@ -255,7 +255,7 @@
@brief This is the same as XMLPortObjectExtended, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
*/
#define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
- static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+ static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
@@ -273,7 +273,7 @@
@brief This is the same as XMLPortObject, but you can specify the loadfunction by adding the param types. See XMLPortParamTemplate for more details about the types.
*/
#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \
- static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
+ static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \
static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
Modified: code/branches/consolecommands3/src/libraries/core/command/Executor.cc
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/Executor.cc 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/core/command/Executor.cc 2010-08-24 14:56:37 UTC (rev 7212)
@@ -66,7 +66,7 @@
if (!temp.empty())
{
COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
- return (*this->functor_)(MultiType(params));
+ return (*this->functor_)(params);
}
else if (!this->defaultValue_[0].null())
{
Modified: code/branches/consolecommands3/src/libraries/core/command/Executor.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/Executor.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/core/command/Executor.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -162,22 +162,22 @@
MultiType parse(T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
{
- const typename FunctorMember<T>::Objects& objects = this->functorMember_->getObjects();
+ T* oldobject = this->functorMember_->getObject();
this->functorMember_->setObject(object);
const MultiType& result = this->Executor::parse(params, success, delimiter);
- this->functorMember_->setObjects(objects);
+ this->functorMember_->setObject(oldobject);
return result;
}
MultiType parse(const T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
{
- const typename FunctorMember<T>::Objects& objects = this->functorMember_->getObjects();
+ T* oldobject = this->functorMember_->getObject();
this->functorMember_->setObject(object);
const MultiType& result = this->Executor::parse(params, success, delimiter);
- this->functorMember_->setObjects(objects);
+ this->functorMember_->setObjects(oldobject);
return result;
}
Modified: code/branches/consolecommands3/src/libraries/core/command/Functor.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/Functor.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/core/command/Functor.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -24,7 +24,6 @@
* Co-authors:
* ...
*
- * Inspiration: Functor by Benjamin Grauer
*/
#ifndef _Functor_H__
@@ -44,48 +43,34 @@
const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
template <class T>
- inline std::string typeToString() { return "unknown"; }
+ inline std::string _typeToString() { return "unknown"; }
-#define CreateTypeToStringTemplate(type) \
- template <> \
- inline std::string typeToString<type>() { return #type; } \
- template <> \
- inline std::string typeToString<type&>() { return #type; } \
- template <> \
- inline std::string typeToString<const type>() { return #type; } \
- template <> \
- inline std::string typeToString<const type&>() { return #type; }
+ template <> inline std::string _typeToString<void>() { return ""; }
+ template <> inline std::string _typeToString<int>() { return "int"; }
+ template <> inline std::string _typeToString<unsigned int>() { return "uint"; }
+ template <> inline std::string _typeToString<char>() { return "char"; }
+ template <> inline std::string _typeToString<unsigned char>() { return "uchar"; }
+ template <> inline std::string _typeToString<short>() { return "short"; }
+ template <> inline std::string _typeToString<unsigned short>() { return "ushort"; }
+ template <> inline std::string _typeToString<long>() { return "long"; }
+ template <> inline std::string _typeToString<unsigned long>() { return "ulong"; }
+ template <> inline std::string _typeToString<long long>() { return "longlong"; }
+ template <> inline std::string _typeToString<unsigned long long>() { return "ulonglong"; }
+ template <> inline std::string _typeToString<float>() { return "float"; }
+ template <> inline std::string _typeToString<double>() { return "double"; }
+ template <> inline std::string _typeToString<long double>() { return "longdouble"; }
+ template <> inline std::string _typeToString<bool>() { return "bool"; }
+ template <> inline std::string _typeToString<std::string>() { return "string"; }
+ template <> inline std::string _typeToString<Vector2>() { return "Vector2"; }
+ template <> inline std::string _typeToString<Vector3>() { return "Vector3"; }
+ template <> inline std::string _typeToString<Quaternion>() { return "Quaternion"; }
+ template <> inline std::string _typeToString<ColourValue>() { return "ColourValue"; }
+ template <> inline std::string _typeToString<Radian>() { return "Radian"; }
+ template <> inline std::string _typeToString<Degree>() { return "Degree"; }
- CreateTypeToStringTemplate(int);
- CreateTypeToStringTemplate(unsigned int);
- CreateTypeToStringTemplate(char);
- CreateTypeToStringTemplate(unsigned char);
- CreateTypeToStringTemplate(short);
- CreateTypeToStringTemplate(unsigned short);
- CreateTypeToStringTemplate(long);
- CreateTypeToStringTemplate(unsigned long);
- CreateTypeToStringTemplate(long long);
- CreateTypeToStringTemplate(unsigned long long);
- CreateTypeToStringTemplate(float);
- CreateTypeToStringTemplate(double);
- CreateTypeToStringTemplate(long double);
- CreateTypeToStringTemplate(bool);
- CreateTypeToStringTemplate(Vector2);
- CreateTypeToStringTemplate(Vector3);
- CreateTypeToStringTemplate(Quaternion);
- CreateTypeToStringTemplate(ColourValue);
- CreateTypeToStringTemplate(Radian);
- CreateTypeToStringTemplate(Degree);
+ template <class T>
+ inline std::string typeToString() { return _typeToString<typename Loki::TypeTraits<T>::UnqualifiedReferredType>(); }
- template <>
- inline std::string typeToString<std::string>() { return "string"; }
- template <>
- inline std::string typeToString<std::string&>() { return "string"; }
- template <>
- inline std::string typeToString<const std::string>() { return "string"; }
- template <>
- inline std::string typeToString<const std::string&>() { return "string"; }
-
class _CoreExport Functor
{
public:
@@ -93,17 +78,12 @@
{
enum Enum
{
- Member,
- ConstMember,
Static,
- Lua
+ Member
};
};
public:
- Functor() {}
- virtual ~Functor() {}
-
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;
virtual Type::Enum getType() const = 0;
@@ -118,472 +98,261 @@
virtual void setRawObjectPointer(void* object) {}
virtual void* getRawObjectPointer() const { return 0; }
+ template <class F>
+ inline bool setFunction(F* function)
+ {
+ if (this->getFullIdentifier() == typeid(F*))
+ {
+ modifyFunctor(this, function);
+ return true;
+ }
+ return false;
+ }
+
+ virtual const std::type_info& getFullIdentifier() const = 0;
virtual const std::type_info& getHeaderIdentifier() const = 0;
};
- class _CoreExport FunctorStatic : public Functor
- {
- public:
- virtual ~FunctorStatic() {}
- 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;
- };
-
- template <class T>
+ template <class O>
class FunctorMember : public Functor
{
public:
- FunctorMember()
- {
- this->object_ = 0;
- this->constObject_ = 0;
- }
- virtual ~FunctorMember() {}
+ FunctorMember(O* object = 0) : object_(object) {}
- virtual MultiType operator()(T* 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;
- virtual MultiType operator()(const T* 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;
+ 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;
- 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)
+ 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)
{
if (this->object_)
return (*this)(this->object_, param1, param2, param3, param4, param5);
- else if (this->constObject_)
- return (*this)(this->constObject_, param1, param2, param3, param4, param5);
else
{
- COUT(1) << "An error occurred in Functor.h:" << std::endl;
- COUT(1) << "Error: No object set." << std::endl;
+ COUT(1) << "Error: Can't execute FunctorMember, no object set." << std::endl;
return MT_Type::Null;
}
}
- inline FunctorMember<T>* setObject(T* object)
- {
- this->object_ = object;
- this->constObject_ = 0;
- return this;
- }
+ Functor::Type::Enum getType() const
+ { return Functor::Type::Member; }
- inline FunctorMember<T>* setObject(const T* object)
- {
- this->object_ = 0;
- this->constObject_ = object;
- return this;
- }
+ inline void setObject(O* object)
+ { this->object_ = object;}
+ inline O* getObject() const
+ { return this->object_; }
- void setRawObjectPointer(void* object)
- {
- this->object_ = (T*)object;
- this->constObject_ = 0;
- }
+ inline void setRawObjectPointer(void* object)
+ { this->object_ = (O*)object; }
+ inline void* getRawObjectPointer() const
+ { return this->object_; }
- void* getRawObjectPointer() const
- {
- if (this->object_)
- return (void*)this->object_;
- else
- return (void*)this->constObject_;
- }
+ protected:
+ O* object_;
+ };
- typedef std::pair<T*, const T*> Objects;
+ template <>
+ class _CoreExport FunctorMember<void> : public Functor
+ {
+ public:
+ FunctorMember(void* = 0) {}
- inline Objects getObjects() const
- {
- return Objects(this->object_, this->constObject_);
- }
+ 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;
- inline void setObjects(const Objects& objects)
+ 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)
{
- this->object_ = objects.first;
- this->constObject_ = objects.second;
+ return (*this)(0, param1, param2, param3, param4, param5);
}
- private:
- T* object_;
- const T* constObject_;
+ Functor::Type::Enum getType() const
+ { return Functor::Type::Static; }
};
+ typedef FunctorMember<void> FunctorStatic;
+ template <class F, class O>
+ class FunctorPointer : public FunctorMember<O>
+ {
+ public:
+ FunctorPointer(F functionPointer, O* object = 0) : FunctorMember<O>(object), functionPointer_(functionPointer) {}
- template <class R, class P1, class P2, class P3, class P4, class P5>
- struct FunctorHeaderIdentifier {};
+ inline void setFunction(F functionPointer)
+ { this->functionPointer_ = functionPointer; }
+ inline F getFunction() const
+ { return this->functionPointer_; }
+ const std::type_info& getFullIdentifier() const
+ { return typeid(F); }
+ protected:
+ F functionPointer_;
+ };
- inline const FunctorPtr& createFunctor(const FunctorPtr& functor)
+ namespace detail
{
- return functor;
- }
+ 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); };
+ 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); };
+ 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); };
+ 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); };
+ 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); };
+ template <class R, class O, class P1> struct FunctionPointer<R, O, false, P1, void, void, void, void> { typedef R (O::*Type)(P1); };
+ template <class R, class O> struct FunctionPointer<R, O, false, void, void, void, void, void> { typedef R (O::*Type)(); };
+ 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; };
+ 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; };
+ 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; };
+ 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; };
+ template <class R, class O, class P1> struct FunctionPointer<R, O, true, P1, void, void, void, void> { typedef R (O::*Type)(P1) const; };
+ template <class R, class O> struct FunctionPointer<R, O, true, void, void, void, void, void> { typedef R (O::*Type)() const; };
+ 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); };
+ 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); };
+ 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); };
+ template <class R, class P1, class P2> struct FunctionPointer<R, void, false, P1, P2, void, void, void> { typedef R (*Type)(P1, P2); };
+ template <class R, class P1> struct FunctionPointer<R, void, false, P1, void, void, void, void> { typedef R (*Type)(P1); };
+ template <class R> struct FunctionPointer<R, void, false, void, void, void, void, void> { typedef R (*Type)(); };
+ 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); } };
+ 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); } };
+ 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); } };
+ 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); } };
+ 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); } };
+ 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)(); } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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); } };
+ 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); } };
+ 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); } };
+ 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); } };
+ 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); } };
+ 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)(); } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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; } };
+ 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; } };
+ template <class R, class P1, class P2, class P3, class P4, class P5>
+ struct FunctorHeaderIdentifier
+ {};
-#define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams, additionalobject) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams(additionalobject)
-#define FUNCTOR_TEMPLATE000(additionalobject)
-#define FUNCTOR_TEMPLATE001(additionalobject) template <class P1>
-#define FUNCTOR_TEMPLATE002(additionalobject) template <class P1, class P2>
-#define FUNCTOR_TEMPLATE003(additionalobject) template <class P1, class P2, class P3>
-#define FUNCTOR_TEMPLATE004(additionalobject) template <class P1, class P2, class P3, class P4>
-#define FUNCTOR_TEMPLATE005(additionalobject) template <class P1, class P2, class P3, class P4, class P5>
-#define FUNCTOR_TEMPLATE010(additionalobject) template <class R>
-#define FUNCTOR_TEMPLATE011(additionalobject) template <class R, class P1>
-#define FUNCTOR_TEMPLATE012(additionalobject) template <class R, class P1, class P2>
-#define FUNCTOR_TEMPLATE013(additionalobject) template <class R, class P1, class P2, class P3>
-#define FUNCTOR_TEMPLATE014(additionalobject) template <class R, class P1, class P2, class P3, class P4>
-#define FUNCTOR_TEMPLATE015(additionalobject) template <class R, class P1, class P2, class P3, class P4, class P5>
-#define FUNCTOR_TEMPLATE100(additionalobject) template <class T FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE101(additionalobject) template <class T, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE102(additionalobject) template <class T, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE103(additionalobject) template <class T, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE104(additionalobject) template <class T, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE105(additionalobject) template <class T, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE110(additionalobject) template <class T, class R FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE111(additionalobject) template <class T, class R, class P1 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE112(additionalobject) template <class T, class R, class P1, class P2 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE113(additionalobject) template <class T, class R, class P1, class P2, class P3 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE114(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
-#define FUNCTOR_TEMPLATE115(additionalobject) template <class T, class R, class P1, class P2, class P3, class P4, class P5 FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) >
+ template <typename T>
+ struct FunctorHasReturnvalue
+ { enum { result = true }; };
+ template <>
+ struct FunctorHasReturnvalue<void>
+ { enum { result = false }; };
-
-
-#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT(additionalobject) FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT##additionalobject
-#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT0
-#define FUNCTOR_TEMPLATE_ADDITIONAL_OBJECT1 , class O
-
-
-
-#define FUNCTOR_TEMPLATE_CLASSES(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE_CLASSES##ismember##returnvalue##numparams
-#define FUNCTOR_TEMPLATE_CLASSES000
-#define FUNCTOR_TEMPLATE_CLASSES001 <P1>
-#define FUNCTOR_TEMPLATE_CLASSES002 <P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES003 <P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES004 <P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES005 <P1, P2, P3, P4, P5>
-#define FUNCTOR_TEMPLATE_CLASSES010 <R>
-#define FUNCTOR_TEMPLATE_CLASSES011 <R, P1>
-#define FUNCTOR_TEMPLATE_CLASSES012 <R, P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES013 <R, P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES014 <R, P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES015 <R, P1, P2, P3, P4, P5>
-#define FUNCTOR_TEMPLATE_CLASSES100 <T>
-#define FUNCTOR_TEMPLATE_CLASSES101 <T, P1>
-#define FUNCTOR_TEMPLATE_CLASSES102 <T, P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES103 <T, P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES104 <T, P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES105 <T, P1, P2, P3, P4, P5>
-#define FUNCTOR_TEMPLATE_CLASSES110 <T, R>
-#define FUNCTOR_TEMPLATE_CLASSES111 <T, R, P1>
-#define FUNCTOR_TEMPLATE_CLASSES112 <T, R, P1, P2>
-#define FUNCTOR_TEMPLATE_CLASSES113 <T, R, P1, P2, P3>
-#define FUNCTOR_TEMPLATE_CLASSES114 <T, R, P1, P2, P3, P4>
-#define FUNCTOR_TEMPLATE_CLASSES115 <T, R, P1, P2, P3, P4, P5>
-
-
-
-#define FUNCTOR_TYPENAME_PARAM(numparams) FUNCTOR_TYPENAME_PARAM##numparams
-#define FUNCTOR_TYPENAME_PARAM0 \
- return BLANKSTRING
-#define FUNCTOR_TYPENAME_PARAM1 \
- if (param == 0) { return typeToString<P1>(); } \
- else { return BLANKSTRING; }
-#define FUNCTOR_TYPENAME_PARAM2 \
- if (param == 0) { return typeToString<P1>(); } \
- else if (param == 1) { return typeToString<P2>(); } \
- else { return BLANKSTRING; }
-#define FUNCTOR_TYPENAME_PARAM3 \
- if (param == 0) { return typeToString<P1>(); } \
- else if (param == 1) { return typeToString<P2>(); } \
- else if (param == 2) { return typeToString<P3>(); } \
- else { return BLANKSTRING; }
-#define FUNCTOR_TYPENAME_PARAM4 \
- if (param == 0) { return typeToString<P1>(); } \
- else if (param == 1) { return typeToString<P2>(); } \
- else if (param == 2) { return typeToString<P3>(); } \
- else if (param == 3) { return typeToString<P4>(); } \
- else { return BLANKSTRING; }
-#define FUNCTOR_TYPENAME_PARAM5 \
- if (param == 0) { return typeToString<P1>(); } \
- else if (param == 1) { return typeToString<P2>(); } \
- else if (param == 2) { return typeToString<P3>(); } \
- else if (param == 3) { return typeToString<P4>(); } \
- else if (param == 4) { return typeToString<P5>(); } \
- else { return BLANKSTRING; }
-
-#define FUNCTOR_TYPENAME_RETURN(returnvalue) FUNCTOR_TYPENAME_RETURN##returnvalue
-#define FUNCTOR_TYPENAME_RETURN0 BLANKSTRING
-#define FUNCTOR_TYPENAME_RETURN1 typeToString<R>()
-
-
-
-#define FUNCTOR_FUNCTION_PARAMS(numparams) FUNCTOR_FUNCTION_PARAMS##numparams
-#define FUNCTOR_FUNCTION_PARAMS0
-#define FUNCTOR_FUNCTION_PARAMS1 P1 param1
-#define FUNCTOR_FUNCTION_PARAMS2 P1 param1, P2 param2
-#define FUNCTOR_FUNCTION_PARAMS3 P1 param1, P2 param2, P3 param3
-#define FUNCTOR_FUNCTION_PARAMS4 P1 param1, P2 param2, P3 param3, P4 param4
-#define FUNCTOR_FUNCTION_PARAMS5 P1 param1, P2 param2, P3 param3, P4 param4, P5 param5
-
-#define FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) FUNCTOR_FUNCTION_RETURNVALUE##returnvalue
-#define FUNCTOR_FUNCTION_RETURNVALUE0 void
-#define FUNCTOR_FUNCTION_RETURNVALUE1 R
-
-
-
-#define FUNCTOR_FUNCTION_CALL(numparams) FUNCTOR_FUNCTION_CALL##numparams
-#define FUNCTOR_FUNCTION_CALL0
-#define FUNCTOR_FUNCTION_CALL1 param1
-#define FUNCTOR_FUNCTION_CALL2 param1, param2
-#define FUNCTOR_FUNCTION_CALL3 param1, param2, param3
-#define FUNCTOR_FUNCTION_CALL4 param1, param2, param3, param4
-#define FUNCTOR_FUNCTION_CALL5 param1, param2, param3, param4, param5
-
-#define FUNCTOR_STORE_RETURNVALUE(returnvalue, functioncall) FUNCTOR_STORE_RETURNVALUE##returnvalue(functioncall)
-#define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall; return MT_Type::Null
-#define FUNCTOR_STORE_RETURNVALUE1(functioncall) return functioncall
-
-
-
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams) FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES##numparams(returnvalue)
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES0(returnvalue) <FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), void, void, void, void, void>
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES1(returnvalue) <FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, void, void, void, void>
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES2(returnvalue) <FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, void, void, void>
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES3(returnvalue) <FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, P3, void, void>
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES4(returnvalue) <FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, P3, P4, void>
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES5(returnvalue) <FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue), P1, P2, P3, P4, P5>
-
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE(returnvalue) FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE##returnvalue
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE0 void
-#define FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES_RETURNVALUE1 R
-
-
-
-#define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
-#define FUNCTOR_EVALUATE_PARAM0
-#define FUNCTOR_EVALUATE_PARAM1 \
- if (index == 0) { param.convert<P1>(); }
-#define FUNCTOR_EVALUATE_PARAM2 \
- if (index == 0) { param.convert<P1>(); } \
- else if (index == 1) { param.convert<P2>(); }
-#define FUNCTOR_EVALUATE_PARAM3 \
- if (index == 0) { param.convert<P1>(); } \
- else if (index == 1) { param.convert<P2>(); } \
- else if (index == 2) { param.convert<P3>(); }
-#define FUNCTOR_EVALUATE_PARAM4 \
- if (index == 0) { param.convert<P1>(); } \
- else if (index == 1) { param.convert<P2>(); } \
- else if (index == 2) { param.convert<P3>(); } \
- else if (index == 3) { param.convert<P4>(); }
-#define FUNCTOR_EVALUATE_PARAM5 \
- if (index == 0) { param.convert<P1>(); } \
- else if (index == 1) { param.convert<P2>(); } \
- else if (index == 2) { param.convert<P3>(); } \
- else if (index == 3) { param.convert<P4>(); } \
- else if (index == 4) { param.convert<P5>(); }
-
-
-
-
-#define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
- FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
- class FunctorStatic##returnvalue##numparams : public FunctorStatic \
- { \
- public: \
- FunctorStatic##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
- { \
- this->functionPointer_ = functionPointer; \
- } \
- \
- 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) \
- { \
- FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
- } \
- \
- void evaluateParam(unsigned int index, MultiType& param) const \
- { \
- FUNCTOR_EVALUATE_PARAM(numparams); \
- } \
- \
- Functor::Type::Enum getType() const { return Functor::Type::Static; } \
- unsigned int getParamCount() const { return numparams; } \
- bool hasReturnvalue() const { return returnvalue; } \
- std::string getTypenameParam(unsigned int param) const { FUNCTOR_TYPENAME_PARAM(numparams); } \
- std::string getTypenameReturnvalue() const { return FUNCTOR_TYPENAME_RETURN(returnvalue); } \
- \
- const std::type_info& getHeaderIdentifier() const \
- { \
- return typeid(FunctorHeaderIdentifier FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams)); \
- } \
- \
- private: \
- FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
- }; \
- \
- \
- FUNCTOR_TEMPLATE(0, returnvalue, numparams, 0) \
- inline SharedChildPtr<FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams), FunctorStaticPtr> createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
- { \
- return new FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams) (functionPointer); \
+ template <class P1, class P2, class P3, class P4, class P5>
+ struct FunctorParamCount
+ { enum { result = 5 }; };
+ template <class P1, class P2, class P3, class P4>
+ struct FunctorParamCount<P1, P2, P3, P4, void>
+ { enum { result = 4 }; };
+ template <class P1, class P2, class P3>
+ struct FunctorParamCount<P1, P2, P3, void, void>
+ { enum { result = 3 }; };
+ template <class P1, class P2>
+ struct FunctorParamCount<P1, P2, void, void, void>
+ { enum { result = 2 }; };
+ template <class P1>
+ struct FunctorParamCount<P1, void, void, void, void>
+ { enum { result = 1 }; };
+ template <>
+ struct FunctorParamCount<void, void, void, void, void>
+ { enum { result = 0 }; };
}
+ template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5>
+ class FunctorTemplate : public FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>
+ {
+ public:
+ 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) {}
+ 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)
+ {
+ return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
+ }
+ void evaluateParam(unsigned int index, MultiType& param) const
+ {
+ switch (index)
+ {
+ case 0: param.convert<P1>(); break;
+ case 1: param.convert<P2>(); break;
+ case 2: param.convert<P3>(); break;
+ case 3: param.convert<P4>(); break;
+ case 4: param.convert<P5>(); break;
+ }
+ }
+ unsigned int getParamCount() const
+ {
+ return detail::FunctorParamCount<P1, P2, P3, P4, P5>::result;
+ }
-#define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \
- FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
- class FunctorMember##returnvalue##numparams : public FunctorMember<T> \
- { \
- public: \
- FunctorMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
- { \
- this->functionPointer_ = functionPointer; \
- } \
- \
- MultiType operator()(T* 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) \
- { \
- FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
- } \
- \
- MultiType operator()(const T* 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) \
- { \
- COUT(1) << "An error occurred in Functor.h:" << std::endl; \
- COUT(1) << "Error: Function is not const." << std::endl; \
- return MT_Type::Null; \
- } \
- \
- void evaluateParam(unsigned int index, MultiType& param) const \
- { \
- FUNCTOR_EVALUATE_PARAM(numparams); \
- } \
- \
- Functor::Type::Enum getType() const { return Functor::Type::Member; } \
- unsigned int getParamCount() const { return numparams; } \
- bool hasReturnvalue() const { return returnvalue; } \
- std::string getTypenameParam(unsigned int param) const { FUNCTOR_TYPENAME_PARAM(numparams); } \
- std::string getTypenameReturnvalue() const { return FUNCTOR_TYPENAME_RETURN(returnvalue); } \
- \
- const std::type_info& getHeaderIdentifier() const \
- { \
- return typeid(FunctorHeaderIdentifier FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams)); \
- } \
- \
- private: \
- FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
- }; \
- \
- \
- FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
- class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \
- { \
- public: \
- FunctorConstMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
- { \
- this->functionPointer_ = functionPointer; \
- } \
- \
- MultiType operator()(T* 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) \
- { \
- FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
- } \
- \
- MultiType operator()(const T* 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) \
- { \
- FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
- } \
- \
- void evaluateParam(unsigned int index, MultiType& param) const \
- { \
- FUNCTOR_EVALUATE_PARAM(numparams); \
- } \
- \
- Functor::Type::Enum getType() const { return Functor::Type::ConstMember; } \
- unsigned int getParamCount() const { return numparams; } \
- bool hasReturnvalue() const { return returnvalue; } \
- std::string getTypenameParam(unsigned int param) const { FUNCTOR_TYPENAME_PARAM(numparams); } \
- std::string getTypenameReturnvalue() const { return FUNCTOR_TYPENAME_RETURN(returnvalue); } \
- \
- const std::type_info& getHeaderIdentifier() const \
- { \
- return typeid(FunctorHeaderIdentifier FUNCTOR_HEADER_IDENTIFIER_TEMPLATE_CLASSES(returnvalue, numparams)); \
- } \
- \
- private: \
- FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)) const; \
- }; \
- \
- \
- FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
- inline SharedChildPtr<FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
- { \
- return new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
- } \
- \
- \
- FUNCTOR_TEMPLATE(1, returnvalue, numparams, 0) \
- inline SharedChildPtr<FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
- { \
- return new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
- } \
- \
- FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
- inline SharedChildPtr<FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)), O* object) \
- { \
- FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
- functor->setObject(object); \
- return functor; \
- } \
- \
- \
- FUNCTOR_TEMPLATE(1, returnvalue, numparams, 1) \
- inline SharedChildPtr<FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams), FunctorMemberPtr<T> > createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const, O* object) \
- { \
- FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* functor = new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
- functor->setObject(object); \
- return functor; \
- }
+ bool hasReturnvalue() const
+ {
+ return detail::FunctorHasReturnvalue<R>::result;
+ }
+ std::string getTypenameParam(unsigned int param) const
+ {
+ switch (param)
+ {
+ case 0: return typeToString<P1>();
+ case 1: return typeToString<P2>();
+ case 2: return typeToString<P3>();
+ case 3: return typeToString<P4>();
+ case 4: return typeToString<P5>();
+ default: return "";
+ }
+ }
+ std::string getTypenameReturnvalue() const
+ {
+ return typeToString<R>();
+ }
-// disable annoying warning about forcing value to boolean
-#ifdef ORXONOX_COMPILER_MSVC
-#pragma warning(push)
-#pragma warning(disable:4100 4800)
-#endif
+ const std::type_info& getHeaderIdentifier() const
+ {
+ return typeid(detail::FunctorHeaderIdentifier<R, P1, P2, P3, P4, P5>);
+ }
+ };
-#define CREATE_ALL_STATIC_FUNCTORS() \
- CREATE_STATIC_FUNCTOR(0, 0); \
- CREATE_STATIC_FUNCTOR(0, 1); \
- CREATE_STATIC_FUNCTOR(0, 2); \
- CREATE_STATIC_FUNCTOR(0, 3); \
- CREATE_STATIC_FUNCTOR(0, 4); \
- CREATE_STATIC_FUNCTOR(0, 5); \
- CREATE_STATIC_FUNCTOR(1, 0); \
- CREATE_STATIC_FUNCTOR(1, 1); \
- CREATE_STATIC_FUNCTOR(1, 2); \
- CREATE_STATIC_FUNCTOR(1, 3); \
- CREATE_STATIC_FUNCTOR(1, 4); \
- CREATE_STATIC_FUNCTOR(1, 5)
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
-#define CREATE_ALL_MEMBER_FUNCTORS() \
- CREATE_MEMBER_FUNCTOR(0, 0); \
- CREATE_MEMBER_FUNCTOR(0, 1); \
- CREATE_MEMBER_FUNCTOR(0, 2); \
- CREATE_MEMBER_FUNCTOR(0, 3); \
- CREATE_MEMBER_FUNCTOR(0, 4); \
- CREATE_MEMBER_FUNCTOR(0, 5); \
- CREATE_MEMBER_FUNCTOR(1, 0); \
- CREATE_MEMBER_FUNCTOR(1, 1); \
- CREATE_MEMBER_FUNCTOR(1, 2); \
- CREATE_MEMBER_FUNCTOR(1, 3); \
- CREATE_MEMBER_FUNCTOR(1, 4); \
- CREATE_MEMBER_FUNCTOR(1, 5)
-
-
- CREATE_ALL_STATIC_FUNCTORS();
- CREATE_ALL_MEMBER_FUNCTORS();
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
+ 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); }
}
-#ifdef ORXONOX_COMPILER_MSVC
-#pragma warning(pop)
-#endif
-
#endif /* _Functor_H__ */
Modified: code/branches/consolecommands3/src/libraries/core/command/FunctorPtr.h
===================================================================
--- code/branches/consolecommands3/src/libraries/core/command/FunctorPtr.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/core/command/FunctorPtr.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -36,8 +36,6 @@
{
typedef SharedPtr<Functor> FunctorPtr;
- typedef SharedChildPtr<FunctorStatic, FunctorPtr> FunctorStaticPtr;
-
template <class T>
class FunctorMemberPtr : public SharedChildPtr<FunctorMember<T>, FunctorPtr>
{
@@ -46,6 +44,17 @@
inline FunctorMemberPtr(FunctorMember<T>* pointer) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(pointer) {}
inline FunctorMemberPtr(const SharedPtr<FunctorMember<T> >& other) : SharedChildPtr<FunctorMember<T>, FunctorPtr>(other) {}
};
+
+ typedef FunctorMemberPtr<void> FunctorStaticPtr;
+
+ template <class F, class T>
+ class FunctorPointerPtr : public SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >
+ {
+ public:
+ inline FunctorPointerPtr() : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >() {}
+ inline FunctorPointerPtr(FunctorPointer<F, T>* pointer) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(pointer) {}
+ inline FunctorPointerPtr(const SharedPtr<FunctorPointer<F, T> >& other) : SharedChildPtr<FunctorPointer<F, T>, FunctorMemberPtr<T> >(other) {}
+ };
}
#endif /* _FunctorPtr_H__ */
Modified: code/branches/consolecommands3/src/libraries/util/MultiType.h
===================================================================
--- code/branches/consolecommands3/src/libraries/util/MultiType.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/util/MultiType.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -492,6 +492,8 @@
template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } /** @brief Returns true if the current type equals the given type. */
template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::convert<void>() { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */
+
// Specialization to avoid ambiguities with the conversion operator
template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } /** @brief Converts the current value to the given type. */
template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } /** @brief Converts the current value to the given type. */
Modified: code/branches/consolecommands3/src/libraries/util/SharedPtr.h
===================================================================
--- code/branches/consolecommands3/src/libraries/util/SharedPtr.h 2010-08-24 14:01:43 UTC (rev 7211)
+++ code/branches/consolecommands3/src/libraries/util/SharedPtr.h 2010-08-24 14:56:37 UTC (rev 7212)
@@ -136,6 +136,11 @@
return *this->pointer_;
}
+ inline T* get() const
+ {
+ return this->pointer_;
+ }
+
inline operator bool() const
{
return (this->pointer_ != 0);
More information about the Orxonox-commit
mailing list