Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9746 in orxonox.OLD for branches/new_class_id/src/lib/util/executor


Ignore:
Timestamp:
Sep 16, 2006, 3:34:04 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: does not run anymore with scripts, but i think, it is on track

lua_State is now handled over the Global Executor

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

Legend:

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

    r9745 r9746  
    7474   */
    7575  __EXECUTOR_FUNCTIONAL_NAME(0,) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST )
    76       : Executor<CallType, BaseClass>(false, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    77   {
    78     this->functionPointer = functionPointer;
    79   };
     76      : Executor<CallType, BaseClass>(false, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     77  {};
    8078
    8179  /**
     
    118116   */
    119117  __EXECUTOR_FUNCTIONAL_NAME(1,) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST)
    120       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    121   {
    122     this->functionPointer = functionPointer;
    123   };
     118      : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     119  {};
    124120
    125121  /**
     
    163159   */
    164160  __EXECUTOR_FUNCTIONAL_NAME(2,) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST)
    165       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    166   {
    167     this->functionPointer = functionPointer;
    168   };
     161      : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     162  {};
    169163
    170164  /**
     
    209203   */
    210204  __EXECUTOR_FUNCTIONAL_NAME(3,) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST)
    211       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    212   {
    213     this->functionPointer = functionPointer;
    214   };
     205      : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     206  {};
    215207
    216208  /**
     
    256248   */
    257249  __EXECUTOR_FUNCTIONAL_NAME(4,) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST)
    258       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    259   {
    260     this->functionPointer = functionPointer;
    261   };
     250      : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     251  {};
    262252
    263253  /**
     
    304294   */
    305295  __EXECUTOR_FUNCTIONAL_NAME(5,) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST)
    306       : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    307   {
    308     this->functionPointer = functionPointer;
    309   };
     296      : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     297  {};
    310298
    311299  /**
     
    334322};
    335323
     324
     325////////////////////
     326//// 0 & RETURN ////
     327////////////////////
     328//! @brief ExecutorClass, that can execute Functions with one parameter.
     329template<class T, typename CallType, typename ret, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     330class __EXECUTOR_FUNCTIONAL_NAME(0,ret) : public Executor<CallType, BaseClass>
     331{
     332private:
     333  /** @brief the FunctioPointer. */
     334  ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST;
     335
     336public:
     337  /**
     338   * @brief constructs the Executor.
     339   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     340   */
     341  __EXECUTOR_FUNCTIONAL_NAME(0,ret) (ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST)
     342      : Executor<CallType, BaseClass>(true, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     343  {};
     344
     345  /**
     346     * @brief executes the Functional
     347     * @param object the Object the action should be executed on.
     348     * @param eval the CallType to get the Parameters from.
     349   */
     350  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     351  {
     352    Evaluater<CallType>().template storeRet<ret>(eval, (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)());
     353  };
     354
     355  /**
     356     * @brief copies the Executor
     357     * @returns a new Executor that's a copy of this one.
     358   */
     359  virtual Executor<CallType, BaseClass>* clone() const
     360  {
     361    return  new __EXECUTOR_FUNCTIONAL_NAME(0,ret)<T, CallType, ret>(this->functionPointer);
     362  };
     363};
     364
     365////////////////////
     366//// 1 & RETURN ////
     367////////////////////
     368//! @brief ExecutorClass, that can execute Functions with one parameter.
     369template<class T, typename CallType, typename ret, typename type0, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     370class __EXECUTOR_FUNCTIONAL_NAME(1,ret) : public Executor<CallType, BaseClass>
     371{
     372private:
     373  /** @brief the FunctioPointer. */
     374  ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST;
     375
     376public:
     377  /**
     378   * @brief constructs the Executor.
     379   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     380   */
     381  __EXECUTOR_FUNCTIONAL_NAME(1,ret) (ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST)
     382      : Executor<CallType, BaseClass>(true, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     383  {};
     384
     385  /**
     386     * @brief executes the Functional
     387     * @param object the Object the action should be executed on.
     388     * @param eval the CallType to get the Parameters from.
     389   */
     390  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     391  {
     392    Evaluater<CallType>().template storeRet<ret>(eval, (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     393          Evaluater<CallType>().template operator()<type0, 0>(eval, 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(1,ret)<T, CallType, ret, type0>(this->functionPointer);
     403  };
     404};
     405
     406
     407////////////////////
     408//// 1 & RETURN ////
     409////////////////////
     410//! @brief ExecutorClass, that can execute Functions with one parameter.
     411template<class T, typename CallType, typename ret, typename type0, typename type1, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     412class __EXECUTOR_FUNCTIONAL_NAME(2,ret) : public Executor<CallType, BaseClass>
     413{
     414private:
     415  /** @brief the FunctioPointer. */
     416  ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST;
     417
     418public:
     419  /**
     420   * @brief constructs the Executor.
     421   * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function.
     422   */
     423  __EXECUTOR_FUNCTIONAL_NAME(2,ret) (ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST)
     424      : Executor<CallType, BaseClass>(true, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE), functionPointer(functionPointer)
     425  {};
     426
     427  /**
     428     * @brief executes the Functional
     429     * @param object the Object the action should be executed on.
     430     * @param eval the CallType to get the Parameters from.
     431   */
     432  virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     433  {
     434    Evaluater<CallType>().template storeRet<ret>(eval, (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     435          Evaluater<CallType>().template operator()<type0, 0>(eval, this->defaultValue),
     436          Evaluater<CallType>().template operator()<type1, 1>(eval, this->defaultValue)));
     437  };
     438
     439  /**
     440     * @brief copies the Executor
     441     * @returns a new Executor that's a copy of this one.
     442   */
     443  virtual Executor<CallType, BaseClass>* clone() const
     444  {
     445    return  new __EXECUTOR_FUNCTIONAL_NAME(2,ret)<T, CallType, ret, type0, type1>(this->functionPointer);
     446  };
     447};
     448
    336449#endif /* __EXECUTOR_FUNCTIONAL_NAME */
  • branches/new_class_id/src/lib/util/executor/executor_lua_state.h

    r9745 r9746  
    6666    return (fromLua<ToType>(CallValue, index));
    6767  }
     68  template <typename ToType>
     69  void storeRet(lua_State*& state, ToType value)
     70  {
     71    toLua<ToType>(state, value);
     72  }
    6873  static lua_State*& defaultValue() { static lua_State* nullState; return nullState; };
    6974};
Note: See TracChangeset for help on using the changeset viewer.