Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9737 in orxonox.OLD for branches/new_class_id/src


Ignore:
Timestamp:
Sep 16, 2006, 12:39:23 PM (18 years ago)
Author:
bensch
Message:

split it up

Location:
branches/new_class_id/src/lib/util/executor
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/executor/executor.h

    r9735 r9737  
    4444  //! an enumerator for the definition of the Type.
    4545  typedef enum {
    46     FunctionDefault,     //!< The function is neither Static nor Constant
     46    FunctionMember,      //!< The function is neither Static nor Constant
    4747    FunctionStatic,      //!< The Function is Static and pointing to either a Static Member or a C-style function.
    48     FunctionConst,      //!< The Function is Constant and pointing to a Member that does not change the Object.
     48    FunctionConstMember, //!< The Function is Constant and pointing to a Member that does not change the Object.
    4949  } FunctionType;
    5050
     
    109109protected:
    110110  //! Now follows a List of Executor Constructors, to be fast in creating.
    111   Executor(bool hasRetVal, FunctionType functionType = FunctionDefault)
     111  Executor(bool hasRetVal, FunctionType functionType = FunctionMember)
    112112  : bRetVal(hasRetVal), paramCount(0), functionType(functionType)
    113113  { };
    114114
    115115  Executor(bool hasRetVal, const MultiType& param0,
    116            FunctionType functionType = FunctionDefault)
     116           FunctionType functionType = FunctionMember)
    117117  : bRetVal(hasRetVal), paramCount(1), functionType(functionType)
    118118  {
     
    121121
    122122  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    123            FunctionType functionType = FunctionDefault)
     123           FunctionType functionType = FunctionMember)
    124124  : bRetVal(hasRetVal), paramCount(2), functionType(functionType)
    125125  {
     
    130130  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    131131           const MultiType& param2,
    132            FunctionType functionType = FunctionDefault)
     132           FunctionType functionType = FunctionMember)
    133133  : bRetVal(hasRetVal), paramCount(3), functionType(functionType)
    134134  {
     
    140140  Executor(bool hasRetVal, const MultiType& param0, const MultiType& param1,
    141141           const MultiType& param2, const MultiType& param3,
    142            FunctionType functionType = FunctionDefault)
     142           FunctionType functionType = FunctionMember)
    143143  : bRetVal(hasRetVal), paramCount(4), functionType(functionType)
    144144  {
     
    152152           const MultiType& param2, const MultiType& param3,
    153153           const MultiType& param4,
    154            FunctionType functionType = FunctionDefault)
     154           FunctionType functionType = FunctionMember)
    155155  : bRetVal(hasRetVal), paramCount(5), functionType(functionType)
    156156  {
     
    165165           const MultiType& param2, const MultiType& param3,
    166166           const MultiType& param4, const MultiType& param5,
    167            FunctionType functionType = FunctionDefault)
     167           FunctionType functionType = FunctionMember)
    168168  : bRetVal(hasRetVal), paramCount(6), functionType(functionType)
    169169  {
     
    180180           const MultiType& param4, const MultiType& param5,
    181181           const MultiType& param6,
    182            FunctionType functionType = FunctionDefault)
     182           FunctionType functionType = FunctionMember)
    183183  : bRetVal(hasRetVal), paramCount(7), functionType(functionType)
    184184  {
  • branches/new_class_id/src/lib/util/executor/executor_functional.h

    r9736 r9737  
    118118//! The Function-Pointer, and how to save it internally.
    119119#define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER   T::*functionPointer
    120 #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionDefault
     120#define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionMember
    121121
    122122#ifdef EXECUTOR_FUNCTIONAL_USE_CONST            //! USING CONST FUNCTIONALS
     
    129129 #define __EXECUTOR_FUNCTIONAL_CONST const
    130130 #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    131  #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionConst
     131 #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionConstMember
    132132 #undef __EXECUTOR_FUNCTIONAL_NAME
    133133 #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_const
  • branches/new_class_id/src/lib/util/executor/executor_generic.h

    r9736 r9737  
    11/*!
    2  * @file executor_functional.h
    3  * Definition of an Executor
     2 * @file executor_generic.h
     3 * Definition of a Generic Executor
    44 */
    55
     
    2020
    2121
    22 #ifndef __EXECUTOR_FUNCTIONAL_H_
    23 #define __EXECUTOR_FUNCTIONAL_H_
     22#ifndef __EXECUTOR_GENERIC_H_
     23#define __EXECUTOR_GENERIC_H_
    2424
    2525#include "executor.h"
     
    106106
    107107
    108 
    109 
    110 #endif /* __EXECUTOR_FUNCTIONAL_H_ */
    111 
    112 //! if Functional is constant calling
    113 #define __EXECUTOR_FUNCTIONAL_CONST
    114 //! The Name to be attached to the functional (for normal, static, and const modes)
    115 #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount)   Executor##ParamCount##Params
    116 //! The Execution-mode (either static or objective)
    117 #define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC      dynamic_cast<T*>(object)->*(functionPointer)
    118 //! The Function-Pointer, and how to save it internally.
    119 #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER   T::*functionPointer
    120 #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionDefault
    121 
    122 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST            //! USING CONST FUNCTIONALS
    123  #ifdef __EXECUTOR_FUNCTIONAL_CONST_INCLUDED    //!< CHECK IF ALREADY INCLUED CONST FUNCTIONALS
    124   #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    125  #else
    126   #define __EXECUTOR_FUNCTIONAL_CONST_INCLUDED
    127  #endif
    128  #undef __EXECUTOR_FUNCTIONAL_CONST
    129  #define __EXECUTOR_FUNCTIONAL_CONST const
    130  #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    131  #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionConst
    132  #undef __EXECUTOR_FUNCTIONAL_NAME
    133  #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_const
    134 //#endif /* EXECUTOR_FUNCTIONAL_USE_CONST */
    135 
    136 #elif defined EXECUTOR_FUNCTIONAL_USE_STATIC
    137  #ifdef EXECUTOR_FUNCTIONAL_USE_CONST
    138   #error you obviously do not know what you are doing !! ask the bensch
    139  #endif
    140 
    141 #ifdef __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
    142    #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    143   #else
    144    #define __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
    145   #endif
    146 
    147 #undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC
    148  #define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC       functionPointer
    149  #undef __EXECUTOR_FUNCTIONAL_NAME
    150  #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount)    Executor##ParamCount##Params_static
    151  #undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER
    152  #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER    *functionPointer
    153  #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    154  #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionStatic
    155 
    156 //#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    157 #else
    158  #ifdef __EXECUTOR_FUNCTIONAL_PLAIN_INCLUDED
    159   #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    160  #else
    161   #define __EXECUTOR_FUNCTIONAL_PLAIN_INCLUDED
    162  #endif
    163 #endif
    164 
    165 #ifndef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    166 
    167 
    168 
    169 
    170108///////////
    171109//// 0 ////
     
    456394};
    457395
    458 
    459 
    460 
    461 
    462 
    463 
    464 
    465 
    466 // // // // // // // // // // // // //
    467 //// EXTENSION TO HIDE CONSTRUCT /////
    468 // // // // // // // // // // // // //
    469 /**
    470  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    471  */
    472 #define EXECUTOR_FUNCTIONAL_CREATOR0() \
    473 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
    474 { \
    475   return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, const SubString>(functionPointer); \
    476 }
    477 
    478 /**
    479  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    480  * @param type0 for internal usage: the first Argument
    481  */
    482 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \
    483 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) \
    484 { \
    485   return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, const SubString, type0>(functionPointer); \
    486 }
    487 
    488 /**
    489  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    490  * @param type0 for internal usage: the first Argument
    491  * @param type1 for internal usage: the second Argument
    492  */
    493 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \
    494 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) \
    495 { \
    496   return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, const SubString, type0, type1>(functionPointer); \
    497 }
    498 
    499 /**
    500  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    501  * @param type0 for internal usage: the first Argument
    502  * @param type1 for internal usage: the second Argument
    503  * @param type2 for internal usage: the third Argument
    504  */
    505 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \
    506 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) \
    507 { \
    508   return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, const SubString, type0, type1, type2>(functionPointer); \
    509 }
    510 
    511 /**
    512  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    513  * @param type0 for internal usage: the first Argument
    514  * @param type1 for internal usage: the second Argument
    515  * @param type2 for internal usage: the third Argument
    516  * @param type3 for internal usage: the fourth Argument
    517  */
    518 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \
    519 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) \
    520 { \
    521   return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, const SubString, type0, type1, type2, type3>(functionPointer); \
    522 }
    523 
    524 /**
    525  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    526  * @param type0 for internal usage: the first Argument
    527  * @param type1 for internal usage: the second Argument
    528  * @param type2 for internal usage: the third Argument
    529  * @param type3 for internal usage: the fourth Argument
    530  * @param type4 for internal usage: the fifth Argument
    531  */
    532 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \
    533 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) \
    534 { \
    535     return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, const SubString, type0, type1, type2, type3, type4>(functionPointer); \
    536 }
    537 
    538 
    539 /**
    540  * Creates the FunctionCallers
    541  */
    542 #define FUNCTOR_LIST(x) EXECUTOR_FUNCTIONAL_CREATOR ## x
    543 #include "functor_list.h"
    544 #undef FUNCTOR_LIST
    545 
    546 
    547 
    548 #undef __EXECUTOR_FUNCTIONAL_CONST
    549 #undef __EXECUTOR_FUNCTIONAL_NAME
    550 #undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC
    551 #undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER
    552 #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    553 
    554 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST
    555  #undef EXECUTOR_FUNCTIONAL_USE_CONST
    556 #endif
    557 #ifdef EXECUTOR_FUNCTIONAL_USE_STATIC
    558  #undef EXECUTOR_FUNCTIONAL_USE_STATIC
    559 #endif
    560 
    561 
    562 #endif /* __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS */
    563 #undef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
     396#ifndef __EXECUTOR_GENERIC_H_
  • branches/new_class_id/src/lib/util/executor/executor_member.h

    r9736 r9737  
    11/*!
    2  * @file executor_functional.h
    3  * Definition of an Executor
     2 * @file executor_member.h
     3 * Definition of an Executor to Member Functions
    44 */
    5 
    65/*
    76   orxonox - the future of 3D-vertical-scrollers
     
    2019
    2120
    22 #ifndef __EXECUTOR_FUNCTIONAL_H_
    23 #define __EXECUTOR_FUNCTIONAL_H_
     21#ifndef __EXECUTOR_MEMBER_H_
     22#define __EXECUTOR_MEMBER_H_
    2423
    25 #include "executor.h"
    26 #include "substring.h"
     24/// Define all Constructs, that define an Executor.
    2725
    28 
    29 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
    30 template<> bool fromString<bool>(const std::string& input, bool defaultValue);
    31 template<> int fromString<int>(const std::string& input, int defaultValue);
    32 template<> unsigned int fromString<unsigned int>(const std::string& input, unsigned int defaultValue);
    33 template<> float fromString<float>(const std::string& input, float defaultValue);
    34 template<> char fromString<char>(const std::string& input, char defaultValue);
    35 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
    36 
    37 template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
    38 template<> bool fromMulti<bool>(const MultiType& multi);
    39 template<> int fromMulti<int>(const MultiType& multi);
    40 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);
    41 template<> float fromMulti<float>(const MultiType& multi);
    42 template<> char fromMulti<char>(const MultiType& multi);
    43 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
    44 
    45 
    46 template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
    47 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i);
    48 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i);
    49 template<> unsigned int getDefault<unsigned int>(const MultiType* const defaultValues, unsigned int i);
    50 template<> float getDefault<float>(const MultiType* const defaultValues, unsigned int i);
    51 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i);
    52 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i);
    53 
    54 
    55 /**
    56  * @brief this is a Template Class used as an evaluater.
    57  *
    58  * Trait to determine a default Value for any Type,
    59  * and to define the Convertible, and how it is transformed into the
    60  * corresponding SubTypes over the operator().
    61  *
    62  * This Class must be reimplemented for each Convertible and all of its
    63  *  conversion-members.
    64  *
    65  * e.g: Convertible SubSting, that splits up into many Stings
    66  *      conversion-members: (int) can be transformed from a String.
    67  */
    68 template<typename FromType> class ExecutorEvaluater
    69 {
    70 public:
    71   /** @brief Executes the Evaluater
    72    * @param CallValue the Value that should be converted
    73    * @param defaults the default Values.
    74    */
    75   template <typename ToType, int index>
    76   ToType operator()(FromType& CallValue, const MultiType* const defaults)
    77   {
    78     return defaultValue; /*(CallValue.size() > index) ?
    79            fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) :
    80     fromMulti<ToType>(defaults[index]); */
    81   }
    82   static FromType& defaultValue() { return FromType(); };
    83 };
    84 
    85 /**
    86  * @brief to remove writing errors, this function is Used.
    87  * @param sub The SubString to use
    88  * @param default The default Values.
    89  */
    90 template<> class ExecutorEvaluater <const SubString>
    91 {
    92 public:
    93   /** @brief Executes the Evaluater
    94    * @param CallValue the Value that should be converted
    95    * @param defaults the default Values.
    96    */
    97   template <typename ToType, int index>
    98   ToType operator()(const SubString& CallValue, const MultiType* const defaults)
    99   {
    100     return (CallValue.size() > index) ?
    101            fromString<ToType>(CallValue[index], getDefault<ToType>(defaults, index)) :
    102            fromMulti<ToType>(defaults[index]);
    103   }
    104   static const SubString& defaultValue() { return SubString::NullSubString; };
    105 };
    106 
    107 
    108 
    109 
    110 #endif /* __EXECUTOR_FUNCTIONAL_H_ */
     26//! The Name to be attached to the functional (for normal, static, and const modes)
     27#define __EXECUTOR_FUNCTIONAL_NAME(ParamCount)   Executor##ParamCount##Params
    11128
    11229//! if Functional is constant calling
    11330#define __EXECUTOR_FUNCTIONAL_CONST
    114 //! The Name to be attached to the functional (for normal, static, and const modes)
    115 #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount)   Executor##ParamCount##Params
    11631//! The Execution-mode (either static or objective)
    11732#define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC      dynamic_cast<T*>(object)->*(functionPointer)
    11833//! The Function-Pointer, and how to save it internally.
    11934#define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER   T::*functionPointer
     35//! The Type of Function
    12036#define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionDefault
    12137
    122 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST            //! USING CONST FUNCTIONALS
    123  #ifdef __EXECUTOR_FUNCTIONAL_CONST_INCLUDED    //!< CHECK IF ALREADY INCLUED CONST FUNCTIONALS
    124   #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    125  #else
    126   #define __EXECUTOR_FUNCTIONAL_CONST_INCLUDED
    127  #endif
    128  #undef __EXECUTOR_FUNCTIONAL_CONST
    129  #define __EXECUTOR_FUNCTIONAL_CONST const
    130  #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    131  #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionConst
    132  #undef __EXECUTOR_FUNCTIONAL_NAME
    133  #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_const
    134 //#endif /* EXECUTOR_FUNCTIONAL_USE_CONST */
    13538
    136 #elif defined EXECUTOR_FUNCTIONAL_USE_STATIC
    137  #ifdef EXECUTOR_FUNCTIONAL_USE_CONST
    138   #error you obviously do not know what you are doing !! ask the bensch
    139  #endif
     39/// We want to include __EXECUTOR_GENERIC_H again, with current settings.
     40#ifdef __EXECUTOR_GENERIC_H
     41#undef __EXECUTOR_GENERIC_H
     42#include "executor_generic.h"
    14043
    141 #ifdef __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
    142    #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    143   #else
    144    #define __EXECUTOR_FUNCTIONAL_STATIC_INCLUDED
    145   #endif
    146 
    147 #undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC
    148  #define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC       functionPointer
    149  #undef __EXECUTOR_FUNCTIONAL_NAME
    150  #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount)    Executor##ParamCount##Params_static
    151  #undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER
    152  #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER    *functionPointer
    153  #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    154  #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionStatic
    155 
    156 //#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    157 #else
    158  #ifdef __EXECUTOR_FUNCTIONAL_PLAIN_INCLUDED
    159   #define __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    160  #else
    161   #define __EXECUTOR_FUNCTIONAL_PLAIN_INCLUDED
    162  #endif
    163 #endif
    164 
    165 #ifndef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    166 
    167 
    168 
    169 
    170 ///////////
    171 //// 0 ////
    172 ///////////
    173 //! @brief ExecutorClass, that can execute Functions without any parameters.
    174 template<class T, typename CallType, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
    175 class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor<CallType, BaseClass>
    176 {
    177 private:
    178   /** @brief the FunctioPointer. */
    179   void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST;
    180 
    181 public:
    182   /**
    183    * @brief constructs the Executor.
    184    * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
    185    */
    186   __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST )
    187       : Executor<CallType, BaseClass>(false, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    188   {
    189     this->functionPointer = functionPointer;
    190   };
    191 
    192   /**
    193    * @brief executes the Functional
    194    * @param object the Object the action should be executed on.
    195    * @param sub the SubString to get the Parameters from.
    196    */
    197   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    198   {
    199     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
    200   };
    201 
    202   /**
    203    * @brief copies the Executor
    204    * @returns a new Executor that's a copy of this one.
    205    */
    206   virtual Executor<CallType, BaseClass>* clone() const
    207   {
    208     return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, CallType>(this->functionPointer);
    209   };
    210 };
    211 
    212 
    213 
    214 
    215 
    216 ///////////
    217 //// 1 ////
    218 ///////////
    219 //! @brief ExecutorClass, that can execute Functions with one parameter.
    220 template<class T, typename CallType, typename type0, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
    221 class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<CallType, BaseClass>
    222 {
    223 private:
    224   /** @brief the FunctioPointer. */
    225   void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST;
    226 
    227 public:
    228   /**
    229    * @brief constructs the Executor.
    230    * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
    231    */
    232   __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST)
    233       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    234   {
    235     this->functionPointer = functionPointer;
    236   };
    237 
    238   /**
    239    * @brief executes the Functional
    240    * @param object the Object the action should be executed on.
    241    * @param sub the SubString to get the Parameters from.
    242    */
    243   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    244   {
    245     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    246       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue));
    247   };
    248 
    249   /**
    250    * @brief copies the Executor
    251    * @returns a new Executor that's a copy of this one.
    252    */
    253   virtual Executor<CallType, BaseClass>* clone() const
    254   {
    255     return  new __EXECUTOR_FUNCTIONAL_NAME(1)<T, CallType, type0>(this->functionPointer);
    256   };
    257 };
    258 
    259 
    260 
    261 
    262 
    263 ///////////
    264 //// 2 ////
    265 ///////////
    266 //! @brief ExecutorClass, that can execute Functions with two parameters.
    267 template<class T, typename CallType, typename type0, typename type1, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
    268 class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<CallType, BaseClass>
    269 {
    270 private:
    271   /** @brief the FunctioPointer. */
    272   void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST;
    273 
    274 public:
    275   /**
    276    * @brief constructs the Executor.
    277    * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
    278    */
    279   __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST)
    280       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    281   {
    282     this->functionPointer = functionPointer;
    283   };
    284 
    285   /**
    286    * @brief executes the Functional
    287    * @param object the Object the action should be executed on.
    288    * @param sub the SubString to get the Parameters from.
    289    */
    290   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    291   {
    292     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    293       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    294       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue));
    295   };
    296 
    297   /**
    298    * @brief copies the Executor
    299    * @returns a new Executor that's a copy of this one.
    300    */
    301   virtual Executor<CallType, BaseClass>* clone() const
    302   {
    303     return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, CallType, type0, type1>(this->functionPointer);
    304   };
    305 };
    306 
    307 
    308 
    309 
    310 
    311 ///////////
    312 //// 3 ////
    313 ///////////
    314 //! @brief ExecutorClass, that can execute Functions with three parameters.
    315 template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
    316 class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<CallType, BaseClass>
    317 {
    318 private:
    319   /** @brief the FunctioPointer. */
    320   void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST;
    321 
    322 public:
    323   /**
    324    * @brief constructs the Executor.
    325    * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
    326    */
    327   __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST)
    328       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    329   {
    330     this->functionPointer = functionPointer;
    331   };
    332 
    333   /**
    334    * @brief executes the Functional
    335    * @param object the Object the action should be executed on.
    336    * @param sub the SubString to get the Parameters from.
    337    */
    338   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    339   {
    340     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    341       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    342       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue),
    343       Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue));
    344   };
    345 
    346   /**
    347    * @brief copies the Executor
    348    * @returns a new Executor that's a copy of this one.
    349    */
    350   virtual Executor<CallType, BaseClass>* clone() const
    351   {
    352     return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, CallType, type0, type1, type2>(this->functionPointer);
    353   };
    354 };
    355 
    356 
    357 
    358 
    359 
    360 ///////////
    361 //// 4 ////
    362 ///////////
    363 //! @brief ExecutorClass, that can execute Functions with four parameters.
    364 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
    365 class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<CallType, BaseClass>
    366 {
    367 private:
    368   /** @brief the FunctioPointer. */
    369   void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST;
    370 
    371 public:
    372   /**
    373    * @brief constructs the Executor.
    374    * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
    375    */
    376   __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST)
    377       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    378   {
    379     this->functionPointer = functionPointer;
    380   };
    381 
    382   /**
    383   * @brief executes the Functional
    384   * @param object the Object the action should be executed on.
    385   * @param sub the SubString to get the Parameters from.
    386    */
    387   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    388   {
    389     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    390       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    391       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue),
    392       Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue),
    393       Evaluater<CallType>().template operator()<type3, 3>(sub, this->defaultValue));
    394   };
    395 
    396   /**
    397    * @brief copies the Executor
    398    * @returns a new Executor that's a copy of this one.
    399    */
    400   virtual Executor<CallType, BaseClass>* clone() const
    401   {
    402     return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, CallType, type0, type1, type2, type3>(this->functionPointer);
    403   };
    404 };
    405 
    406 
    407 
    408 
    409 
    410 
    411 ///////////
    412 //// 5 ////
    413 ///////////
    414 //! @brief ExecutorClass, that can execute Functions with five parameters.
    415 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
    416 class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<CallType, BaseClass>
    417 {
    418 private:
    419   /** @brief the FunctioPointer. */
    420   void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST;
    421 
    422 public:
    423   /**
    424    * @brief constructs the Executor.
    425    * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
    426    */
    427   __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST)
    428       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    429   {
    430     this->functionPointer = functionPointer;
    431   };
    432 
    433   /**
    434   * @brief executes the Functional
    435   * @param object the Object the action should be executed on.
    436   * @param sub the SubString to get the Parameters from.
    437    */
    438   virtual void operator()(BaseObject* object, CallType& sub = Evaluater<CallType>::defaultValue()) const
    439   {
    440     (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    441       Evaluater<CallType>().template operator()<type0, 0>(sub, this->defaultValue),
    442       Evaluater<CallType>().template operator()<type1, 1>(sub, this->defaultValue),
    443       Evaluater<CallType>().template operator()<type2, 2>(sub, this->defaultValue),
    444       Evaluater<CallType>().template operator()<type3, 3>(sub, this->defaultValue),
    445       Evaluater<CallType>().template operator()<type4, 4>(sub, this->defaultValue));
    446   };
    447 
    448   /**
    449    * @brief copies the Executor
    450    * @returns a new Executor that's a copy of this one.
    451    */
    452   virtual Executor<CallType, BaseClass>* clone() const
    453   {
    454     return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, CallType, type0, type1, type2, type3, type4>(this->functionPointer);
    455   };
    456 };
    457 
    458 
    459 
    460 
    461 
    462 
    463 
    464 
    465 
    466 // // // // // // // // // // // // //
    467 //// EXTENSION TO HIDE CONSTRUCT /////
    468 // // // // // // // // // // // // //
    469 /**
    470  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    471  */
    472 #define EXECUTOR_FUNCTIONAL_CREATOR0() \
    473 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
    474 { \
    475   return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, const SubString>(functionPointer); \
    476 }
    477 
    478 /**
    479  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    480  * @param type0 for internal usage: the first Argument
    481  */
    482 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \
    483 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) \
    484 { \
    485   return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, const SubString, type0>(functionPointer); \
    486 }
    487 
    488 /**
    489  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    490  * @param type0 for internal usage: the first Argument
    491  * @param type1 for internal usage: the second Argument
    492  */
    493 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \
    494 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) \
    495 { \
    496   return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, const SubString, type0, type1>(functionPointer); \
    497 }
    498 
    499 /**
    500  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    501  * @param type0 for internal usage: the first Argument
    502  * @param type1 for internal usage: the second Argument
    503  * @param type2 for internal usage: the third Argument
    504  */
    505 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \
    506 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) \
    507 { \
    508   return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, const SubString, type0, type1, type2>(functionPointer); \
    509 }
    510 
    511 /**
    512  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    513  * @param type0 for internal usage: the first Argument
    514  * @param type1 for internal usage: the second Argument
    515  * @param type2 for internal usage: the third Argument
    516  * @param type3 for internal usage: the fourth Argument
    517  */
    518 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \
    519 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) \
    520 { \
    521   return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, const SubString, type0, type1, type2, type3>(functionPointer); \
    522 }
    523 
    524 /**
    525  * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    526  * @param type0 for internal usage: the first Argument
    527  * @param type1 for internal usage: the second Argument
    528  * @param type2 for internal usage: the third Argument
    529  * @param type3 for internal usage: the fourth Argument
    530  * @param type4 for internal usage: the fifth Argument
    531  */
    532 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \
    533 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) \
    534 { \
    535     return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, const SubString, type0, type1, type2, type3, type4>(functionPointer); \
    536 }
    537 
    538 
    539 /**
    540  * Creates the FunctionCallers
    541  */
    542 #define FUNCTOR_LIST(x) EXECUTOR_FUNCTIONAL_CREATOR ## x
    543 #include "functor_list.h"
    544 #undef FUNCTOR_LIST
    545 
    546 
     44#undef __EXECUTOR_FUNCTIONAL_NAME
    54745
    54846#undef __EXECUTOR_FUNCTIONAL_CONST
    549 #undef __EXECUTOR_FUNCTIONAL_NAME
    55047#undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC
    55148#undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER
    55249#undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    55350
    554 #ifdef EXECUTOR_FUNCTIONAL_USE_CONST
    555  #undef EXECUTOR_FUNCTIONAL_USE_CONST
    556 #endif
    557 #ifdef EXECUTOR_FUNCTIONAL_USE_STATIC
    558  #undef EXECUTOR_FUNCTIONAL_USE_STATIC
    559 #endif
    560 
    561 
    562 #endif /* __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS */
    563 #undef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
     51#endif /* __EXECUTOR_MEMBER_H_ */
Note: See TracChangeset for help on using the changeset viewer.