Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8894 in orxonox.OLD for trunk/src/lib/util/executor/executor_lua.h


Ignore:
Timestamp:
Jun 29, 2006, 12:19:48 AM (18 years ago)
Author:
patrick
Message:

merged the branche single_player_map with the trunk

File:
1 edited

Legend:

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

    r8711 r8894  
    233233
    234234
     235///////////
     236//// 4 ////
     237///////////
     238//! Executes a Function with a lua_State* parameter.
     239template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor
     240{
     241  public:
     242    /**
     243   * @brief Constructor of a ExecutorXML
     244   * @param function a Function to call
     245     */
     246    ExecutorLua4(void(T::*function)(type0, type1, type2, type3))
     247  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     248    {
     249      this->functionPointer = function;
     250      this->functorType = Executor_Objective | Executor_NoLoadString;
     251    }
     252
     253    /**
     254     * @brief executes the Command on BaseObject
     255     * @param object the BaseObject to execute this Executor on
     256     * @param loadString ignored in this case
     257     */
     258    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     259    {
     260      PRINTF(1)("no usefull executor\n");
     261    }
     262
     263    virtual void operator()(BaseObject* object, int& count, void* values) const
     264    {
     265      lua_State* state = (lua_State*)values;
     266      count = 0;
     267
     268      (dynamic_cast<T*>(object)->*(functionPointer))(
     269          fromLua<type0>(state, 1),
     270          fromLua<type1>(state, 2),
     271          fromLua<type2>(state, 3),
     272          fromLua<type3>(state, 4) );
     273    }
     274
     275    /**
     276     * @returns a _new_ Copy of this Executor
     277     */
     278    virtual Executor* clone () const
     279    {
     280      return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer);
     281    }
     282  private:
     283    void          (T::*functionPointer)(type0, type1, type2, type3);
     284};
    235285
    236286
     
    388438};
    389439
     440
     441///////////
     442//// 3 ////
     443///////////
     444//! Executes a Function with a lua_State* parameter.
     445template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor
     446{
     447  public:
     448    /**
     449   * @brief Constructor of a ExecutorXML
     450   * @param function a Function to call
     451     */
     452    ExecutorLua3ret(ret (T::*function)(type0, type1, type2))
     453  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
     454    {
     455      this->functionPointer = function;
     456      this->functorType = Executor_Objective | Executor_NoLoadString;
     457    }
     458
     459    /**
     460     * @brief executes the Command on BaseObject
     461     * @param object the BaseObject to execute this Executor on
     462     * @param loadString ignored in this case
     463     */
     464    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     465    {
     466      PRINTF(1)("no usefull executor\n");
     467    }
     468
     469    virtual void operator()(BaseObject* object, int& count, void* values) const
     470    {
     471      lua_State* state = (lua_State*)values;
     472      count = 1;
     473
     474      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     475          fromLua<type0>(state, 1),
     476          fromLua<type1>(state, 2),
     477          fromLua<type2>(state, 3) ));
     478    }
     479
     480    /**
     481     * @returns a _new_ Copy of this Executor
     482     */
     483    virtual Executor* clone () const
     484    {
     485      return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer);
     486    }
     487  private:
     488    ret          (T::*functionPointer)(type0, type1, type2);
     489};
     490
     491
     492///////////
     493//// 4 ////
     494///////////
     495//! Executes a Function with a lua_State* parameter.
     496template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor
     497{
     498  public:
     499    /**
     500   * @brief Constructor of a ExecutorXML
     501   * @param function a Function to call
     502     */
     503    ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3))
     504  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     505    {
     506      this->functionPointer = function;
     507      this->functorType = Executor_Objective | Executor_NoLoadString;
     508    }
     509
     510    /**
     511     * @brief executes the Command on BaseObject
     512     * @param object the BaseObject to execute this Executor on
     513     * @param loadString ignored in this case
     514     */
     515    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     516    {
     517      PRINTF(1)("no usefull executor\n");
     518    }
     519
     520    virtual void operator()(BaseObject* object, int& count, void* values) const
     521    {
     522      lua_State* state = (lua_State*)values;
     523      count = 1;
     524
     525      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     526          fromLua<type0>(state, 1),
     527          fromLua<type1>(state, 2),
     528          fromLua<type2>(state, 3),
     529          fromLua<type3>(state, 4) ));
     530    }
     531
     532    /**
     533     * @returns a _new_ Copy of this Executor
     534     */
     535    virtual Executor* clone () const
     536    {
     537      return new ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer);
     538    }
     539  private:
     540    ret          (T::*functionPointer)(type0, type1, type2, type3);
     541};
     542
     543///////////
     544//// 5 ////
     545///////////
     546//! Executes a Function with a lua_State* parameter.
     547template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor
     548{
     549  public:
     550    /**
     551   * @brief Constructor of a ExecutorXML
     552   * @param function a Function to call
     553     */
     554    ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4))
     555  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
     556    {
     557      this->functionPointer = function;
     558      this->functorType = Executor_Objective | Executor_NoLoadString;
     559    }
     560
     561    /**
     562     * @brief executes the Command on BaseObject
     563     * @param object the BaseObject to execute this Executor on
     564     * @param loadString ignored in this case
     565     */
     566    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     567    {
     568      PRINTF(1)("no usefull executor\n");
     569    }
     570
     571    virtual void operator()(BaseObject* object, int& count, void* values) const
     572    {
     573      lua_State* state = (lua_State*)values;
     574      count = 1;
     575
     576      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     577          fromLua<type0>(state, 1),
     578          fromLua<type1>(state, 2),
     579          fromLua<type2>(state, 3),
     580          fromLua<type3>(state, 4),
     581          fromLua<type4>(state, 5) ));
     582    }
     583
     584    /**
     585     * @returns a _new_ Copy of this Executor
     586     */
     587    virtual Executor* clone () const
     588    {
     589      return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer);
     590    }
     591  private:
     592    ret          (T::*functionPointer)(type0, type1, type2, type3, type4);
     593};
     594
     595///////////
     596//// 6 ////
     597///////////
     598//! Executes a Function with a lua_State* parameter.
     599template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor
     600{
     601  public:
     602    /**
     603   * @brief Constructor of a ExecutorXML
     604   * @param function a Function to call
     605     */
     606    ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5))
     607  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     608             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     609             ExecutorParamType<type4>(), ExecutorParamType<type5>())
     610    {
     611      this->functionPointer = function;
     612      this->functorType = Executor_Objective | Executor_NoLoadString;
     613    }
     614
     615    /**
     616     * @brief executes the Command on BaseObject
     617     * @param object the BaseObject to execute this Executor on
     618     * @param loadString ignored in this case
     619     */
     620    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     621    {
     622      PRINTF(1)("no usefull executor\n");
     623    }
     624
     625    virtual void operator()(BaseObject* object, int& count, void* values) const
     626    {
     627      lua_State* state = (lua_State*)values;
     628      count = 1;
     629
     630      toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     631          fromLua<type0>(state, 1),
     632          fromLua<type1>(state, 2),
     633          fromLua<type2>(state, 3),
     634          fromLua<type3>(state, 4),
     635          fromLua<type4>(state, 5),
     636          fromLua<type5>(state, 6) ));
     637    }
     638
     639    /**
     640     * @returns a _new_ Copy of this Executor
     641     */
     642    virtual Executor* clone () const
     643    {
     644      return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer);
     645    }
     646  private:
     647    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5);
     648};
     649
     650///////////
     651//// 7 ////
     652///////////
     653//! Executes a Function with a lua_State* parameter.
     654template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor
     655{
     656  public:
     657    /**
     658   * @brief Constructor of a ExecutorXML
     659   * @param function a Function to call
     660     */
     661    ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6))
     662  : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(),
     663             ExecutorParamType<type2>(), ExecutorParamType<type3>(),
     664             ExecutorParamType<type4>(), ExecutorParamType<type5>(),
     665             ExecutorParamType<type6>())
     666             {
     667               this->functionPointer = function;
     668               this->functorType = Executor_Objective | Executor_NoLoadString;
     669             }
     670
     671    /**
     672              * @brief executes the Command on BaseObject
     673              * @param object the BaseObject to execute this Executor on
     674              * @param loadString ignored in this case
     675     */
     676             virtual void operator()(BaseObject* object, const SubString& = SubString()) const
     677             {
     678               PRINTF(1)("no usefull executor\n");
     679             }
     680
     681             virtual void operator()(BaseObject* object, int& count, void* values) const
     682             {
     683               lua_State* state = (lua_State*)values;
     684               count = 1;
     685
     686               toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))(
     687                   fromLua<type0>(state, 1),
     688                   fromLua<type1>(state, 2),
     689                   fromLua<type2>(state, 3),
     690                   fromLua<type3>(state, 4),
     691                   fromLua<type4>(state, 5),
     692                   fromLua<type5>(state, 6),
     693                   fromLua<type6>(state, 7) ));
     694             }
     695
     696    /**
     697              * @returns a _new_ Copy of this Executor
     698     */
     699             virtual Executor* clone () const
     700             {
     701               return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer);
     702             }
     703  private:
     704    ret           (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6);
     705};
     706
     707
    390708#endif /* _EXECUTOR_LUA_H */
Note: See TracChangeset for help on using the changeset viewer.