Changeset 9733 in orxonox.OLD for branches/new_class_id/src
- Timestamp:
- Sep 15, 2006, 3:39:51 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
r9732 r9733 18 18 #include "executor.h" 19 19 20 21 20 template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; }; 22 21 template<> MT_Type ExecutorParamType<int>() { return MT_INT; }; … … 25 24 template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; }; 26 25 template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; }; 27 28 29 30 /**31 * @brief constructs and registers a new Command32 * @param commandName the name of the Command33 * @param className the name of the class to apply this command to34 * @param paramCount the count of parameters this command takes35 */36 ExecutorBase::ExecutorBase(bool hasRetVal,37 const MultiType& param0,38 const MultiType& param1,39 const MultiType& param2,40 const MultiType& param3,41 const MultiType& param4,42 const MultiType& param5,43 const MultiType& param6)44 : bRetVal(hasRetVal)45 {46 // What Parameters have we got47 this->defaultValue[0] = param0;48 this->defaultValue[1] = param1;49 this->defaultValue[2] = param2;50 this->defaultValue[3] = param3;51 this->defaultValue[4] = param4;52 this->defaultValue[5] = param5;53 this->defaultValue[6] = param6;54 55 this->paramCount = 0;56 for (unsigned int i = 0; i <= EXECUTOR_MAX_ARGUMENTS; i++)57 {58 if (this->defaultValue[i] == MT_NULL || i == EXECUTOR_MAX_ARGUMENTS)59 {60 this->paramCount = i;61 break;62 }63 else64 this->defaultValue[i].storeString();65 }66 }67 68 /**69 * clones this element into executor.70 * @param executor the Executor to clone71 */72 void ExecutorBase::cloning(ExecutorBase* executor) const73 {74 executor->functorType = this->functorType;75 executor->paramCount = this->paramCount;76 for (unsigned int i = 0; i < this->paramCount; i++)77 executor->defaultValue[i] = this->defaultValue[i];78 }79 80 /**81 * @brief set the default values of the executor82 * @param value0 the first default value83 * @param value1 the second default value84 * @param value2 the third default value85 * @param value3 the fourth default value86 * @param value4 the fifth default value87 * @returns itself88 */89 void ExecutorBase::defaultValues(const MultiType& value0,90 const MultiType& value1,91 const MultiType& value2,92 const MultiType& value3,93 const MultiType& value4,94 const MultiType& value5,95 const MultiType& value6)96 {97 const MultiType* value[5];98 value[0] = &value0;99 value[1] = &value1;100 value[2] = &value2;101 value[3] = &value3;102 value[4] = &value4;103 value[5] = &value5;104 value[6] = &value6;105 for (unsigned int i = 0; i < this->paramCount; i++)106 {107 if (*value[i] != MT_NULL)108 {109 this->defaultValue[i].setValueOf(*value[i]);110 this->defaultValue[i].storeString();111 }112 }113 }114 115 /**116 * @brief prints out nice information about the Executor117 */118 void ExecutorBase::debug()119 {120 } -
branches/new_class_id/src/lib/util/executor/executor.h
r9732 r9733 9 9 #include "base_object.h" 10 10 11 #include "helper_functions.h"12 11 #include "multi_type.h" 13 #include "functor_list.h" //< MUST BE INCLUDED HERE AT LEAST ONCE.14 15 //! an enumerator for the definition of the Type.16 typedef enum {17 Executor_Objective,18 Executor_Static,19 } Executor_Type;20 12 21 13 //! The maximum Count of Arguments of the Executor … … 47 39 * Functions with many types (@see functor_list.h) 48 40 */ 49 class ExecutorBase 41 template <typename CallType> class Executor 50 42 { 51 43 public: 44 //! an enumerator for the definition of the Type. 45 typedef enum { 46 FunctionDefault, 47 FunctionStatic, 48 FunctionConst, 49 } FunctionType; 50 51 public: 52 virtual ~Executor() {}; 53 54 // RETRIEVE INFORMATION 52 55 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 53 56 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 57 /** @returns the default Values as a List */ 58 inline const MultiType* const getDefaultValues() { return defaultValue; }; 54 59 55 // RETRIEVE INFORMATION56 60 /** @returns the Type of this Function (either static or objective) */ 57 inline Executor_Type getType() const { return this->functorType; };61 inline FunctionType getType() const { return this->functionType; }; 58 62 59 63 /** @returns the Count of Parameters this Executor takes */ … … 61 65 /** @returns true if the Executor has a return Value. */ 62 66 inline bool hasRetVal() const { return bRetVal; }; 63 64 static void debug();65 66 protected:67 virtual ~ExecutorBase() {};68 ExecutorBase(bool hasRetVal = false,69 const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,70 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,71 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,72 const MultiType& param6 = MT_NULL);73 74 // SETTING up the EXECUTOR75 void defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,76 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,77 const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL,78 const MultiType& param6 = MT_NULL);79 80 void cloning(ExecutorBase* executor) const;81 82 protected:83 Executor_Type functorType; //!< The type of Function we've got (either static or objective).84 unsigned int paramCount; //!< the count of parameters.85 MultiType defaultValue[7]; //!< Default Values.86 87 private:88 const bool bRetVal; //!< True if the Executor has a return Value.89 const bool bStaticFunction; //!< A Executor to a Static Function90 const bool bConstFunction; //!< A Executor to a Constant Function91 };92 93 template <typename CallType> class Executor : public ExecutorBase94 {95 public:96 virtual Executor<CallType>* clone () const = 0;97 67 98 68 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ … … 114 84 const MultiType& value6 = MT_NULL) 115 85 { 116 this->ExecutorBase::defaultValues(value0, value1, value2, value3, value4, value5, value6); 86 const MultiType* value[5]; 87 value[0] = &value0; 88 value[1] = &value1; 89 value[2] = &value2; 90 value[3] = &value3; 91 value[4] = &value4; 92 value[5] = &value5; 93 value[6] = &value6; 94 for (unsigned int i = 0; i < this->paramCount; i++) 95 { 96 if (*value[i] != MT_NULL) 97 { 98 this->defaultValue[i].setValueOf(*value[i]); 99 this->defaultValue[i].storeString(); 100 } 101 } 117 102 return this; 118 103 } 104 105 virtual Executor<CallType>* clone () const = 0; 119 106 120 107 protected: … … 124 111 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL, 125 112 const MultiType& param6 = MT_NULL) 126 : ExecutorBase(hasRetVal, param0, param1, param2, param3, param4, param5, param6) 127 {}} 128 ; 113 : bRetVal(hasRetVal) 114 { 115 // What Parameters have we got 116 this->defaultValue[0] = param0; 117 this->defaultValue[1] = param1; 118 this->defaultValue[2] = param2; 119 this->defaultValue[3] = param3; 120 this->defaultValue[4] = param4; 121 this->defaultValue[5] = param5; 122 this->defaultValue[6] = param6; 123 124 this->paramCount = 0; 125 for (unsigned int i = 0; i <= EXECUTOR_MAX_ARGUMENTS; i++) 126 { 127 if (this->defaultValue[i] == MT_NULL || i == EXECUTOR_MAX_ARGUMENTS) 128 { 129 this->paramCount = i; 130 break; 131 } 132 else 133 this->defaultValue[i].storeString(); 134 } 135 } 136 137 138 139 protected: 140 unsigned int paramCount; //!< the count of parameters. 141 MultiType defaultValue[7]; //!< Default Values. 142 143 FunctionType functionType; //!< What Type of Function it is. 144 private: 145 const bool bRetVal; //!< True if the Executor has a return Value. 146 }; 129 147 130 148 #endif /* _EXECUTOR_H */ -
branches/new_class_id/src/lib/util/executor/executor_functional.h
r9732 r9733 140 140 : Executor<CallType>(false) 141 141 { 142 this->funct orType = Executor_Objective;142 this->functionType = Executor<CallType>::FunctionDefault; 143 143 this->functionPointer = functionPointer; 144 144 }; … … 185 185 : Executor<CallType>(false, ExecutorParamType<type0>()) 186 186 { 187 this->funct orType = Executor_Objective;187 this->functionType = Executor<CallType>::FunctionDefault; 188 188 this->functionPointer = functionPointer; 189 189 }; … … 229 229 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>()) 230 230 { 231 this->funct orType = Executor_Objective;231 this->functionType = Executor<CallType>::FunctionDefault; 232 232 this->functionPointer = functionPointer; 233 233 }; … … 275 275 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 276 276 { 277 this->funct orType = Executor_Objective;277 this->functionType = Executor<CallType>::FunctionDefault; 278 278 this->functionPointer = functionPointer; 279 279 }; … … 323 323 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 324 324 { 325 this->funct orType = Executor_Objective;325 this->functionType = Executor<CallType>::FunctionDefault; 326 326 this->functionPointer = functionPointer; 327 327 }; … … 372 372 : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 373 373 { 374 this->funct orType = Executor_Objective;374 this->functionType = Executor<CallType>::FunctionDefault; 375 375 this->functionPointer = functionPointer; 376 376 }; -
branches/new_class_id/src/lib/util/executor/executor_lua.h
r9728 r9733 51 51 { 52 52 this->functionPointer = function; 53 this->funct orType = Executor_Objective;53 this->functionType = Executor<lua_State*>::FunctionDefault; 54 54 } 55 55 … … 88 88 { 89 89 this->functionPointer = function; 90 this->funct orType = Executor_Objective;90 this->functionType = Executor<lua_State*>::FunctionDefault; 91 91 } 92 92 … … 124 124 { 125 125 this->functionPointer = function; 126 this->funct orType = Executor_Objective;126 this->functionType = Executor<lua_State*>::FunctionDefault; 127 127 } 128 128 … … 161 161 { 162 162 this->functionPointer = function; 163 this->funct orType = Executor_Objective;163 this->functionType = Executor<lua_State*>::FunctionDefault; 164 164 } 165 165 … … 200 200 { 201 201 this->functionPointer = function; 202 this->funct orType = Executor_Objective;202 this->functionType = Executor<lua_State*>::FunctionDefault; 203 203 } 204 204 … … 246 246 { 247 247 this->functionPointer = function; 248 this->funct orType = Executor_Objective;248 this->functionType = Executor<lua_State*>::FunctionDefault; 249 249 } 250 250 … … 282 282 { 283 283 this->functionPointer = function; 284 this->funct orType = Executor_Objective;284 this->functionType = Executor<lua_State*>::FunctionDefault; 285 285 } 286 286 … … 317 317 { 318 318 this->functionPointer = function; 319 this->funct orType = Executor_Objective;319 this->functionType = Executor<lua_State*>::FunctionDefault; 320 320 } 321 321 … … 354 354 { 355 355 this->functionPointer = function; 356 this->funct orType = Executor_Objective;356 this->functionType = Executor<lua_State*>::FunctionDefault; 357 357 } 358 358 … … 392 392 { 393 393 this->functionPointer = function; 394 this->funct orType = Executor_Objective;394 this->functionType = Executor<lua_State*>::FunctionDefault; 395 395 } 396 396 … … 430 430 { 431 431 this->functionPointer = function; 432 this->funct orType = Executor_Objective;432 this->functionType = Executor<lua_State*>::FunctionDefault; 433 433 } 434 434 … … 471 471 { 472 472 this->functionPointer = function; 473 this->funct orType = Executor_Objective;473 this->functionType = Executor<lua_State*>::FunctionDefault; 474 474 } 475 475 … … 514 514 { 515 515 this->functionPointer = function; 516 this->funct orType = Executor_Objective;516 this->functionType = Executor<lua_State*>::FunctionDefault; 517 517 } 518 518 -
branches/new_class_id/src/lib/util/executor/executor_xml.h
r9727 r9733 40 40 this->paramName = paramName; 41 41 this->functionPointer = function; 42 this->funct orType = Executor_Objective;42 this->functionType = FunctionDefault; 43 43 } 44 44
Note: See TracChangeset
for help on using the changeset viewer.