Changeset 7714 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- May 19, 2006, 1:29:27 AM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.cc
r7300 r7714 18 18 #include "executor.h" 19 19 20 #include "debug.h"21 #include "class_list.h"22 23 #include "key_names.h"24 #include <stdarg.h>25 #include <stdio.h>26 #include <string.h>27 28 using namespace std;29 30 20 //////////////////////// 31 21 // SHELL COMMAND BASE // 32 22 //////////////////////// 33 23 /** 34 * constructs and registers a new Command24 * @brief constructs and registers a new Command 35 25 * @param commandName the name of the Command 36 26 * @param className the name of the class to apply this command to … … 43 33 const MultiType& param4) 44 34 { 45 this->setClassID(CL_EXECUTOR, "Executor");35 // this->setClassID(CL_EXECUTOR, "Executor"); 46 36 47 37 // What Parameters have we got -
trunk/src/lib/util/executor/executor.h
r7474 r7714 36 36 * Functions with many types (@see functor_list.h) 37 37 */ 38 class Executor : public BaseObject38 class Executor : public BaseObject 39 39 { 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 40 public: 41 virtual ~Executor(); 42 43 virtual Executor* clone () const = 0; 44 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 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); }; 57 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; }; 63 64 static void debug(); 65 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); 70 71 void cloning(Executor* executor) const; 72 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. 77 77 }; 78 78 … … 89 89 90 90 91 91 92 /////////////////////// 92 93 // FUNCTION POINTERS // … … 232 233 template<class T> class EXECUTOR : public Executor 233 234 { 234 235 236 237 238 239 240 241 242 243 244 245 //! FUNCTOR_LIST is the List of CommandConstructors235 public: 236 EXECUTOR() : Executor() { }; 237 // COPY constuctor (virtual version) 238 virtual Executor* clone () const 239 { 240 EXECUTOR<T>* executor = new EXECUTOR<T>(); 241 this->cloning(executor); 242 executor->fp = this->fp; 243 return executor; 244 } 245 246 //! FUNCTOR_LIST is the List of CommandConstructors 246 247 #define FUNCTOR_LIST(x) ExecutorConstructor ## x 247 248 #include "functor_list.h" 248 249 #undef FUNCTOR_LIST 249 250 250 251 //! FUNCTOR_LIST is the List of FunctionPointers252 251 private: 252 //! FUNCTOR_LIST is the List of FunctionPointers 253 union FunctionPointers { 253 254 #define FUNCTOR_LIST(x) ExecutorFunctionPoiter ## x 254 255 #include "functor_list.h" 255 256 #undef FUNCTOR_LIST 256 257 258 259 260 //! FUNCTOR_LIST is the List of Executive Functions257 } fp; 258 259 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 260 { 261 //! FUNCTOR_LIST is the List of Executive Functions 261 262 #define FUNCTOR_LIST(x) ExecutorExecute ## x 262 263 #include "functor_list.h" 263 264 #undef FUNCTOR_LIST 264 } 265 266 } 265 267 }; 266 268 … … 292 294 template<class T> class ExecutorStatic : public Executor 293 295 { 294 295 296 297 298 299 300 301 302 303 304 305 //! FUNCTOR_LIST is the List of CommandConstructors296 public: 297 EXECUTOR() : Executor() { }; 298 // COPY constuctor 299 virtual Executor* clone () const 300 { 301 EXECUTOR<T>* executor = new EXECUTOR<T>(); 302 this->cloning(executor); 303 executor->fp = this->fp; 304 return executor; 305 } 306 307 //! FUNCTOR_LIST is the List of CommandConstructors 306 308 #define FUNCTOR_LIST(x) ExecutorConstructor ## x 307 309 #include "functor_list.h" 308 310 #undef FUNCTOR_LIST 309 311 310 311 //! FUNCTOR_LIST is the List of FunctionPointers312 312 private: 313 //! FUNCTOR_LIST is the List of FunctionPointers 314 union FunctionPointers { 313 315 #define FUNCTOR_LIST(x) ExecutorFunctionPoiter ## x 314 316 #include "functor_list.h" 315 317 #undef FUNCTOR_LIST 316 317 318 319 320 321 //! FUNCTOR_LIST is the List of Executive Functions318 } fp; 319 320 321 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 322 { 323 //! FUNCTOR_LIST is the List of Executive Functions 322 324 #define FUNCTOR_LIST(x) ExecutorExecute ## x 323 325 #include "functor_list.h" 324 326 #undef FUNCTOR_LIST 325 } 327 328 } 326 329 }; 327 330 -
trunk/src/lib/util/helper_functions.cc
r7412 r7714 101 101 * @return returns the contained string (char-array), if STRING was correct otherwise defaultValue 102 102 */ 103 std::stringisString(const std::string& STRING, const std::string& defaultValue)103 const std::string& isString(const std::string& STRING, const std::string& defaultValue) 104 104 { 105 105 if (STRING.size() > 0) … … 124 124 { 125 125 if(::toupper(*it1) != ::toupper(*it2)) //letters differ? 126 // return -1 to indicate smaller than, 1 otherwise126 // return -1 to indicate smaller than, 1 otherwise 127 127 return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1; 128 128 //proceed to the next character in each string … … 131 131 } 132 132 size_t size1=s1.size(), size2=s2.size();// cache lengths 133 133 //return -1,0 or 1 according to strings' lengths 134 134 if (size1==size2) 135 135 return 0; … … 155 155 { 156 156 if(::toupper(*it1) != ::toupper(*it2)) //letters differ? 157 // return -1 to indicate smaller than, 1 otherwise157 // return -1 to indicate smaller than, 1 otherwise 158 158 return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1; 159 159 //proceed to the next character in each string -
trunk/src/lib/util/helper_functions.h
r7371 r7714 18 18 float isFloat(const std::string& FLOAT, float defaultValue); 19 19 const char* isCString(const std::string& STRING, const char* defaultValue); 20 std::stringisString(const std::string& STRING, const std::string& defaultValue);20 const std::string& isString(const std::string& STRING, const std::string& defaultValue); 21 21 22 22
Note: See TracChangeset
for help on using the changeset viewer.