/*! * @file executor_generic.h * Definition of a Generic Executor */ /* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #ifndef __EXECUTOR_GENERIC_H_ #define __EXECUTOR_GENERIC_H_ #include "executor.h" /** * @brief this is a Template Class used as an evaluater. * * Trait to determine a default Value for any Type, * and to define the Convertible, and how it is transformed into the * corresponding SubTypes over the operator(). * * This Class must be reimplemented for each Convertible and all of its * conversion-members. * * e.g: Convertible SubSting, that splits up into many Stings * conversion-members: (int) can be transformed from a String. */ template class ExecutorEvaluater { public: /** @brief Executes the Evaluater * @param CallValue the Value that should be converted * @param defaults the default Values. */ template ToType operator()(FromType& CallValue, const MultiType* const defaults) { return defaultValue; } static FromType& defaultValue() { static FromType defaultValue; return defaultValue; }; }; #endif /* __EXECUTOR_GENERIC_H_ */ #ifdef __EXECUTOR_FUNCTIONAL_NAME /////////// //// 0 //// /////////// //! @brief ExecutorClass, that can execute Functions without any parameters. template class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor { private: /** @brief the FunctioPointer. */ void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST; public: /** * @brief constructs the Executor. * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. */ __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST ) : Executor(false, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) { this->functionPointer = functionPointer; }; /** * @brief executes the Functional * @param object the Object the action should be executed on. * @param eval the CallType to get the Parameters from. */ virtual void operator()(BaseObject* object, CallType& eval = Evaluater::defaultValue()) const { (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); }; /** * @brief copies the Executor * @returns a new Executor that's a copy of this one. */ virtual Executor* clone() const { return new __EXECUTOR_FUNCTIONAL_NAME(0)(this->functionPointer); }; }; /////////// //// 1 //// /////////// //! @brief ExecutorClass, that can execute Functions with one parameter. template class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor { private: /** @brief the FunctioPointer. */ void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST; public: /** * @brief constructs the Executor. * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. */ __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) : Executor(false, ExecutorParamType(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) { this->functionPointer = functionPointer; }; /** * @brief executes the Functional * @param object the Object the action should be executed on. * @param eval the CallType to get the Parameters from. */ virtual void operator()(BaseObject* object, CallType& eval = Evaluater::defaultValue()) const { (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( Evaluater().template operator()(eval, this->defaultValue)); }; /** * @brief copies the Executor * @returns a new Executor that's a copy of this one. */ virtual Executor* clone() const { return new __EXECUTOR_FUNCTIONAL_NAME(1)(this->functionPointer); }; }; /////////// //// 2 //// /////////// //! @brief ExecutorClass, that can execute Functions with two parameters. template class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor { private: /** @brief the FunctioPointer. */ void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST; public: /** * @brief constructs the Executor. * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. */ __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) : Executor(false, ExecutorParamType(), ExecutorParamType(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) { this->functionPointer = functionPointer; }; /** * @brief executes the Functional * @param object the Object the action should be executed on. * @param eval the CallType to get the Parameters from. */ virtual void operator()(BaseObject* object, CallType& eval = Evaluater::defaultValue()) const { (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue)); }; /** * @brief copies the Executor * @returns a new Executor that's a copy of this one. */ virtual Executor* clone() const { return new __EXECUTOR_FUNCTIONAL_NAME(2)(this->functionPointer); }; }; /////////// //// 3 //// /////////// //! @brief ExecutorClass, that can execute Functions with three parameters. template class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor { private: /** @brief the FunctioPointer. */ void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST; public: /** * @brief constructs the Executor. * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. */ __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) : Executor(false, ExecutorParamType(), ExecutorParamType(), ExecutorParamType(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) { this->functionPointer = functionPointer; }; /** * @brief executes the Functional * @param object the Object the action should be executed on. * @param eval the CallType to get the Parameters from. */ virtual void operator()(BaseObject* object, CallType& eval = Evaluater::defaultValue()) const { (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue)); }; /** * @brief copies the Executor * @returns a new Executor that's a copy of this one. */ virtual Executor* clone() const { return new __EXECUTOR_FUNCTIONAL_NAME(3)(this->functionPointer); }; }; /////////// //// 4 //// /////////// //! @brief ExecutorClass, that can execute Functions with four parameters. template class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor { private: /** @brief the FunctioPointer. */ void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST; public: /** * @brief constructs the Executor. * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. */ __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) : Executor(false, ExecutorParamType(), ExecutorParamType(), ExecutorParamType(), ExecutorParamType(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) { this->functionPointer = functionPointer; }; /** * @brief executes the Functional * @param object the Object the action should be executed on. * @param eval the CallType to get the Parameters from. */ virtual void operator()(BaseObject* object, CallType& eval = Evaluater::defaultValue()) const { (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue)); }; /** * @brief copies the Executor * @returns a new Executor that's a copy of this one. */ virtual Executor* clone() const { return new __EXECUTOR_FUNCTIONAL_NAME(4)(this->functionPointer); }; }; /////////// //// 5 //// /////////// //! @brief ExecutorClass, that can execute Functions with five parameters. template class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor { private: /** @brief the FunctioPointer. */ void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST; public: /** * @brief constructs the Executor. * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. */ __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) : Executor(false, ExecutorParamType(), ExecutorParamType(), ExecutorParamType(), ExecutorParamType(), ExecutorParamType(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE) { this->functionPointer = functionPointer; }; /** * @brief executes the Functional * @param object the Object the action should be executed on. * @param eval the CallType to get the Parameters from. */ virtual void operator()(BaseObject* object, CallType& eval = Evaluater::defaultValue()) const { (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue), Evaluater().template operator()(eval, this->defaultValue)); }; /** * @brief copies the Executor * @returns a new Executor that's a copy of this one. */ virtual Executor* clone() const { return new __EXECUTOR_FUNCTIONAL_NAME(5)(this->functionPointer); }; }; #endif /* __EXECUTOR_FUNCTIONAL_NAME */