Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8808 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 26, 2006, 5:04:39 PM (18 years ago)
Author:
snellen
Message:

added executor with 6 and 7 parameters

File:
1 edited

Legend:

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

    r8711 r8808  
    388388};
    389389
     390///////////
     391//// 6 ////
     392///////////
     393//! Executes a Function with a lua_State* parameter.
     394template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor
     395{
     396  public:
     397    /**
     398   * @brief Constructor of a ExecutorXML
     399   * @param function a Function to call
     400     */
     401    ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5))
     402  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     403             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     404             ExecutorParamType<type4>(), ExecutorParamType<type5>())
     405    {
     406      this->functionPointer = function;
     407      this->functorType = Executor_Objective | Executor_NoLoadString;
     408    }
     409
     410    /**
     411     * @brief executes the Command on BaseObject
     412     * @param object the BaseObject to execute this Executor on
     413     * @param loadString ignored in this case
     414     */
     415    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     416    {
     417      PRINTF(1)("no usefull executor\n");
     418    }
     419
     420    virtual void operator()(BaseObject* object, int& count, void* values) const
     421    {
     422      lua_State* state = (lua_State*)values;
     423      count = 1;
     424
     425      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     426          fromLua<type0>(state, 1),
     427          fromLua<type1>(state, 2),
     428          fromLua<type2>(state, 3),
     429          fromLua<type3>(state, 4),
     430          fromLua<type4>(state, 5),
     431          fromLua<type5>(state, 6) ));
     432    }
     433
     434    /**
     435     * @returns a _new_ Copy of this Executor
     436     */
     437    virtual Executor* clone () const
     438    {
     439      return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer);
     440    }
     441  private:
     442    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5);
     443};
     444
     445///////////
     446//// 7 ////
     447///////////
     448//! Executes a Function with a lua_State* parameter.
     449template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor
     450{
     451  public:
     452    /**
     453   * @brief Constructor of a ExecutorXML
     454   * @param function a Function to call
     455     */
     456    ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6))
     457  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     458             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     459             ExecutorParamType<type4>(), ExecutorParamType<type5>(),
     460             ExecutorParamType<type6>())
     461             {
     462               this->functionPointer = function;
     463               this->functorType = Executor_Objective | Executor_NoLoadString;
     464             }
     465
     466    /**
     467              * @brief executes the Command on BaseObject
     468              * @param object the BaseObject to execute this Executor on
     469              * @param loadString ignored in this case
     470     */
     471             virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     472             {
     473               PRINTF(1)("no usefull executor\n");
     474             }
     475
     476             virtual void operator()(BaseObject* object, int& count, void* values) const
     477             {
     478               lua_State* state = (lua_State*)values;
     479               count = 1;
     480
     481               toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     482                   fromLua<type0>(state, 1),
     483                   fromLua<type1>(state, 2),
     484                   fromLua<type2>(state, 3),
     485                   fromLua<type3>(state, 4),
     486                   fromLua<type4>(state, 5),
     487                   fromLua<type4>(state, 6),
     488                   fromLua<type5>(state, 7) ));
     489             }
     490
     491    /**
     492              * @returns a _new_ Copy of this Executor
     493     */
     494             virtual Executor* clone () const
     495             {
     496               return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer);
     497             }
     498  private:
     499    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6);
     500};
     501
     502
    390503#endif /* _EXECUTOR_LUA_H */
Note: See TracChangeset for help on using the changeset viewer.