Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/effects/cloud_effect.cc

    r9716 r9746  
    5050
    5151CREATE_SCRIPTABLE_CLASS(CloudEffect, CloudEffect::classID(),
    52                         addMethod("skyColor", ExecutorLua4<CloudEffect,float,float,float,float>(&CloudEffect::shellSkyColor))
    53                         ->addMethod("cloudColor", ExecutorLua4<CloudEffect,float,float,float,float>(&CloudEffect::shellCloudColor))
    54                         ->addMethod("activate", ExecutorLua0<CloudEffect>(&CloudEffect::activate))
    55                         ->addMethod("deactivate", ExecutorLua0<CloudEffect>(&CloudEffect::deactivate))
     52                        addMethod("skyColor", Executor4<CloudEffect, lua_State*,float,float,float,float>(&CloudEffect::shellSkyColor))
     53                        ->addMethod("cloudColor", Executor4<CloudEffect, lua_State*,float,float,float,float>(&CloudEffect::shellCloudColor))
     54                        ->addMethod("activate", Executor0<CloudEffect, lua_State*>(&CloudEffect::activate))
     55                        ->addMethod("deactivate", Executor0<CloudEffect, lua_State*>(&CloudEffect::deactivate))
    5656                       );
    5757
  • branches/new_class_id/src/lib/graphics/effects/fog_effect.cc

    r9716 r9746  
    2121#include "script_class.h"
    2222#include "cloud_effect.h"
     23#include "debug.h"
    2324
    2425ObjectListDefinition(FogEffect);
     
    3233
    3334CREATE_SCRIPTABLE_CLASS(FogEffect, FogEffect::classID(),
    34                         addMethod("fadeIn", ExecutorLua0<FogEffect>(&FogEffect::fadeInFog))
    35                             ->addMethod("fadeOut", ExecutorLua0<FogEffect>(&FogEffect::fadeOutFog))
    36                             ->addMethod("activate", ExecutorLua0<FogEffect>(&FogEffect::activate))
    37                             ->addMethod("deactivate", ExecutorLua0<FogEffect>(&FogEffect::deactivate))
     35                        addMethod("fadeIn", Executor0<FogEffect, lua_State*>(&FogEffect::fadeInFog))
     36                            ->addMethod("fadeOut", Executor0<FogEffect, lua_State*>(&FogEffect::fadeOutFog))
     37                            ->addMethod("activate", Executor0<FogEffect, lua_State*>(&FogEffect::activate))
     38                            ->addMethod("deactivate", Executor0<FogEffect, lua_State*>(&FogEffect::deactivate))
    3839                       );
    3940
  • branches/new_class_id/src/lib/graphics/effects/lightning_effect.cc

    r9716 r9746  
    2727#include "cloud_effect.h"
    2828#include "script_class.h"
     29#include "debug.h"
    2930#include "class_id_DEPRECATED.h"
    3031
     
    3536
    3637CREATE_SCRIPTABLE_CLASS(LightningEffect, LightningEffect::classID(),
    37                         addMethod("activate", ExecutorLua0<LightningEffect>(&LightningEffect::activate))
    38                             ->addMethod("deactivate", ExecutorLua0<LightningEffect>(&LightningEffect::deactivate))
     38                        addMethod("activate", Executor0<LightningEffect, lua_State*>(&LightningEffect::activate))
     39                            ->addMethod("deactivate", Executor0<LightningEffect, lua_State*>(&LightningEffect::deactivate))
    3940                       );
    4041
  • branches/new_class_id/src/lib/graphics/effects/rain_effect.cc

    r9716 r9746  
    3030#include "cloud_effect.h"
    3131#include "script_class.h"
     32#include "debug.h"
    3233
    3334#include "class_id_DEPRECATED.h"
     
    4445
    4546CREATE_SCRIPTABLE_CLASS(RainEffect, RainEffect::classID(),
    46                         addMethod("startRaining", ExecutorLua0<RainEffect>(&RainEffect::startRaining))
    47                             ->addMethod("stopRaining", ExecutorLua0<RainEffect>(&RainEffect::stopRaining))
    48                             ->addMethod("activate", ExecutorLua0<RainEffect>(&RainEffect::activate))
    49                             ->addMethod("deactivate", ExecutorLua0<RainEffect>(&RainEffect::deactivate))
     47                        addMethod("startRaining", Executor0<RainEffect, lua_State*>(&RainEffect::startRaining))
     48                            ->addMethod("stopRaining", Executor0<RainEffect, lua_State*>(&RainEffect::stopRaining))
     49                            ->addMethod("activate", Executor0<RainEffect, lua_State*>(&RainEffect::activate))
     50                            ->addMethod("deactivate", Executor0<RainEffect, lua_State*>(&RainEffect::deactivate))
    5051                       );
    5152
  • branches/new_class_id/src/lib/graphics/effects/snow_effect.cc

    r9716 r9746  
    3838
    3939CREATE_SCRIPTABLE_CLASS(SnowEffect, SnowEffect::classID(),
    40                             addMethod("activate", ExecutorLua0<SnowEffect>(&SnowEffect::activate))
    41                             ->addMethod("deactivate", ExecutorLua0<SnowEffect>(&SnowEffect::deactivate))
     40                            addMethod("activate", Executor0<SnowEffect, lua_State*>(&SnowEffect::activate))
     41                            ->addMethod("deactivate", Executor0<SnowEffect, lua_State*>(&SnowEffect::deactivate))
    4242                       );
    4343
  • branches/new_class_id/src/lib/script_engine/script.cc

    r9720 r9746  
    2626
    2727CREATE_SCRIPTABLE_CLASS(Script, Script::classID(),
    28                     addMethod("addObject", ExecutorLua2<Script,const std::string&, const std::string& >(&Script::addObject))
    29                     ->addMethod("registerClass", ExecutorLua1<Script,const std::string&>(&Script::registerClass))
    30                     ->addMethod("selectFunction", ExecutorLua2ret<Script, bool, const std::string&, int >(&Script::selectFunction))
    31                     ->addMethod("executeFunction", ExecutorLua0ret<Script,bool >(&Script::executeFunction))
     28                    addMethod("addObject", Executor2<Script, lua_State*,const std::string&, const std::string& >(&Script::addObject))
     29                    ->addMethod("registerClass", Executor1<Script, lua_State*,const std::string&>(&Script::registerClass))
     30                    ->addMethod("selectFunction", Executor2ret<Script, lua_State*, bool, const std::string&, int >(&Script::selectFunction))
     31                    ->addMethod("executeFunction", Executor0ret<Script, lua_State*,bool >(&Script::executeFunction))
    3232                     );
    3333
  • branches/new_class_id/src/lib/script_engine/script_method.h

    r9727 r9746  
    99#include <vector>
    1010
    11 #include "executor/executor_lua.h"
    12 
     11#include "executor/executor_lua_state.h"
     12#include "executor/executor_member.h"
    1313
    1414class ScriptMethod
  • branches/new_class_id/src/lib/util/Makefile.am

    r9743 r9746  
    88libORXexecutor_a_SOURCES = \
    99                executor/executor.cc \
    10                 executor/executor_lua.cc \
    1110                executor/executor_lua_state.cc \
    1211                executor/executor_substring.cc
     
    4948                executor/executor.h \
    5049                executor/executor_xml.h \
    51                 executor/executor_lua.h \
    5250                executor/executor_lua_state.h \
    5351                executor/executor_substring.h \
  • 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.