Changeset 7985 in orxonox.OLD for branches/gui/src/lib/util/executor
- Timestamp:
- May 30, 2006, 6:25:19 PM (19 years ago)
- Location:
- branches/gui/src/lib/util/executor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/util/executor/executor.h
r7725 r7985 38 38 class Executor : public BaseObject 39 39 { 40 public:41 virtual ~Executor();40 public: 41 virtual ~Executor(); 42 42 43 virtual Executor* clone () const = 0;43 virtual Executor* clone () const = 0; 44 44 45 // SETTING up the EXECUTOR46 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,47 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,48 const MultiType& value4 = MT_NULL);49 /** @param i the i'th defaultValue, @returns reference to the MultiType */50 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };45 // SETTING up the EXECUTOR 46 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 47 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 48 const MultiType& value4 = MT_NULL); 49 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 50 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 51 51 52 // EXECUTE 53 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 54 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 55 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/ 56 void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); }; 52 // EXECUTE 53 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const = 0; 57 54 58 // RETRIEVE INFORMATION 59 /** @returns the Type of this Function (either static or objective) */ 60 inline long getType() const { return this->functorType; }; 61 /** @returns the Count of Parameters this Executor takes */ 62 inline unsigned int getParamCount() const { return this->paramCount; }; 55 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 56 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 57 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/ 58 void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); }; 63 59 64 static void debug();65 60 66 protected: 67 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 68 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 69 const MultiType& param4 = MT_NULL); 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; }; 70 66 71 void cloning(Executor* executor) const;67 static void debug(); 72 68 73 protected: 74 short functorType; //!< The type of Function we've got (either static or objective). 75 unsigned int paramCount; //!< the count of parameters. 76 MultiType defaultValue[5]; //!< Default Values. 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); 73 74 void cloning(Executor* executor) const; 75 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[5]; //!< Default Values. 77 80 }; 78 81 -
branches/gui/src/lib/util/executor/executor_functional.cc
r7728 r7985 34 34 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return ExecutorFunctional_returningString_from = isString(input, defaultValue); }; 35 35 36 37 template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); }; 38 template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); } 39 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); }; 40 template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); }; 41 template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); }; 42 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getString(); }; 43 44 36 45 template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); }; 37 46 template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); }; … … 40 49 template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); }; 41 50 template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return ExecutorFunctional_returningString_default = defaultValues[i].getString(); }; 51 52 42 53 43 54 -
branches/gui/src/lib/util/executor/executor_functional.h
r7725 r7985 33 33 template<> MT_Type ExecutorParamType<const std::string&>(); 34 34 35 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };35 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; }; 36 36 template<> bool fromString<bool>(const std::string& input, bool defaultValue); 37 37 template<> int fromString<int>(const std::string& input, int defaultValue); … … 40 40 template<> char fromString<char>(const std::string& input, char defaultValue); 41 41 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue); 42 43 template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ }; 44 template<> bool fromMulti<bool>(const MultiType& multi); 45 template<> int fromMulti<int>(const MultiType& multi); 46 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi); 47 template<> float fromMulti<float>(const MultiType& multi); 48 template<> char fromMulti<char>(const MultiType& multi); 49 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi); 50 42 51 43 52 template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; }; … … 81 90 #endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */ 82 91 92 /////////// 93 //// 0 //// 94 /////////// 83 95 //! @brief ExecutorClass, that can execute Functions without any parameters. 84 96 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor … … 110 122 }; 111 123 124 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 125 { 126 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); 127 } 128 112 129 /** 113 130 * @brief copies the Executor … … 120 137 }; 121 138 139 140 141 /////////// 142 //// 1 //// 143 /////////// 122 144 //! @brief ExecutorClass, that can execute Functions with one parameter. 123 145 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor … … 138 160 this->functionPointer = functionPointer; 139 161 }; 162 163 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 164 { 165 switch(count) 166 { 167 case 0: 168 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(fromMulti<type0>(this->defaultValue[0])); 169 default: 170 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(fromMulti<type0>(values[0])); 171 } 172 } 173 140 174 141 175 /** … … 166 200 }; 167 201 202 /////////// 203 //// 2 //// 204 /////////// 168 205 //! @brief ExecutorClass, that can execute Functions with two parameters. 169 206 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor … … 197 234 }; 198 235 236 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 237 { 238 } 239 199 240 /** 200 241 * @brief copies the Executor … … 208 249 209 250 251 /////////// 252 //// 3 //// 253 /////////// 210 254 //! @brief ExecutorClass, that can execute Functions with three parameters. 211 255 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor … … 240 284 }; 241 285 286 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 287 { 288 } 289 242 290 /** 243 291 * @brief copies the Executor … … 252 300 253 301 302 /////////// 303 //// 4 //// 304 /////////// 254 305 //! @brief ExecutorClass, that can execute Functions with four parameters. 255 306 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor … … 285 336 }; 286 337 338 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 339 { 340 } 341 287 342 /** 288 343 * @brief copies the Executor … … 295 350 }; 296 351 352 353 354 /////////// 355 //// 5 //// 356 /////////// 297 357 //! @brief ExecutorClass, that can execute Functions with five parameters. 298 358 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor … … 329 389 }; 330 390 391 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 392 { 393 } 394 331 395 /** 332 396 * @brief copies the Executor -
branches/gui/src/lib/util/executor/executor_specials.h
r7711 r7985 67 67 } 68 68 69 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 70 { 71 72 } 73 69 74 private: 70 75 /**
Note: See TracChangeset
for help on using the changeset viewer.