Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7724 in orxonox.OLD for trunk/src/lib/util


Ignore:
Timestamp:
May 19, 2006, 4:41:01 AM (19 years ago)
Author:
bensch
Message:

trunk: comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor_functional.h

    r7722 r7724  
    5151#endif /* __EXECUTOR_FUNCTIONAL_H_ */
    5252
    53 
     53//! if Functional is constant calling
    5454#define __EXECUTOR_FUNCTIONAL_CONST
     55//! The Name to be attached to the functional (for normal, static, and const modes)
    5556#define __EXECUTOR_FUNCTIONAL_NAME(ParamCount)   Executor##ParamCount##Params
     57//! The Execution-mode (either static or objective)
    5658#define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC      dynamic_cast<T*>(object)->*(functionPointer)
     59//! The Function-Pointer, and how to save it internally.
    5760#define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER   T::*functionPointer
    5861
     
    8083#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    8184
     85//! @brief ExecutorClass, that can execute Functions without any parameters.
    8286template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor
    8387{
    8488private:
     89  /** @brief the FunctioPointer. */
    8590  void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST;
    8691
    8792public:
     93  /**
     94   * @brief constructs the Executor.
     95   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     96   */
    8897  __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST )
    8998      : Executor()
     
    93102  };
    94103
     104  /**
     105   * @brief executes the Functional
     106   * @param object the Object the action should be executed on.
     107   * @param sub the SubString to get the Parameters from.
     108   */
    95109  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    96110  {
     
    98112  };
    99113
     114  /**
     115   * @brief copies the Executor
     116   * @returns a new Executor that's a copy of this one.
     117   */
    100118  virtual Executor* clone() const
    101119  {
     
    104122};
    105123
    106 //! SINGLE VALUE
     124//! @brief ExecutorClass, that can execute Functions with one parameter.
    107125template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor
    108126{
    109127private:
     128  /** @brief the FunctioPointer. */
    110129  void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST;
    111130
    112131public:
     132  /**
     133   * @brief constructs the Executor.
     134   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     135   */
    113136  __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST)
    114137      : Executor(ExecutorParamType<type0>())
     
    118141  };
    119142
     143  /**
     144   * @brief executes the Functional
     145   * @param object the Object the action should be executed on.
     146   * @param sub the SubString to get the Parameters from.
     147   */
    120148  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    121149  {
     
    130158  };
    131159
     160  /**
     161   * @brief copies the Executor
     162   * @returns a new Executor that's a copy of this one.
     163   */
    132164  virtual Executor* clone() const
    133165  {
     
    136168};
    137169
    138 //! DOUBLE VALUE
     170//! @brief ExecutorClass, that can execute Functions with two parameters.
    139171template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor
    140172{
    141173private:
     174  /** @brief the FunctioPointer. */
    142175  void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST;
    143176
    144177public:
     178  /**
     179   * @brief constructs the Executor.
     180   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     181   */
    145182  __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST)
    146183      : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>())
     
    150187  };
    151188
     189  /**
     190   * @brief executes the Functional
     191   * @param object the Object the action should be executed on.
     192   * @param sub the SubString to get the Parameters from.
     193   */
    152194  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    153195  {
     
    157199  };
    158200
     201  /**
     202   * @brief copies the Executor
     203   * @returns a new Executor that's a copy of this one.
     204   */
    159205  virtual Executor* clone() const
    160206  {
     
    164210
    165211
    166 //! TRIPPLE VALUE
     212//! @brief ExecutorClass, that can execute Functions with three parameters.
    167213template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor
    168214{
    169215private:
     216  /** @brief the FunctioPointer. */
    170217  void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST;
    171218
    172219public:
     220  /**
     221   * @brief constructs the Executor.
     222   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     223   */
    173224  __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST)
    174225      : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
     
    178229  };
    179230
     231  /**
     232   * @brief executes the Functional
     233   * @param object the Object the action should be executed on.
     234   * @param sub the SubString to get the Parameters from.
     235   */
    180236  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    181237  {
     
    186242  };
    187243
     244  /**
     245   * @brief copies the Executor
     246   * @returns a new Executor that's a copy of this one.
     247   */
    188248  virtual Executor* clone() const
    189249  {
     
    194254
    195255
    196 //! QUADRUPPEL VALUE
     256//! @brief ExecutorClass, that can execute Functions with four parameters.
    197257template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor
    198258{
    199259private:
     260  /** @brief the FunctioPointer. */
    200261  void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST;
    201262
    202263public:
     264  /**
     265   * @brief constructs the Executor.
     266   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     267   */
    203268  __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST)
    204   : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
    205   {
    206     this->functorType = Executor_Objective;
    207     this->functionPointer = functionPointer;
    208   };
    209 
     269      : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     270  {
     271    this->functorType = Executor_Objective;
     272    this->functionPointer = functionPointer;
     273  };
     274
     275  /**
     276  * @brief executes the Functional
     277  * @param object the Object the action should be executed on.
     278  * @param sub the SubString to get the Parameters from.
     279   */
    210280  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    211281  {
     
    217287  };
    218288
     289  /**
     290   * @brief copies the Executor
     291   * @returns a new Executor that's a copy of this one.
     292   */
    219293  virtual Executor* clone() const
    220294  {
     
    223297};
    224298
    225 //! CHINQUE VALUE
     299//! @brief ExecutorClass, that can execute Functions with five parameters.
    226300template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor
    227301{
    228   private:
    229     void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST;
    230 
    231   public:
    232     __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST)
    233   : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
    234     {
    235       this->functorType = Executor_Objective;
    236       this->functionPointer = functionPointer;
    237     };
    238 
    239     virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    240     {
    241       (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    242           fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
     302private:
     303  /** @brief the FunctioPointer. */
     304  void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST;
     305
     306public:
     307  /**
     308   * @brief constructs the Executor.
     309   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     310   */
     311  __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST)
     312      : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
     313  {
     314    this->functorType = Executor_Objective;
     315    this->functionPointer = functionPointer;
     316  };
     317
     318  /**
     319  * @brief executes the Functional
     320  * @param object the Object the action should be executed on.
     321  * @param sub the SubString to get the Parameters from.
     322   */
     323  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
     324  {
     325    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     326      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)),
    243327      fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)),
    244328      fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)),
    245329      fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)),
    246330      fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4)));
    247     };
    248 
    249     virtual Executor* clone() const
    250     {
    251       return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer);
    252     };
    253 };
    254 
    255 
    256 
     331  };
     332
     333  /**
     334   * @brief copies the Executor
     335   * @returns a new Executor that's a copy of this one.
     336   */
     337  virtual Executor* clone() const
     338  {
     339    return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer);
     340  };
     341};
     342
     343
     344
     345/**
     346 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
     347 */
    257348#define EXECUTOR_FUNCTIONAL_CREATOR0() \
    258349template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
     
    261352}
    262353
     354/**
     355 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
     356 * @param type0 for internal usage: the first Argument
     357 */
    263358#define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \
    264359template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     
    267362}
    268363
     364/**
     365 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
     366 * @param type0 for internal usage: the first Argument
     367 * @param type1 for internal usage: the second Argument
     368 */
    269369#define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \
    270370template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     
    273373}
    274374
     375/**
     376 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
     377 * @param type0 for internal usage: the first Argument
     378 * @param type1 for internal usage: the second Argument
     379 * @param type2 for internal usage: the third Argument
     380 */
    275381#define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \
    276382template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     
    279385}
    280386
     387/**
     388 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
     389 * @param type0 for internal usage: the first Argument
     390 * @param type1 for internal usage: the second Argument
     391 * @param type2 for internal usage: the third Argument
     392 * @param type3 for internal usage: the fourth Argument
     393 */
    281394#define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \
    282395template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     
    285398}
    286399
     400/**
     401 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
     402 * @param type0 for internal usage: the first Argument
     403 * @param type1 for internal usage: the second Argument
     404 * @param type2 for internal usage: the third Argument
     405 * @param type3 for internal usage: the fourth Argument
     406 * @param type4 for internal usage: the fifth Argument
     407 */
    287408#define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \
    288409template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     
    292413
    293414
    294 
     415/**
     416 * Creates the FunctionCallers
     417 */
    295418#define FUNCTOR_LIST(x) EXECUTOR_FUNCTIONAL_CREATOR ## x
    296419#include "functor_list.h"
Note: See TracChangeset for help on using the changeset viewer.