Changeset 5641 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Nov 18, 2005, 9:22:23 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.cc
r5636 r5641 32 32 // SHELL COMMAND BASE // 33 33 //////////////////////// 34 // empty constructor 35 Executor::Executor() 36 { 37 this->defaultValue = NULL; 38 } 39 34 40 /** 35 41 * constructs and registers a new Command … … 63 69 delete[] this->defaultValue; 64 70 } 71 72 /** 73 * clones this element into executor. 74 */ 75 void Executor::cloning(Executor* executor) const 76 { 77 executor->functorType = this->functorType; 78 executor->paramCount = this->paramCount; 79 executor->defaultValue = new MultiType[this->paramCount]; 80 for (unsigned int i = 0; i < this->paramCount; i++) 81 executor->defaultValue[i] = this->defaultValue[i]; 82 } 83 84 65 85 66 86 /** -
trunk/src/lib/util/executor/executor.h
r5636 r5641 22 22 typedef enum { 23 23 Executor_Objective = 1, 24 Executor_Static = 2,24 Executor_Static = 2, 25 25 } Executor_Type; 26 26 … … 32 32 { 33 33 public: 34 virtual ~Executor(); 35 36 virtual Executor* clone () const = 0; 37 34 38 Executor* defaultValues(unsigned int count, ...); 35 39 Executor* defaultValues(unsigned int count, va_list values); … … 38 42 virtual void execute (BaseObject* object, const char* parameters) = 0; 39 43 44 /** @returns the Type of this Function (either static or objective) */ 45 inline Executor_Type getType() const { return this->functorType; }; 46 40 47 static void debug(); 41 48 42 49 protected: 50 Executor(); 43 51 Executor(unsigned int paramCount, ...); 44 ~Executor(); 45 46 /** @returns the Type of this Function (either static or objective) */ 47 inline Executor_Type getType() { return this->functorType; }; 52 53 void cloning(Executor* executor) const; 48 54 49 55 protected: … … 51 57 unsigned int paramCount; //!< the count of parameters. 52 58 MultiType* defaultValue; //!< Default Values. 53 54 private:55 59 }; 56 60 … … 226 230 template<class T> class ExecutorObjective : public Executor 227 231 { 228 229 232 public: 233 ExecutorObjective() : Executor() { }; 234 // COPY constuctor (virtual version) 235 virtual Executor* clone () const 236 { 237 ExecutorObjective<T>* executor = new ExecutorObjective<T>(); 238 this->cloning(executor); 239 executor->fp = this->fp; 240 return executor; 241 } 242 230 243 //! FUNCTOR_LIST is the List of CommandConstructors 231 244 #define FUNCTOR_LIST(x) ExecutorConstructor ## x … … 279 292 { 280 293 public: 294 ExecutorStatic() : Executor() { }; 295 // COPY constuctor 296 virtual Executor* clone () const 297 { 298 ExecutorStatic<T>* executor = new ExecutorStatic<T>(); 299 this->cloning(executor); 300 executor->fp = this->fp; 301 return executor; 302 } 303 281 304 //! FUNCTOR_LIST is the List of CommandConstructors 282 305 #define FUNCTOR_LIST(x) ExecutorConstructor ## x … … 303 326 }; 304 327 305 //! A Class, that handles aliases.306 class ExecutorAlias307 {308 friend class ExecutorBase;309 public:310 /** @returns the Name of the Alias. */311 const char* getName() const { return this->aliasName; };312 /** @returns the Command, this Alias is asociated with */313 ExecutorBase* getCommand() const { return this->command; };314 315 private:316 /** @param aliasName the name of the Alias @param command the Command, to associate this alias with */317 ExecutorAlias(const char* aliasName, ExecutorBase* command) { this->aliasName = aliasName; this->command = command; };318 319 private:320 const char* aliasName; //!< the name of the Alias321 ExecutorBase* command; //!< a pointer to the command, this alias executes.322 };323 324 328 #endif /* _EXECUTOR_H */ -
trunk/src/lib/util/multi_type.cc
r5638 r5641 101 101 this->value = mt.value; 102 102 103 if (mt.type == MT_STRING )103 if (mt.type == MT_STRING && mt.storedString != NULL) 104 104 { 105 105 this->storedString = new char[strlen (mt.storedString)+1]; … … 107 107 this->value.String = this->storedString; 108 108 } 109 else 110 this->storedString = NULL; 109 111 } 110 112 … … 290 292 { 291 293 if (this->type & MT_BOOL) return (this->value.Bool)? "true" : "false"; 292 else if (this->type & MT_CHAR) &this->value.Char;293 294 294 char tmpString[128]; 295 295 if (this->storedString != NULL) … … 298 298 this->storedString = NULL; 299 299 } 300 301 if (this->type & MT_INT) 300 if (this->type & MT_CHAR) 301 { 302 this->storedString = new char[2]; 303 this->storedString[0] = this->value.Char; 304 this->storedString[1] = '\0'; 305 return this->storedString; 306 } 307 else if (this->type & MT_INT) 302 308 { 303 309 sprintf(tmpString, "%d", this->value.Int);
Note: See TracChangeset
for help on using the changeset viewer.