Changeset 8035 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- May 31, 2006, 4:20:51 PM (19 years ago)
- Location:
- trunk/src/lib/util
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.h
r7725 r8035 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 // virtual bool operator==(const Executor* executor) const = 0; 44 45 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]; };46 // SETTING up the EXECUTOR 47 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 48 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 49 const MultiType& value4 = MT_NULL); 50 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 51 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; 51 52 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); }; 53 // EXECUTE 54 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 55 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const = 0; 56 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 57 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0; 58 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/ 59 void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); }; 57 60 58 // RETRIEVE INFORMATION59 /** @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 61 64 static void debug(); 62 // RETRIEVE INFORMATION 63 /** @returns the Type of this Function (either static or objective) */ 64 inline long getType() const { return this->functorType; }; 65 /** @returns the Count of Parameters this Executor takes */ 66 inline unsigned int getParamCount() const { return this->paramCount; }; 65 67 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); 68 static void debug(); 70 69 71 void cloning(Executor* executor) const; 70 protected: 71 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 72 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 73 const MultiType& param4 = MT_NULL); 72 74 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. 75 void cloning(Executor* executor) const; 76 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[5]; //!< Default Values. 77 81 }; 78 82 -
trunk/src/lib/util/executor/executor_functional.cc
r7728 r8035 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.getConstString(); }; 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 -
trunk/src/lib/util/executor/executor_functional.h
r7725 r8035 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 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 125 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 126 { 127 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); 128 } 129 112 130 /** 113 131 * @brief copies the Executor … … 120 138 }; 121 139 140 141 142 /////////// 143 //// 1 //// 144 /////////// 122 145 //! @brief ExecutorClass, that can execute Functions with one parameter. 123 146 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor … … 139 162 }; 140 163 164 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 165 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 166 { 167 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 168 fromMulti<type0>((count > 0)? values[0] : this->defaultValue[0]) ); 169 } 170 171 141 172 /** 142 173 * @brief executes the Functional … … 146 177 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 147 178 { 148 149 /* // THE VERY COOL DEBUG150 printf("SUB[0] : %s\n", sub[0].c_str());151 printf("getDefault<type0>(this->defaultValue, 0):::: %d\n", getDefault<type0>(this->defaultValue, 0));152 printf("VALUE: %d\n", fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)));153 */154 179 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 155 180 fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) ); … … 166 191 }; 167 192 193 /////////// 194 //// 2 //// 195 /////////// 168 196 //! @brief ExecutorClass, that can execute Functions with two parameters. 169 197 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor … … 197 225 }; 198 226 227 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 228 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 229 { 230 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 231 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 232 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]) ); 233 } 234 199 235 /** 200 236 * @brief copies the Executor … … 208 244 209 245 246 /////////// 247 //// 3 //// 248 /////////// 210 249 //! @brief ExecutorClass, that can execute Functions with three parameters. 211 250 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor … … 240 279 }; 241 280 281 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 282 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 283 { 284 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 285 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 286 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 287 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]) ); 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 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 339 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 340 { 341 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 342 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 343 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 344 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]), 345 fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]) ); 346 } 347 287 348 /** 288 349 * @brief copies the Executor … … 295 356 }; 296 357 358 359 360 /////////// 361 //// 5 //// 362 /////////// 297 363 //! @brief ExecutorClass, that can execute Functions with five parameters. 298 364 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor … … 329 395 }; 330 396 397 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 398 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 399 { 400 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 401 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 402 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 403 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]), 404 fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]), 405 fromMulti<type4>((count > 4) ? values[4] : this->defaultValue[4]) ); 406 } 407 331 408 /** 332 409 * @brief copies the Executor … … 344 421 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 345 422 */ 346 #define EXECUTOR_FUNCTIONAL_CREATOR0( ) \347 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \423 #define EXECUTOR_FUNCTIONAL_CREATOR0(ret) \ 424 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ 348 425 { \ 349 426 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \ … … 354 431 * @param type0 for internal usage: the first Argument 355 432 */ 356 #define EXECUTOR_FUNCTIONAL_CREATOR1( type0) \357 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \433 #define EXECUTOR_FUNCTIONAL_CREATOR1(ret, type0) \ 434 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 358 435 { \ 359 436 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \ … … 365 442 * @param type1 for internal usage: the second Argument 366 443 */ 367 #define EXECUTOR_FUNCTIONAL_CREATOR2( type0, type1) \368 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \444 #define EXECUTOR_FUNCTIONAL_CREATOR2(ret, type0, type1) \ 445 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 369 446 { \ 370 447 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \ … … 377 454 * @param type2 for internal usage: the third Argument 378 455 */ 379 #define EXECUTOR_FUNCTIONAL_CREATOR3( type0, type1, type2) \380 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \456 #define EXECUTOR_FUNCTIONAL_CREATOR3(ret, type0, type1, type2) \ 457 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 381 458 { \ 382 459 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \ … … 390 467 * @param type3 for internal usage: the fourth Argument 391 468 */ 392 #define EXECUTOR_FUNCTIONAL_CREATOR4( type0, type1, type2, type3) \393 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \469 #define EXECUTOR_FUNCTIONAL_CREATOR4(ret, type0, type1, type2, type3) \ 470 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 394 471 { \ 395 472 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \ … … 404 481 * @param type4 for internal usage: the fifth Argument 405 482 */ 406 #define EXECUTOR_FUNCTIONAL_CREATOR5( type0, type1, type2, type3, type4) \407 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \483 #define EXECUTOR_FUNCTIONAL_CREATOR5(ret, type0, type1, type2, type3, type4) \ 484 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 408 485 { \ 409 486 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \ -
trunk/src/lib/util/executor/executor_specials.h
r7711 r8035 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 /** -
trunk/src/lib/util/executor/functor_list.h
r7785 r8035 90 90 #ifdef FUNCTOR_LIST 91 91 92 FUNCTOR_LIST(0)( );92 FUNCTOR_LIST(0)(void); 93 93 //! makes functions with one string 94 FUNCTOR_LIST(1)( l_STRING);94 FUNCTOR_LIST(1)(void, l_STRING); 95 95 //! makes functions with two strings 96 FUNCTOR_LIST(2)( l_STRING, l_STRING);96 FUNCTOR_LIST(2)(void, l_STRING, l_STRING); 97 97 //! makes functions with three strings 98 FUNCTOR_LIST(3)( l_STRING, l_STRING, l_STRING);98 FUNCTOR_LIST(3)(void, l_STRING, l_STRING, l_STRING); 99 99 //! makes functions with four strings 100 FUNCTOR_LIST(4)( l_STRING, l_STRING, l_STRING, l_STRING);100 FUNCTOR_LIST(4)(void, l_STRING, l_STRING, l_STRING, l_STRING); 101 101 102 102 103 103 //! makes functions with one bool 104 FUNCTOR_LIST(1)( l_BOOL);104 FUNCTOR_LIST(1)(void, l_BOOL); 105 105 106 106 //! makes functions with one int 107 FUNCTOR_LIST(1)( l_INT);107 FUNCTOR_LIST(1)(void, l_INT); 108 108 //! makes functions with two ints 109 FUNCTOR_LIST(2)( l_INT, l_INT);109 FUNCTOR_LIST(2)(void, l_INT, l_INT); 110 110 //! makes functions with three ints 111 FUNCTOR_LIST(3)( l_INT, l_INT, l_INT);111 FUNCTOR_LIST(3)(void, l_INT, l_INT, l_INT); 112 112 //! makes functions with four ints 113 FUNCTOR_LIST(4)( l_INT, l_INT, l_INT, l_INT);113 FUNCTOR_LIST(4)(void, l_INT, l_INT, l_INT, l_INT); 114 114 115 115 116 116 //! makes functions with one unsigned int 117 FUNCTOR_LIST(1)( l_UINT);117 FUNCTOR_LIST(1)(void, l_UINT); 118 118 //! makes functions with two unsigned ints 119 FUNCTOR_LIST(2)( l_UINT, l_UINT);119 FUNCTOR_LIST(2)(void, l_UINT, l_UINT); 120 120 //! makes functions with three unsigned ints 121 FUNCTOR_LIST(3)( l_UINT, l_UINT, l_UINT);121 FUNCTOR_LIST(3)(void, l_UINT, l_UINT, l_UINT); 122 122 //! makes functions with four unsigned ints 123 FUNCTOR_LIST(4)( l_UINT, l_UINT, l_UINT, l_UINT);123 FUNCTOR_LIST(4)(void, l_UINT, l_UINT, l_UINT, l_UINT); 124 124 125 125 //! makes functions with one float 126 FUNCTOR_LIST(1)( l_FLOAT);126 FUNCTOR_LIST(1)(void, l_FLOAT); 127 127 //! makes functions with two floats 128 FUNCTOR_LIST(2)( l_FLOAT, l_FLOAT);128 FUNCTOR_LIST(2)(void, l_FLOAT, l_FLOAT); 129 129 //! makes functions with three floats 130 FUNCTOR_LIST(3)( l_FLOAT, l_FLOAT, l_FLOAT);130 FUNCTOR_LIST(3)(void, l_FLOAT, l_FLOAT, l_FLOAT); 131 131 //! makes functions with four floats 132 FUNCTOR_LIST(4)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);132 FUNCTOR_LIST(4)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT); 133 133 //! makes functions with four floats 134 FUNCTOR_LIST(5)( l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);134 FUNCTOR_LIST(5)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT); 135 135 136 136 //! mixed values: 137 FUNCTOR_LIST(2)( l_STRING, l_FLOAT);138 FUNCTOR_LIST(2)( l_UINT, l_LONG);139 FUNCTOR_LIST(2)( l_STRING, l_UINT);137 FUNCTOR_LIST(2)(void, l_STRING, l_FLOAT); 138 FUNCTOR_LIST(2)(void, l_UINT, l_LONG); 139 FUNCTOR_LIST(2)(void, l_STRING, l_UINT); 140 140 141 FUNCTOR_LIST(3)( l_STRING, l_FLOAT, l_UINT);142 FUNCTOR_LIST(4)( l_STRING, l_FLOAT, l_UINT, l_UINT);143 FUNCTOR_LIST(3)( l_STRING, l_INT, l_UINT);144 FUNCTOR_LIST(3)( l_STRING, l_UINT, l_UINT);141 FUNCTOR_LIST(3)(void, l_STRING, l_FLOAT, l_UINT); 142 FUNCTOR_LIST(4)(void, l_STRING, l_FLOAT, l_UINT, l_UINT); 143 FUNCTOR_LIST(3)(void, l_STRING, l_INT, l_UINT); 144 FUNCTOR_LIST(3)(void, l_STRING, l_UINT, l_UINT); 145 145 146 146 #endif /* FUNCTOR_LIST */ -
trunk/src/lib/util/multi_type.cc
r7401 r8035 39 39 switch (this->type) 40 40 { 41 41 default: 42 42 this->value.Float = 0.0f; 43 43 break; 44 44 case MT_BOOL: 45 45 this->value.Bool = false; 46 46 break; 47 47 case MT_INT: 48 48 this->value.Int = 0; 49 49 break; 50 50 case MT_FLOAT: 51 51 this->value.Float = 0.0f; 52 52 break; 53 53 case MT_CHAR: 54 54 this->value.Char = '\0'; 55 55 break; 56 56 case MT_STRING: 57 57 this->storedString = ""; 58 58 break; … … 148 148 switch (this->type) 149 149 { 150 150 case MT_NULL: 151 151 return true; 152 152 case MT_BOOL: 153 153 return (this->value.Bool == mt.value.Bool); 154 154 case MT_INT: 155 155 return (this->value.Int == mt.value.Int); 156 156 case MT_CHAR: 157 157 return (this->value.Char == mt.value.Char); 158 158 case MT_FLOAT: 159 159 return (this->value.Float == mt.value.Float); 160 160 case MT_STRING: 161 161 return (this->storedString == mt.storedString); 162 162 } … … 175 175 switch (type) 176 176 { 177 177 case MT_BOOL: 178 178 this->setBool(this->getBool()); 179 179 break; 180 180 case MT_INT: 181 181 this->setInt(this->getInt()); 182 182 break; 183 183 case MT_FLOAT: 184 184 this->setFloat(this->getFloat()); 185 185 break; 186 186 case MT_CHAR: 187 187 this->setChar(this->getChar()); 188 188 break; 189 189 case MT_STRING: 190 190 this->setString(this->getString()); 191 191 break; … … 382 382 383 383 /** 384 * @brief returns a Constant string (actually this is slower than getString() 385 * @returns a constant string of the stored version's one. 386 * @note this could lead to a inconsistency of data 387 */ 388 const std::string& MultiType::getConstString() const 389 { 390 391 MultiType::constString = this->getString(); 392 return MultiType::constString; 393 } 394 395 396 /** 384 397 * @returns a formated c-string of the held value 385 398 */ … … 422 435 switch ( this->type ) 423 436 { 424 437 case MT_BOOL: 425 438 this->setBool(false); 426 439 break; 427 440 case MT_INT: 428 441 this->setInt(0); 429 442 break; 430 443 case MT_FLOAT: 431 444 this->setFloat(0.0f); 432 445 break; 433 446 case MT_CHAR: 434 447 this->setChar('\0'); 435 448 break; 436 449 case MT_STRING: 437 450 this->setString(""); 438 451 break; 439 452 default: 440 453 #ifdef DEBUG 441 454 PRINTF(2)("Unknown Type not reseting\n"); … … 454 467 switch ( type ) 455 468 { 456 469 case MT_BOOL: 457 470 return MultiType::typeNames[1]; 458 471 case MT_INT: 459 472 return MultiType::typeNames[2]; 460 473 case MT_FLOAT: 461 474 return MultiType::typeNames[3]; 462 475 case MT_CHAR: 463 476 return MultiType::typeNames[4]; 464 477 case MT_STRING: 465 478 return MultiType::typeNames[5]; 466 479 } … … 490 503 491 504 505 std::string MultiType::constString = ""; 492 506 const std::string MultiType::typeNames[] = 493 507 { -
trunk/src/lib/util/multi_type.h
r7401 r8035 87 87 const char* getCString(); 88 88 std::string getString() const; 89 const std::string& getConstString() const; 89 90 90 91 void reset(); … … 107 108 MT_Type type; //!< The Type stored in this MultiType 108 109 110 111 static std::string constString; //!< A String for returning Constant strings. 112 109 113 static const std::string typeNames[]; //!< List of TypeNames for conversion. 110 114 };
Note: See TracChangeset
for help on using the changeset viewer.