Changeset 9727 in orxonox.OLD for branches/new_class_id/src/lib/util/executor
- Timestamp:
- Sep 14, 2006, 5:24:31 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util/executor
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor.cc
r9715 r9727 19 19 20 20 21 ObjectListDefinition(Executor );21 ObjectListDefinition(ExecutorBase); 22 22 23 23 /** … … 27 27 * @param paramCount the count of parameters this command takes 28 28 */ 29 Executor::Executor(const MultiType& param0, 30 const MultiType& param1, 31 const MultiType& param2, 32 const MultiType& param3, 33 const MultiType& param4, 34 const MultiType& param5, 35 const MultiType& param6) 29 ExecutorBase::ExecutorBase(bool hasRetVal, 30 const MultiType& param0, 31 const MultiType& param1, 32 const MultiType& param2, 33 const MultiType& param3, 34 const MultiType& param4, 35 const MultiType& param5, 36 const MultiType& param6) 37 : bRetVal(hasRetVal) 36 38 { 37 this->registerObject(this, Executor ::_objectList);39 this->registerObject(this, ExecutorBase::_objectList); 38 40 39 41 // What Parameters have we got … … 58 60 59 61 /** 60 * deconstructs a Executor 62 * clones this element into executor. 63 * @param executor the Executor to clone 61 64 */ 62 Executor::~Executor() 63 {} 64 65 /** 66 * clones this element into executor. 67 */ 68 void Executor::cloning(Executor* executor) const 65 void ExecutorBase::cloning(ExecutorBase* executor) const 69 66 { 70 67 executor->functorType = this->functorType; … … 83 80 * @returns itself 84 81 */ 85 Executor* Executor::defaultValues(const MultiType& value0,82 void ExecutorBase::defaultValues(const MultiType& value0, 86 83 const MultiType& value1, 87 84 const MultiType& value2, … … 91 88 const MultiType& value6) 92 89 { 93 if (this == NULL)94 return NULL;95 96 90 const MultiType* value[5]; 97 91 value[0] = &value0; … … 109 103 } 110 104 } 111 return this;112 105 } 113 106 … … 115 108 * @brief prints out nice information about the Executor 116 109 */ 117 void Executor ::debug()110 void ExecutorBase::debug() 118 111 { 119 120 112 } -
branches/new_class_id/src/lib/util/executor/executor.h
r9715 r9727 18 18 Executor_Objective = 1, 19 19 Executor_Static = 2, 20 21 Executor_NoLoadString = 8,22 20 } Executor_Type; 23 21 … … 36 34 * Functions with many types (@see functor_list.h) 37 35 */ 38 class Executor : public BaseObject36 class ExecutorBase : public BaseObject 39 37 { 40 ObjectListDeclaration(Executor );41 42 virtual ~Executor();38 ObjectListDeclaration(ExecutorBase); 39 public: 40 // virtual bool operator==(const Executor* executor) const = 0; 43 41 44 virtual Executor* clone () const = 0;45 // virtual bool operator==(const Executor* executor) const = 0;42 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 43 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 46 44 47 // SETTING up the EXECUTOR 48 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 49 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 50 const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL, 51 const MultiType& param6 = MT_NULL); 52 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 53 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 45 // EXECUTE 46 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 47 // virtual void operator()(BaseObject* object, int& count, void* values) const = 0; 48 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 49 // virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 54 50 55 // EXECUTE 56 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 57 virtual void operator()(BaseObject* object, int& count, void* values) const = 0; 58 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 59 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 51 // RETRIEVE INFORMATION 52 /** @returns the Type of this Function (either static or objective) */ 53 inline long getType() const { return this->functorType; }; 54 /** @returns the Count of Parameters this Executor takes */ 55 inline unsigned int getParamCount() const { return this->paramCount; }; 56 /** @returns true if the Executor has a return Value. */ 57 inline bool hasRetVal() const { return bRetVal; }; 60 58 61 // RETRIEVE INFORMATION 62 /** @returns the Type of this Function (either static or objective) */ 63 inline long getType() const { return this->functorType; }; 64 /** @returns the Count of Parameters this Executor takes */ 65 inline unsigned int getParamCount() const { return this->paramCount; }; 59 static void debug(); 66 60 67 static void debug(); 61 protected: 62 ExecutorBase(bool hasRetVal = false, 63 const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 64 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 65 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL, 66 const MultiType& param6 = MT_NULL); 68 67 69 protected:70 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,71 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,72 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,73 const MultiType& param6 = MT_NULL);68 // SETTING up the EXECUTOR 69 void defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 70 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 71 const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL, 72 const MultiType& param6 = MT_NULL); 74 73 75 void cloning(Executor* executor) const;74 void cloning(ExecutorBase* executor) const; 76 75 77 protected: 78 short functorType; //!< The type of Function we've got (either static or objective). 79 unsigned int paramCount; //!< the count of parameters. 80 MultiType defaultValue[7]; //!< Default Values. 76 protected: 77 short functorType; //!< The type of Function we've got (either static or objective). 78 unsigned int paramCount; //!< the count of parameters. 79 MultiType defaultValue[7]; //!< Default Values. 80 81 bool bRetVal; //!< True if the Executor has a return Value. 81 82 }; 83 84 template <typename CallType> class Executor : public ExecutorBase 85 { 86 public: 87 virtual Executor<CallType>* clone () const = 0; 88 89 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 90 virtual void operator()(BaseObject* object, CallType& values) const = 0; 91 92 /** 93 * @brief set the default values of the executor 94 * @param value0 the first default value 95 * @param value1 the second default value 96 * @param value2 the third default value 97 * @param value3 the fourth default value 98 * @param value4 the fifth default value 99 * @returns itself 100 * @note: THIS FUNCTION WILL BE REPLACED BY A CONFIGURATOR (most probably). 101 */ 102 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 103 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 104 const MultiType& value4 = MT_NULL, const MultiType& value5 = MT_NULL, 105 const MultiType& value6 = MT_NULL) 106 { 107 this->ExecutorBase::defaultValues(value0, value1, value2, value3, value4, value5, value6); 108 return this; 109 } 110 111 112 113 protected: 114 Executor(bool hasRetVal, 115 const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 116 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 117 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL, 118 const MultiType& param6 = MT_NULL) 119 : ExecutorBase(hasRetVal, param0, param1, param2, param3, param4, param5, param6) 120 {} 121 }; 122 123 82 124 83 125 #include "executor/executor_functional.h" -
branches/new_class_id/src/lib/util/executor/executor_functional.h
r9406 r9727 94 94 /////////// 95 95 //! @brief ExecutorClass, that can execute Functions without any parameters. 96 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor 96 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor<const SubString> 97 97 { 98 98 private: … … 106 106 */ 107 107 __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST ) 108 : Executor ()108 : Executor<const SubString>(false) 109 109 { 110 110 this->functorType = Executor_Objective; … … 132 132 * @returns a new Executor that's a copy of this one. 133 133 */ 134 virtual Executor * clone() const134 virtual Executor<const SubString>* clone() const 135 135 { 136 136 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(this->functionPointer); … … 144 144 /////////// 145 145 //! @brief ExecutorClass, that can execute Functions with one parameter. 146 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor 146 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<const SubString> 147 147 { 148 148 private: … … 156 156 */ 157 157 __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) 158 : Executor (ExecutorParamType<type0>())158 : Executor<const SubString>(false, ExecutorParamType<type0>()) 159 159 { 160 160 this->functorType = Executor_Objective; … … 186 186 * @returns a new Executor that's a copy of this one. 187 187 */ 188 virtual Executor * clone() const188 virtual Executor<const SubString>* clone() const 189 189 { 190 190 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0>(this->functionPointer); … … 196 196 /////////// 197 197 //! @brief ExecutorClass, that can execute Functions with two parameters. 198 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor 198 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<const SubString> 199 199 { 200 200 private: … … 208 208 */ 209 209 __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) 210 : Executor (ExecutorParamType<type0>(), ExecutorParamType<type1>())210 : Executor<const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>()) 211 211 { 212 212 this->functorType = Executor_Objective; … … 239 239 * @returns a new Executor that's a copy of this one. 240 240 */ 241 virtual Executor * clone() const241 virtual Executor<const SubString>* clone() const 242 242 { 243 243 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0, type1>(this->functionPointer); … … 250 250 /////////// 251 251 //! @brief ExecutorClass, that can execute Functions with three parameters. 252 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor 252 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<const SubString> 253 253 { 254 254 private: … … 262 262 */ 263 263 __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) 264 : Executor (ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())264 : Executor<const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 265 265 { 266 266 this->functorType = Executor_Objective; … … 295 295 * @returns a new Executor that's a copy of this one. 296 296 */ 297 virtual Executor * clone() const297 virtual Executor<const SubString>* clone() const 298 298 { 299 299 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0, type1, type2>(this->functionPointer); … … 307 307 /////////// 308 308 //! @brief ExecutorClass, that can execute Functions with four parameters. 309 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor 309 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<const SubString> 310 310 { 311 311 private: … … 319 319 */ 320 320 __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) 321 : Executor (ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())321 : Executor<const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 322 322 { 323 323 this->functorType = Executor_Objective; … … 354 354 * @returns a new Executor that's a copy of this one. 355 355 */ 356 virtual Executor * clone() const356 virtual Executor<const SubString>* clone() const 357 357 { 358 358 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0, type1, type2, type3>(this->functionPointer); … … 366 366 /////////// 367 367 //! @brief ExecutorClass, that can execute Functions with five parameters. 368 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor 368 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<const SubString> 369 369 { 370 370 private: … … 378 378 */ 379 379 __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) 380 : Executor (ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())380 : Executor<const SubString>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 381 381 { 382 382 this->functorType = Executor_Objective; … … 415 415 * @returns a new Executor that's a copy of this one. 416 416 */ 417 virtual Executor * clone() const417 virtual Executor<const SubString>* clone() const 418 418 { 419 419 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer); … … 427 427 */ 428 428 #define EXECUTOR_FUNCTIONAL_CREATOR0() \ 429 template<class T> Executor * createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \429 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ 430 430 { \ 431 431 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \ … … 437 437 */ 438 438 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \ 439 template<class T> Executor * createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \439 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 440 440 { \ 441 441 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \ … … 448 448 */ 449 449 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \ 450 template<class T> Executor * createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \450 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 451 451 { \ 452 452 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \ … … 460 460 */ 461 461 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \ 462 template<class T> Executor * createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \462 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 463 463 { \ 464 464 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \ … … 473 473 */ 474 474 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \ 475 template<class T> Executor * createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \475 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 476 476 { \ 477 477 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \ … … 487 487 */ 488 488 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \ 489 template<class T> Executor * createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \489 template<class T> Executor<const SubString>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 490 490 { \ 491 491 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \ -
branches/new_class_id/src/lib/util/executor/executor_lua.h
r9006 r9727 40 40 /////////// 41 41 //! Executes a Function with a lua_State* parameter. 42 template<class T> class ExecutorLua0 : public Executor 43 { 44 public: 45 /** 46 * @brief Constructor of a ExecutorXML 47 * @param function a Function to call 48 */ 49 ExecutorLua0(void(T::*function)()) 50 : Executor() 51 { 52 this->functionPointer = function; 53 this->functorType = Executor_Objective | Executor_NoLoadString; 54 } 55 56 /** 57 * @brief executes the Command on BaseObject 58 * @param object the BaseObject to execute this Executor on 59 * @param loadString ignored in this case 60 */ 61 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 62 { 63 PRINTF(1)("no usefull executor\n"); 64 } 65 66 virtual void operator()(BaseObject* object, int& count, void* values) const 67 { 68 (dynamic_cast<T*>(object)->*(functionPointer))(); 69 count = 0; 70 } 71 72 /** 73 * @returns a _new_ Copy of this Executor 74 */ 75 virtual Executor* clone () const 76 { 77 return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 78 } 79 private: 80 void (T::*functionPointer)(); 42 template<class T> class ExecutorLua0 : public Executor<lua_State*> 43 { 44 public: 45 /** 46 * @brief Constructor of a ExecutorXML 47 * @param function a Function to call 48 */ 49 ExecutorLua0(void(T::*function)()) 50 : Executor<lua_State*>(false) 51 { 52 this->functionPointer = function; 53 this->functorType = Executor_Objective; 54 } 55 56 57 virtual void operator()(BaseObject* object, lua_State*& state) const 58 { 59 (dynamic_cast<T*>(object)->*(functionPointer))(); 60 } 61 62 /** 63 * @returns a _new_ Copy of this Executor 64 */ 65 virtual Executor<lua_State*>* clone () const 66 { 67 return new ExecutorLua0<T>(ExecutorLua0<T>(this->functionPointer)); 68 } 69 private: 70 void (T::*functionPointer)(); 81 71 }; 82 72 … … 87 77 /////////// 88 78 //! Executes a Function with a lua_State* parameter. 89 template<class T, typename type0> class ExecutorLua1 : public Executor 90 { 91 public: 92 /** 93 * @brief Constructor of a ExecutorXML 94 * @param function a Function to call 95 */ 96 ExecutorLua1(void(T::*function)(type0)) 97 : Executor(ExecutorParamType<type0>()) 98 { 99 this->functionPointer = function; 100 this->functorType = Executor_Objective | Executor_NoLoadString; 101 } 102 103 /** 104 * @brief executes the Command on BaseObject 105 * @param object the BaseObject to execute this Executor on 106 * @param loadString ignored in this case 107 */ 108 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 109 { 110 PRINTF(1)("no usefull executor\n"); 111 } 112 113 virtual void operator()(BaseObject* object, int& count, void* values) const 114 { 115 lua_State* state = (lua_State*)values; 116 count = 0; 117 118 (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1)); 119 } 120 121 /** 122 * @returns a _new_ Copy of this Executor 123 */ 124 virtual Executor* clone () const 125 { 126 return new ExecutorLua1<T, type0>((this->functionPointer)); 127 } 128 private: 129 void (T::*functionPointer)(type0); 79 template<class T, typename type0> class ExecutorLua1 : public Executor<lua_State*> 80 { 81 public: 82 /** 83 * @brief Constructor of a ExecutorXML 84 * @param function a Function to call 85 */ 86 ExecutorLua1(void(T::*function)(type0)) 87 : Executor<lua_State*>(false, ExecutorParamType<type0>()) 88 { 89 this->functionPointer = function; 90 this->functorType = Executor_Objective; 91 } 92 93 virtual void operator()(BaseObject* object, lua_State*& state) const 94 { 95 (dynamic_cast<T*>(object)->*(functionPointer))(fromLua<type0>(state, 1)); 96 } 97 98 /** 99 * @returns a _new_ Copy of this Executor 100 */ 101 virtual Executor<lua_State*>* clone () const 102 { 103 return new ExecutorLua1<T, type0>((this->functionPointer)); 104 } 105 private: 106 void (T::*functionPointer)(type0); 130 107 }; 131 108 … … 136 113 /////////// 137 114 //! Executes a Function with a lua_State* parameter. 138 template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor 139 { 140 public: 141 /** 142 * @brief Constructor of a ExecutorXML 143 * @param function a Function to call 144 */ 145 ExecutorLua2(void(T::*function)(type0, type1)) 146 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) 147 { 148 this->functionPointer = function; 149 this->functorType = Executor_Objective | Executor_NoLoadString; 150 } 151 152 /** 153 * @brief executes the Command on BaseObject 154 * @param object the BaseObject to execute this Executor on 155 * @param loadString ignored in this case 156 */ 157 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 158 { 159 PRINTF(1)("no usefull executor\n"); 160 } 161 162 virtual void operator()(BaseObject* object, int& count, void* values) const 163 { 164 lua_State* state = (lua_State*)values; 165 count = 0; 166 167 (dynamic_cast<T*>(object)->*(functionPointer))( 168 fromLua<type0>(state, 1), 115 template<class T, typename type0, typename type1> class ExecutorLua2 : public Executor<lua_State*> 116 { 117 public: 118 /** 119 * @brief Constructor of a ExecutorXML 120 * @param function a Function to call 121 */ 122 ExecutorLua2(void(T::*function)(type0, type1)) 123 : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>()) 124 { 125 this->functionPointer = function; 126 this->functorType = Executor_Objective; 127 } 128 129 /** 130 * @brief executes the Command on BaseObject 131 * @param object the BaseObject to execute this Executor on 132 * @param loadString ignored in this case 133 */ 134 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 135 { 136 PRINTF(1)("no usefull executor\n"); 137 } 138 139 virtual void operator()(BaseObject* object, lua_State*& state) const 140 { 141 (dynamic_cast<T*>(object)->*(functionPointer))( 142 fromLua<type0>(state, 1), 169 143 fromLua<type1>(state, 2) ); 170 171 172 173 174 175 virtual Executor* clone () const176 177 178 179 180 144 } 145 146 /** 147 * @returns a _new_ Copy of this Executor 148 */ 149 virtual Executor<lua_State*>* clone () const 150 { 151 return new ExecutorLua2<T, type0, type1>(this->functionPointer); 152 } 153 private: 154 void (T::*functionPointer)(type0, type1); 181 155 }; 182 156 … … 186 160 /////////// 187 161 //! Executes a Function with a lua_State* parameter. 188 template<class T, typename type0, typename type1, typename type2> class ExecutorLua3 : public Executor 189 { 190 public: 191 /** 192 * @brief Constructor of a ExecutorXML 193 * @param function a Function to call 194 */ 195 ExecutorLua3(void(T::*function)(type0, type1, type2)) 196 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 197 { 198 this->functionPointer = function; 199 this->functorType = Executor_Objective | Executor_NoLoadString; 200 } 201 202 /** 203 * @brief executes the Command on BaseObject 204 * @param object the BaseObject to execute this Executor on 205 * @param loadString ignored in this case 206 */ 207 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 208 { 209 PRINTF(1)("no usefull executor\n"); 210 } 211 212 virtual void operator()(BaseObject* object, int& count, void* values) const 213 { 214 lua_State* state = (lua_State*)values; 215 count = 0; 216 217 (dynamic_cast<T*>(object)->*(functionPointer))( 218 fromLua<type0>(state, 1), 162 template<class T, typename type0, typename type1, typename type2> class ExecutorLua3 : public Executor<lua_State*> 163 { 164 public: 165 /** 166 * @brief Constructor of a ExecutorXML 167 * @param function a Function to call 168 */ 169 ExecutorLua3(void(T::*function)(type0, type1, type2)) 170 : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 171 { 172 this->functionPointer = function; 173 this->functorType = Executor_Objective; 174 } 175 176 /** 177 * @brief executes the Command on BaseObject 178 * @param object the BaseObject to execute this Executor on 179 * @param loadString ignored in this case 180 */ 181 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 182 { 183 PRINTF(1)("no usefull executor\n"); 184 } 185 186 virtual void operator()(BaseObject* object, lua_State*& state) const 187 { 188 (dynamic_cast<T*>(object)->*(functionPointer))( 189 fromLua<type0>(state, 1), 219 190 fromLua<type1>(state, 2), 220 191 fromLua<type2>(state, 3) ); 221 222 223 224 225 226 virtual Executor* clone () const227 228 229 230 231 192 } 193 194 /** 195 * @returns a _new_ Copy of this Executor 196 */ 197 virtual Executor<lua_State*>* clone () const 198 { 199 return new ExecutorLua3<T, type0, type1, type2>(this->functionPointer); 200 } 201 private: 202 void (T::*functionPointer)(type0, type1, type2); 232 203 }; 233 204 … … 237 208 /////////// 238 209 //! Executes a Function with a lua_State* parameter. 239 template<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), 210 template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor<lua_State*> 211 { 212 public: 213 /** 214 * @brief Constructor of a ExecutorXML 215 * @param function a Function to call 216 */ 217 ExecutorLua4(void(T::*function)(type0, type1, type2, type3)) 218 : Executor<lua_State*>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 219 { 220 this->functionPointer = function; 221 this->functorType = Executor_Objective; 222 } 223 224 virtual void operator()(BaseObject* object, lua_State*& state) const 225 { 226 (dynamic_cast<T*>(object)->*(functionPointer))( 227 fromLua<type0>(state, 1), 270 228 fromLua<type1>(state, 2), 271 229 fromLua<type2>(state, 3), 272 230 fromLua<type3>(state, 4) ); 273 274 275 276 277 278 virtual Executor* clone () const279 280 281 282 283 231 } 232 233 /** 234 * @returns a _new_ Copy of this Executor 235 */ 236 virtual Executor<lua_State*>* clone () const 237 { 238 return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer); 239 } 240 private: 241 void (T::*functionPointer)(type0, type1, type2, type3); 284 242 }; 285 243 … … 296 254 /////////// 297 255 //! Executes a Function with a lua_State* parameter. 298 template<class T, typename ret> class ExecutorLua0ret : public Executor 299 { 300 public: 301 /** 302 * @brief Constructor of a ExecutorXML 303 * @param function a Function to call 304 */ 305 ExecutorLua0ret(ret (T::*function)()) 306 : Executor() 307 { 308 this->functionPointer = function; 309 this->functorType = Executor_Objective | Executor_NoLoadString; 310 } 311 312 /** 313 * @brief executes the Command on BaseObject 314 * @param object the BaseObject to execute this Executor on 315 * @param loadString ignored in this case 316 */ 317 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 318 { 319 PRINTF(1)("no usefull executor\n"); 320 } 321 322 virtual void operator()(BaseObject* object, int& count, void* values) const 323 { 324 lua_State* state = (lua_State*)values; 325 count = 1; 326 327 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))()); 328 } 329 330 /** 331 * @returns a _new_ Copy of this Executor 332 */ 333 virtual Executor* clone () const 334 { 335 return new ExecutorLua0ret<T, ret>(this->functionPointer); 336 } 337 private: 338 ret (T::*functionPointer)(); 256 template<class T, typename ret> class ExecutorLua0ret : public Executor<lua_State*> 257 { 258 public: 259 /** 260 * @brief Constructor of a ExecutorXML 261 * @param function a Function to call 262 */ 263 ExecutorLua0ret(ret (T::*function)()) 264 : Executor<lua_State*>(true) 265 { 266 this->functionPointer = function; 267 this->functorType = Executor_Objective; 268 } 269 270 virtual void operator()(BaseObject* object, lua_State*& state) const 271 { 272 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))()); 273 } 274 275 /** 276 * @returns a _new_ Copy of this Executor 277 */ 278 virtual Executor<lua_State*>* clone () const 279 { 280 return new ExecutorLua0ret<T, ret>(this->functionPointer); 281 } 282 private: 283 ret (T::*functionPointer)(); 339 284 }; 340 285 … … 345 290 /////////// 346 291 //! Executes a Function with a lua_State* parameter. 347 template<class T, typename ret, typename type0> class ExecutorLua1ret : public Executor 348 { 349 public: 350 /** 351 * @brief Constructor of a ExecutorXML 352 * @param function a Function to call 353 */ 354 ExecutorLua1ret(ret (T::*function)(type0)) 355 : Executor(ExecutorParamType<type0>()) 356 { 357 this->functionPointer = function; 358 this->functorType = Executor_Objective | Executor_NoLoadString; 359 } 360 361 /** 362 * @brief executes the Command on BaseObject 363 * @param object the BaseObject to execute this Executor on 364 * @param loadString ignored in this case 365 */ 366 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 367 { 368 PRINTF(1)("no usefull executor\n"); 369 } 370 371 virtual void operator()(BaseObject* object, int& count, void* values) const 372 { 373 lua_State* state = (lua_State*)values; 374 count = 1; 375 376 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 377 fromLua<type0>(state, 1))); 378 } 379 380 /** 381 * @returns a _new_ Copy of this Executor 382 */ 383 virtual Executor* clone () const 384 { 385 return new ExecutorLua1ret<T, ret, type0>(this->functionPointer); 386 } 387 private: 388 ret (T::*functionPointer)(type0); 292 template<class T, typename ret, typename type0> class ExecutorLua1ret : public Executor<lua_State*> 293 { 294 public: 295 /** 296 * @brief Constructor of a ExecutorXML 297 * @param function a Function to call 298 */ 299 ExecutorLua1ret(ret (T::*function)(type0)) 300 : Executor<lua_State*>(true, ExecutorParamType<type0>()) 301 { 302 this->functionPointer = function; 303 this->functorType = Executor_Objective; 304 } 305 306 virtual void operator()(BaseObject* object, lua_State*& state) const 307 { 308 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 309 fromLua<type0>(state, 1))); 310 } 311 312 /** 313 * @returns a _new_ Copy of this Executor 314 */ 315 virtual Executor<lua_State*>* clone () const 316 { 317 return new ExecutorLua1ret<T, ret, type0>(this->functionPointer); 318 } 319 private: 320 ret (T::*functionPointer)(type0); 389 321 }; 390 322 … … 393 325 /////////// 394 326 //! Executes a Function with a lua_State* parameter. 395 template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor 396 { 397 public: 398 /** 399 * @brief Constructor of a ExecutorXML 400 * @param function a Function to call 401 */ 402 ExecutorLua2ret(ret (T::*function)(type0, type1)) 403 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) 404 { 405 this->functionPointer = function; 406 this->functorType = Executor_Objective | Executor_NoLoadString; 407 } 408 409 /** 410 * @brief executes the Command on BaseObject 411 * @param object the BaseObject to execute this Executor on 412 * @param loadString ignored in this case 413 */ 414 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 415 { 416 PRINTF(1)("no usefull executor\n"); 417 } 418 419 virtual void operator()(BaseObject* object, int& count, void* values) const 420 { 421 lua_State* state = (lua_State*)values; 422 count = 1; 423 424 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 425 fromLua<type0>(state, 1), 426 fromLua<type1>(state, 2) )); 427 } 428 429 /** 430 * @returns a _new_ Copy of this Executor 431 */ 432 virtual Executor* clone () const 433 { 434 return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer); 435 } 436 private: 437 ret (T::*functionPointer)(type0, type1); 327 template<class T, typename ret, typename type0, typename type1> class ExecutorLua2ret : public Executor<lua_State*> 328 { 329 public: 330 /** 331 * @brief Constructor of a ExecutorXML 332 * @param function a Function to call 333 */ 334 ExecutorLua2ret(ret (T::*function)(type0, type1)) 335 : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>()) 336 { 337 this->functionPointer = function; 338 this->functorType = Executor_Objective; 339 } 340 341 virtual void operator()(BaseObject* object, lua_State*& state) const 342 { 343 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 344 fromLua<type0>(state, 1), 345 fromLua<type1>(state, 2) )); 346 } 347 348 /** 349 * @returns a _new_ Copy of this Executor 350 */ 351 virtual Executor<lua_State*>* clone () const 352 { 353 return new ExecutorLua2ret<T, ret, type0, type1>(this->functionPointer); 354 } 355 private: 356 ret (T::*functionPointer)(type0, type1); 438 357 }; 439 358 … … 443 362 /////////// 444 363 //! Executes a Function with a lua_State* parameter. 445 template<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); 364 template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor<lua_State*> 365 { 366 public: 367 /** 368 * @brief Constructor of a ExecutorXML 369 * @param function a Function to call 370 */ 371 ExecutorLua3ret(ret (T::*function)(type0, type1, type2)) 372 : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 373 { 374 this->functionPointer = function; 375 this->functorType = Executor_Objective; 376 } 377 378 /** 379 * @brief executes the Command on BaseObject 380 * @param object the BaseObject to execute this Executor on 381 * @param loadString ignored in this case 382 */ 383 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 384 { 385 PRINTF(1)("no usefull executor\n"); 386 } 387 388 virtual void operator()(BaseObject* object, lua_State*& state) const 389 { 390 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 391 fromLua<type0>(state, 1), 392 fromLua<type1>(state, 2), 393 fromLua<type2>(state, 3) )); 394 } 395 396 /** 397 * @returns a _new_ Copy of this Executor 398 */ 399 virtual Executor<lua_State*>* clone () const 400 { 401 return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer); 402 } 403 private: 404 ret (T::*functionPointer)(type0, type1, type2); 489 405 }; 490 406 … … 494 410 /////////// 495 411 //! Executes a Function with a lua_State* parameter. 496 template<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); 412 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor<lua_State*> 413 { 414 public: 415 /** 416 * @brief Constructor of a ExecutorXML 417 * @param function a Function to call 418 */ 419 ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3)) 420 : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 421 { 422 this->functionPointer = function; 423 this->functorType = Executor_Objective; 424 } 425 426 virtual void operator()(BaseObject* object, lua_State*& state) const 427 { 428 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 429 fromLua<type0>(state, 1), 430 fromLua<type1>(state, 2), 431 fromLua<type2>(state, 3), 432 fromLua<type3>(state, 4) )); 433 } 434 435 /** 436 * @returns a _new_ Copy of this Executor 437 */ 438 virtual Executor<lua_State*>* clone () const 439 { 440 return new ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer); 441 } 442 private: 443 ret (T::*functionPointer)(type0, type1, type2, type3); 541 444 }; 542 445 … … 545 448 /////////// 546 449 //! Executes a Function with a lua_State* parameter. 547 template<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); 450 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor<lua_State*> 451 { 452 public: 453 /** 454 * @brief Constructor of a ExecutorXML 455 * @param function a Function to call 456 */ 457 ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4)) 458 : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 459 { 460 this->functionPointer = function; 461 this->functorType = Executor_Objective; 462 } 463 464 virtual void operator()(BaseObject* object, lua_State*& state) const 465 { 466 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 467 fromLua<type0>(state, 1), 468 fromLua<type1>(state, 2), 469 fromLua<type2>(state, 3), 470 fromLua<type3>(state, 4), 471 fromLua<type4>(state, 5) )); 472 } 473 474 /** 475 * @returns a _new_ Copy of this Executor 476 */ 477 virtual Executor<lua_State*>* clone () const 478 { 479 return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer); 480 } 481 private: 482 ret (T::*functionPointer)(type0, type1, type2, type3, type4); 593 483 }; 594 484 … … 597 487 /////////// 598 488 //! Executes a Function with a lua_State* parameter. 599 template<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); 489 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor<lua_State*> 490 { 491 public: 492 /** 493 * @brief Constructor of a ExecutorXML 494 * @param function a Function to call 495 */ 496 ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5)) 497 : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), 498 ExecutorParamType<type2>(), ExecutorParamType<type3>(), 499 ExecutorParamType<type4>(), ExecutorParamType<type5>()) 500 { 501 this->functionPointer = function; 502 this->functorType = Executor_Objective; 503 } 504 505 virtual void operator()(BaseObject* object, lua_State*& state) const 506 { 507 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 508 fromLua<type0>(state, 1), 509 fromLua<type1>(state, 2), 510 fromLua<type2>(state, 3), 511 fromLua<type3>(state, 4), 512 fromLua<type4>(state, 5), 513 fromLua<type5>(state, 6) )); 514 } 515 516 /** 517 * @returns a _new_ Copy of this Executor 518 */ 519 virtual Executor<lua_State*>* clone () const 520 { 521 return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer); 522 } 523 private: 524 ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5); 648 525 }; 649 526 … … 652 529 /////////// 653 530 //! Executes a Function with a lua_State* parameter. 654 template<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); 531 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor<lua_State*> 532 { 533 public: 534 /** 535 * @brief Constructor of a ExecutorXML 536 * @param function a Function to call 537 */ 538 ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6)) 539 : Executor<lua_State*>(true, ExecutorParamType<type0>(), ExecutorParamType<type1>(), 540 ExecutorParamType<type2>(), ExecutorParamType<type3>(), 541 ExecutorParamType<type4>(), ExecutorParamType<type5>(), 542 ExecutorParamType<type6>()) 543 { 544 this->functionPointer = function; 545 this->functorType = Executor_Objective; 546 } 547 548 virtual void operator()(BaseObject* object, lua_State*& state) const 549 { 550 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 551 fromLua<type0>(state, 1), 552 fromLua<type1>(state, 2), 553 fromLua<type2>(state, 3), 554 fromLua<type3>(state, 4), 555 fromLua<type4>(state, 5), 556 fromLua<type5>(state, 6), 557 fromLua<type6>(state, 7) )); 558 } 559 560 /** 561 * @returns a _new_ Copy of this Executor 562 */ 563 virtual Executor<lua_State*>* clone () const 564 { 565 return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer); 566 } 567 private: 568 ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6); 705 569 }; 706 570 -
branches/new_class_id/src/lib/util/executor/executor_xml.h
r8362 r9727 19 19 * What must be defined is a XML-root to search the ParameterName under an a Function to call. 20 20 */ 21 template<class T> class ExecutorXML : public Executor 21 template<class T> class ExecutorXML : public Executor<const TiXmlElement*> 22 22 { 23 24 23 public: 24 /** 25 25 * @brief Constructor of a ExecutorXML 26 27 28 29 30 ExecutorXML(void(T::*function)(const TiXmlElement*), const TiXmlElement* root, const char*paramName)31 : Executor (MT_EXT1)32 33 PRINTF(4)("Loading %s from XML-element %p\n", paramName, root);26 * @param function a Function to call 27 * @param root The XML root to search paramName under 28 * @param paramName the ParameterName the search in root, and lookup the TiXmlElement from 29 */ 30 ExecutorXML(void(T::*function)(const TiXmlElement*), const TiXmlElement* root, const std::string& paramName) 31 : Executor<const TiXmlElement*>(false, MT_EXT1) 32 { 33 PRINTF(4)("Loading %s from XML-element %p\n", paramName.c_str(), root); 34 34 35 if (likely(root != NULL && paramName!= NULL))36 37 38 35 if (likely(root != NULL)) 36 this->element = root->FirstChildElement(paramName); 37 else 38 this->element = NULL; 39 39 40 this->functionPointer = function; 41 this->functorType = Executor_Objective | Executor_NoLoadString; 42 } 40 this->paramName = paramName; 41 this->functionPointer = function; 42 this->functorType = Executor_Objective; 43 } 43 44 44 /** 45 * @brief clones an ExecutorXML, used to copy this Element. 46 * @returns a _new_ Copy of this Executor 47 */ 48 virtual Executor* clone () const 49 { 50 ExecutorXML<T>* executor = new ExecutorXML<T>(); 51 this->cloning(executor); 52 executor->functionPointer = this->functionPointer; 53 executor->element = this->element; 54 return executor; 55 } 45 /** 46 * @brief clones an ExecutorXML, used to copy this Element. 47 * @returns a _new_ Copy of this Executor 48 */ 49 virtual Executor<const TiXmlElement*>* clone () const 50 { 51 return new ExecutorXML<T>(functionPointer, element, paramName); 52 } 56 53 57 /** 58 * @brief executes the Command on BaseObject 59 * @param object the BaseObject to execute this Executor on 60 * @param loadString ignored in this case 61 */ 62 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 63 { 64 if (object != NULL && this->element != NULL) 65 (dynamic_cast<T*>(object)->*(functionPointer))(this->element); 66 } 54 /** 55 * @brief executes the Command on BaseObject 56 * @param object the BaseObject to execute this Executor on 57 * @param root ignored in this case 58 */ 59 virtual void operator()(BaseObject* object, const TiXmlElement*& element) const 60 { 61 assert (object != NULL); 62 if (this->element != NULL) 63 (dynamic_cast<T*>(object)->*(functionPointer))(this->element); 64 } 67 65 68 virtual void operator()(BaseObject* object, int& count, void* values) const 69 { 70 PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n"); 71 } 72 73 private: 74 /** 75 * @brief used for the copy-(Clone)-constructor 76 */ 77 ExecutorXML() : Executor() { }; 78 79 80 private: 81 void (T::*functionPointer)(const TiXmlElement*); //!< The functionPointer to the function to be called 82 const TiXmlElement* element; //!< The XML-element to call. 66 private: 67 void (T::*functionPointer)(const TiXmlElement*); //!< The functionPointer to the function to be called 68 const TiXmlElement* element; //!< The XML-element to call. 69 std::string paramName; 83 70 }; 84 71
Note: See TracChangeset
for help on using the changeset viewer.