Changeset 957 for code/branches/core2
- Timestamp:
- Mar 30, 2008, 5:38:03 AM (17 years ago)
- Location:
- code/branches/core2/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core2/src/orxonox/core/CommandExecutor.cc
r955 r957 192 192 break; 193 193 case CS_Shortcut_Params: 194 // not enough parameters but lets hope there are some additional parameters 195 if (evaluation.shortcut_ != 0) 196 return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_); 197 break; 194 // not enough parameters but lets hope there are some additional parameters and go on 198 195 case CS_Shortcut_Finished: 199 196 // call the shortcut 200 197 if (evaluation.shortcut_ != 0) 201 return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_); 198 { 199 if (tokens.size() >= 2) 200 return evaluation.shortcut_->parse(tokens.subSet(1).join() + " " + evaluation.additionalParameter_); 201 else 202 return evaluation.shortcut_->parse(evaluation.additionalParameter_); 203 } 202 204 break; 203 205 case CS_Function: 204 206 break; 205 207 case CS_Function_Params: 206 // not enough parameters but lets hope there are some additional parameters 207 if (evaluation.function_ != 0) 208 return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_); 209 break; 208 // not enough parameters but lets hope there are some additional parameters and go on 210 209 case CS_Function_Finished: 211 210 // call the shortcut 212 211 if (evaluation.function_ != 0) 213 return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_); 212 { 213 if (tokens.size() >= 3) 214 return evaluation.function_->parse(tokens.subSet(2).join() + " " + evaluation.additionalParameter_); 215 else 216 return evaluation.function_->parse(evaluation.additionalParameter_); 217 } 214 218 break; 215 219 case CS_ConfigValueClass: … … 218 222 break; 219 223 case CS_ConfigValueType: 220 // not enough parameters but lets hope there are some additional parameters 221 if (evaluation.configvalue_ != 0) 222 return evaluation.configvalue_->parseString(tokens.subSet(3).join() + " " + evaluation.additionalParameter_); 223 break; 224 // not enough parameters but lets hope there are some additional parameters and go on 224 225 case CS_ConfigValueFinished: 225 226 // set the config value 226 227 if (evaluation.configvalue_ != 0) 227 return evaluation.configvalue_->parseString(tokens.subSet(3).join() + " " + evaluation.additionalParameter_); 228 { 229 if ((tokens.size() >= 1) && (tokens[0] == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE)) 230 { 231 if (tokens.size() >= 4) 232 return evaluation.configvalue_->set(tokens.subSet(3).join() + " " + evaluation.additionalParameter_); 233 else 234 return evaluation.configvalue_->set(evaluation.additionalParameter_); 235 } 236 else if ((tokens.size() >= 1) && (tokens[0] == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) 237 { 238 if (tokens.size() >= 4) 239 return evaluation.configvalue_->tset(tokens.subSet(3).join() + " " + evaluation.additionalParameter_); 240 else 241 return evaluation.configvalue_->tset(evaluation.additionalParameter_); 242 } 243 } 228 244 break; 229 245 case CS_KeybindKey: 230 246 break; 231 247 case CS_KeybindCommand: 232 // not enough parameters but lets hope there are some additional parameters 233 break; 248 // not enough parameters but lets hope there are some additional parameters and go on 234 249 case CS_KeybindFinished: 235 250 // set the keybind … … 980 995 981 996 if (executor->defaultValueSet(i)) 982 output += " ]";997 output += "=" + executor->getDefaultValue(i).toString() + "]"; 983 998 else 984 999 output += "}"; … … 989 1004 std::string CommandExecutor::dump(const ConfigValueContainer* container) 990 1005 { 991 return container->getTypename(); 1006 AddLanguageEntry("CommandExecutor::oldvalue", "old value"); 1007 return "{" + container->getTypename() + "} (" + GetLocalisation("CommandExecutor::oldvalue") + ": " + container->toString() + ")"; 992 1008 } 993 1009 -
code/branches/core2/src/orxonox/core/CommandExecutor.h
r955 r957 68 68 class _CoreExport CommandEvaluation 69 69 { 70 friend class CommandExecutor; 71 70 72 public: 71 73 CommandEvaluation(); … … 75 77 bool isValid() const; 76 78 79 private: 77 80 std::string processedCommand_; 78 81 SubString tokens_; -
code/branches/core2/src/orxonox/core/ConfigValueContainer.cc
r949 r957 34 34 35 35 #include "ConfigValueContainer.h" 36 #include "util/Tokenizer.h"37 #include "util/Convert.h"38 36 #include "Language.h" 37 #include "Iterator.h" 38 #include "BaseObject.h" 39 39 40 40 #define CONFIGFILEPATH "orxonox.ini" … … 49 49 @param defvalue The default-value 50 50 */ 51 ConfigValueContainer::ConfigValueContainer( const std::string& classname, const std::string& varname, MultiTypeMath defvalue)51 ConfigValueContainer::ConfigValueContainer(Identifier* identifier, const std::string& varname, MultiTypeMath defvalue) 52 52 { 53 53 this->bAddedDescription_ = false; 54 this-> classname_ = classname;54 this->identifier_ = identifier; 55 55 this->varname_ = varname; 56 56 57 this->valueToString(&this->defvalueString_, defvalue); // Try to convert the default-value to a string 58 this->searchConfigFileLine(); // Search the entry in the config-file 59 60 std::string valueString = this->parseValueString(!(defvalue.isA(MT_string) || defvalue.isA(MT_constchar))); // Parses the value string from the config-file-entry 61 if (!this->parseString(valueString, defvalue)) // Try to convert the string to a value 62 this->resetConfigFileEntry(); // The conversion failed 63 } 64 65 /** 66 @brief Converts a value to a string. 67 @param output The string to write to 68 @param input The value to convert 69 @return True if the converson was successful 70 */ 71 bool ConfigValueContainer::valueToString(std::string* output, MultiTypeMath& input) 72 { 73 if (input.getType() == MT_int) 74 return ConvertValue(output, input.getInt(), std::string("0")); 75 else if (input.getType() == MT_uint) 76 return ConvertValue(output, input.getUnsignedInt(), std::string("0")); 77 else if (input.getType() == MT_char) 78 return ConvertValue(output, (int)input.getChar(), std::string("0")); 79 else if (input.getType() == MT_uchar) 80 return ConvertValue(output, (unsigned int)input.getUnsignedChar(), std::string("0")); 81 else if (input.getType() == MT_short) 82 return ConvertValue(output, input.getShort(), std::string("0")); 83 else if (input.getType() == MT_ushort) 84 return ConvertValue(output, input.getUnsignedShort(), std::string("0")); 85 else if (input.getType() == MT_long) 86 return ConvertValue(output, input.getLong(), std::string("0")); 87 else if (input.getType() == MT_ulong) 88 return ConvertValue(output, input.getUnsignedLong(), std::string("0")); 89 else if (input.getType() == MT_float) 90 return ConvertValue(output, input.getFloat(), std::string("0.000000")); 91 else if (input.getType() == MT_double) 92 return ConvertValue(output, input.getDouble(), std::string("0.000000")); 93 else if (input.getType() == MT_longdouble) 94 return ConvertValue(output, input.getChar(), std::string("0.000000")); 95 else if (input.getType() == MT_bool) 96 { 97 if (input.getBool()) 98 (*output) = "true"; 99 else 100 (*output) = "false"; 101 102 return true; 103 } 104 else if (input.getType() == MT_constchar) 105 { 106 (*output) = "\"" + input.getString() + "\""; 107 return true; 108 } 109 else if (input.getType() == MT_string) 110 { 111 (*output) = "\"" + input.getString() + "\""; 112 return true; 113 } 114 else if (input.getType() == MT_vector2) 115 { 116 std::ostringstream ostream; 117 if (ostream << "(" << input.getVector2().x << "," << input.getVector2().y << ")") 118 { 119 (*output) = ostream.str(); 120 return true; 121 } 122 else 123 { 124 (*output) = "(0,0)"; 125 return false; 126 } 127 } 128 else if (input.getType() == MT_vector3) 129 { 130 std::ostringstream ostream; 131 if (ostream << "(" << input.getVector3().x << "," << input.getVector3().y << "," << input.getVector3().z << ")") 132 { 133 (*output) = ostream.str(); 134 return true; 135 } 136 else 137 { 138 (*output) = "(0,0,0)"; 139 return false; 140 } 141 } 142 else if (input.getType() == MT_colourvalue) 143 { 144 std::ostringstream ostream; 145 if (ostream << "(" << input.getColourValue().r << "," << input.getColourValue().g << "," << input.getColourValue().b << "," << input.getColourValue().a << ")") 146 { 147 (*output) = ostream.str(); 148 return true; 149 } 150 else 151 { 152 (*output) = "(0,0,0,0)"; 153 return false; 154 } 155 } 156 else if (input.getType() == MT_quaternion) 157 { 158 std::ostringstream ostream; 159 if (ostream << "(" << input.getQuaternion().w << "," << input.getQuaternion().x << "," << input.getQuaternion().y << "," << input.getQuaternion().z << ")") 160 { 161 (*output) = ostream.str(); 162 return true; 163 } 164 else 165 { 166 (*output) = "(0,0,0,0)"; 167 return false; 168 } 169 } 170 else if (input.getType() == MT_radian) 171 return ConvertValue(output, input.getRadian(), std::string("0.000000")); 172 else if (input.getType() == MT_degree) 173 return ConvertValue(output, input.getDegree(), std::string("0.000000")); 174 175 return false; 57 this->defvalueString_ = defvalue.toString(); // Convert the default-value to a string 58 this->searchLineInConfigFile(); // Search the entry in the config-file 59 60 std::string valueString = this->parseValueStringFromConfigFile(!(defvalue.isA(MT_string) || defvalue.isA(MT_constchar))); // Parses the value string from the config-file-entry 61 if (!this->parse(valueString, defvalue)) // Try to convert the string to a value 62 this->resetLineInConfigFile(); // The conversion failed 63 } 64 65 /** 66 @brief Assigns a new value to the config-value of all objects and writes the change into the config-file. 67 @param input The new value 68 @return True if the new value was successfully assigned 69 */ 70 bool ConfigValueContainer::set(const std::string& input) 71 { 72 bool success = this->tset(input); 73 this->setLineInConfigFile(input); 74 return success; 75 } 76 77 /** 78 @brief Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary). 79 @param input The new value 80 @return True if the new value was successfully assigned 81 */ 82 bool ConfigValueContainer::tset(const std::string& input) 83 { 84 bool success = this->parse(input); 85 this->identifier_->updateConfigValues(); 86 return success; 87 } 88 89 /** 90 @brief Sets the value of the variable back to the default value and resets the config-file entry. 91 */ 92 bool ConfigValueContainer::reset() 93 { 94 return this->set(this->defvalueString_); 176 95 } 177 96 … … 181 100 @return True if the string was successfully parsed 182 101 */ 183 bool ConfigValueContainer::parseString(const std::string& input, const MultiTypeMath& defvalue) 184 { 185 if (defvalue.getType() == MT_int) 186 return this->parseString(input, defvalue.getInt()); 187 else if (defvalue.getType() == MT_uint) 188 return this->parseString(input, defvalue.getUnsignedInt()); 189 else if (defvalue.getType() == MT_char) 190 return this->parseString(input, defvalue.getChar()); 191 else if (defvalue.getType() == MT_uchar) 192 return this->parseString(input, defvalue.getUnsignedChar()); 193 else if (defvalue.getType() == MT_short) 194 return this->parseString(input, defvalue.getShort()); 195 else if (defvalue.getType() == MT_ushort) 196 return this->parseString(input, defvalue.getUnsignedShort()); 197 else if (defvalue.getType() == MT_long) 198 return this->parseString(input, defvalue.getLong()); 199 else if (defvalue.getType() == MT_ulong) 200 return this->parseString(input, defvalue.getUnsignedLong()); 201 else if (defvalue.getType() == MT_float) 202 return this->parseString(input, defvalue.getFloat()); 203 else if (defvalue.getType() == MT_double) 204 return this->parseString(input, defvalue.getDouble()); 205 else if (defvalue.getType() == MT_longdouble) 206 return this->parseString(input, defvalue.getLongDouble()); 207 else if (defvalue.getType() == MT_bool) 208 return this->parseString(input, defvalue.getBool()); 209 else if (defvalue.getType() == MT_constchar) 210 return this->parseString(input, defvalue.getString()); 211 else if (defvalue.getType() == MT_string) 212 return this->parseString(input, defvalue.getString()); 213 else if (defvalue.getType() == MT_vector2) 214 return this->parseString(input, defvalue.getVector2()); 215 else if (defvalue.getType() == MT_vector3) 216 return this->parseString(input, defvalue.getVector3()); 217 else if (defvalue.getType() == MT_colourvalue) 218 return this->parseString(input, defvalue.getColourValue()); 219 else if (defvalue.getType() == MT_quaternion) 220 return this->parseString(input, defvalue.getQuaternion()); 221 else if (defvalue.getType() == MT_radian) 222 return this->parseString(input, defvalue.getRadian()); 223 else if (defvalue.getType() == MT_degree) 224 return this->parseString(input, defvalue.getDegree()); 225 102 bool ConfigValueContainer::parse(const std::string& input) 103 { 104 MultiTypeMath temp = this->value_; 105 if (temp.fromString(input)) 106 { 107 this->value_ = temp; 108 return true; 109 } 226 110 return false; 227 111 } 228 112 229 113 /** 230 @brief Parses a given std::string into a value of the type int and assigns it to the right variable. If the conversion failed, the default-value gets assigned.114 @brief Parses a given std::string into a value of the type of the associated variable and assigns it. 231 115 @param input The string to convert 232 @param defvalue The default -value116 @param defvalue The default value to assign if the parsing fails 233 117 @return True if the string was successfully parsed 234 118 */ 235 bool ConfigValueContainer::parseString(const std::string& input, int defvalue) 236 { 237 int temp; 238 bool success = ConvertValue(&temp, input, defvalue); 239 this->value_.setValue(temp); 240 return success; 241 } 242 243 /** 244 @brief Parses a given std::string into a value of the type unsigned int and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 245 @param input The string to convert 246 @param defvalue The default-value 247 @return True if the string was successfully parsed 248 */ 249 bool ConfigValueContainer::parseString(const std::string& input, unsigned int defvalue) 250 { 251 unsigned int temp; 252 bool success = ConvertValue(&temp, input, defvalue); 253 this->value_.setValue(temp); 254 return success; 255 } 256 257 /** 258 @brief Parses a given std::string into a value of the type char and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 259 @param input The string to convert 260 @param defvalue The default-value 261 @return True if the string was successfully parsed 262 */ 263 bool ConfigValueContainer::parseString(const std::string& input, char defvalue) 264 { 265 // I used value_int_ instead of value_char_ to avoid number <-> char confusion in the config-file 266 int temp; 267 bool success = ConvertValue(&temp, input, (int)defvalue); 268 this->value_.setValue((char)temp); 269 return success; 270 } 271 272 /** 273 @brief Parses a given std::string into a value of the type unsigned char and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 274 @param input The string to convert 275 @param defvalue The default-value 276 @return True if the string was successfully parsed 277 */ 278 bool ConfigValueContainer::parseString(const std::string& input, unsigned char defvalue) 279 { 280 // I used value_uint_ instead of value_uchar_ to avoid number <-> char confusion in the config-file 281 unsigned int temp; 282 bool success = ConvertValue(&temp, input, (unsigned int)defvalue); 283 this->value_.setValue((unsigned char)temp); 284 return success; 285 } 286 287 /** 288 @brief Parses a given std::string into a value of the type short and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 289 @param input The string to convert 290 @param defvalue The default-value 291 @return True if the string was successfully parsed 292 */ 293 bool ConfigValueContainer::parseString(const std::string& input, short defvalue) 294 { 295 short temp; 296 bool success = ConvertValue(&temp, input, defvalue); 297 this->value_.setValue(temp); 298 return success; 299 } 300 301 /** 302 @brief Parses a given std::string into a value of the type unsigned short and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 303 @param input The string to convert 304 @param defvalue The default-value 305 @return True if the string was successfully parsed 306 */ 307 bool ConfigValueContainer::parseString(const std::string& input, unsigned short defvalue) 308 { 309 unsigned short temp; 310 bool success = ConvertValue(&temp, input, defvalue); 311 this->value_.setValue(temp); 312 return success; 313 } 314 315 /** 316 @brief Parses a given std::string into a value of the type long and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 317 @param input The string to convert 318 @param defvalue The default-value 319 @return True if the string was successfully parsed 320 */ 321 bool ConfigValueContainer::parseString(const std::string& input, long defvalue) 322 { 323 long temp; 324 bool success = ConvertValue(&temp, input, defvalue); 325 this->value_.setValue(temp); 326 return success; 327 } 328 329 /** 330 @brief Parses a given std::string into a value of the type unsigned long and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 331 @param input The string to convert 332 @param defvalue The default-value 333 @return True if the string was successfully parsed 334 */ 335 bool ConfigValueContainer::parseString(const std::string& input, unsigned long defvalue) 336 { 337 unsigned long temp; 338 bool success = ConvertValue(&temp, input, defvalue); 339 this->value_.setValue(temp); 340 return success; 341 } 342 343 /** 344 @brief Parses a given std::string into a value of the type float and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 345 @param input The string to convert 346 @param defvalue The default-value 347 @return True if the string was successfully parsed 348 */ 349 bool ConfigValueContainer::parseString(const std::string& input, float defvalue) 350 { 351 float temp; 352 bool success = ConvertValue(&temp, input, defvalue); 353 this->value_.setValue(temp); 354 return success; 355 } 356 357 /** 358 @brief Parses a given std::string into a value of the type double and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 359 @param input The string to convert 360 @param defvalue The default-value 361 @return True if the string was successfully parsed 362 */ 363 bool ConfigValueContainer::parseString(const std::string& input, double defvalue) 364 { 365 double temp; 366 bool success = ConvertValue(&temp, input, defvalue); 367 this->value_.setValue(temp); 368 return success; 369 } 370 371 /** 372 @brief Parses a given std::string into a value of the type long double and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 373 @param input The string to convert 374 @param defvalue The default-value 375 @return True if the string was successfully parsed 376 */ 377 bool ConfigValueContainer::parseString(const std::string& input, long double defvalue) 378 { 379 long double temp; 380 bool success = ConvertValue(&temp, input, defvalue); 381 this->value_.setValue(temp); 382 return success; 383 } 384 385 /** 386 @brief Parses a given std::string into a value of the type bool and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 387 @param input The string to convert 388 @param defvalue The default-value 389 @return True if the string was successfully parsed 390 */ 391 bool ConfigValueContainer::parseString(const std::string& input, bool defvalue) 392 { 393 // Try to parse the value-string - is it a word? 394 if (input.find("true") < input.size() 395 || input.find("True") < input.size() 396 || input.find("yes") < input.size() 397 || input.find("Yes") < input.size()) 398 this->value_.setValue(true); 399 else if (input.find("false") < input.size() 400 || input.find("False") < input.size() 401 || input.find("no") < input.size() 402 || input.find("No") < input.size()) 403 this->value_.setValue(false); 119 bool ConfigValueContainer::parse(const std::string& input, const MultiTypeMath& defvalue) 120 { 121 MultiTypeMath temp = defvalue; 122 if (temp.fromString(input)) 123 { 124 this->value_ = temp; 125 return true; 126 } 404 127 else 405 128 { 406 // Its not a known word - is it a number? 407 bool temp; 408 bool success = ConvertValue(&temp, input, defvalue); 409 this->value_.setValue(temp); 410 return success; 411 } 412 413 return true; 414 } 415 416 /** 417 @brief Parses a given std::string into a value of the type std::string and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 418 @param input The string to convert 419 @param defvalue The default-value 420 @return True if the string was successfully parsed 421 */ 422 bool ConfigValueContainer::parseString(const std::string& input, const std::string& defvalue) 423 { 424 // Strip the quotes 425 unsigned int pos1 = input.find("\"") + 1; 426 unsigned int pos2 = input.find("\"", pos1); 427 428 // Check if the entry was correctly quoted 429 if (pos1 < input.length() && pos2 < input.length() && !(input.find("\"", pos2 + 1) < input.length())) 430 { 431 // It was - get the string between the quotes 432 this->value_.setValue(input.substr(pos1, pos2 - pos1)); 433 return true; 434 } 435 436 // It wasn't - use the default-value and restore the entry in the config-file. 437 this->value_.setValue(defvalue); 438 return false; 439 } 440 441 /** 442 @brief Parses a given std::string into a value of the type const char* and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 443 @param input The string to convert 444 @param defvalue The default-value 445 @return True if the string was successfully parsed 446 */ 447 bool ConfigValueContainer::parseString(const std::string& input, const char* defvalue) 448 { 449 // Strip the quotes 450 unsigned int pos1 = input.find("\"") + 1; 451 unsigned int pos2 = input.find("\"", pos1); 452 453 // Check if the entry was correctly quoted 454 if (pos1 < input.length() && pos2 < input.length() && !(input.find("\"", pos2 + 1) < input.length())) 455 { 456 // It was - get the string between the quotes 457 this->value_.setValue(input.substr(pos1, pos2 - pos1)); 458 return true; 459 } 460 461 // It wasn't - use the default-value and restore the entry in the config-file. 462 this->value_.setValue(defvalue); 463 return false; 464 } 465 466 /** 467 @brief Parses a given std::string into a value of the type _Vector2 and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 468 @param input The string to convert 469 @param defvalue The default-value 470 @return True if the string was successfully parsed 471 */ 472 bool ConfigValueContainer::parseString(const std::string& input, const Vector2& defvalue) 473 { 474 // Strip the value-string 475 unsigned int pos1 = input.find("(") + 1; 476 unsigned int pos2 = input.find(")", pos1); 477 478 // Try to convert the stripped value-string to Vector2 479 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 480 { 481 std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 482 if (!ConvertValue(&this->value_.getVector2().x, tokens[0])) 483 { 484 this->value_.setValue(defvalue); 485 return false; 486 } 487 if (!ConvertValue(&this->value_.getVector2().y, tokens[1])) 488 { 489 this->value_.setValue(defvalue); 490 return false; 491 } 492 493 return true; 494 } 495 496 this->value_.setValue(defvalue); 497 return false; 498 } 499 500 /** 501 @brief Parses a given std::string into a value of the type Vector3 and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 502 @param input The string to convert 503 @param defvalue The default-value 504 @return True if the string was successfully parsed 505 */ 506 bool ConfigValueContainer::parseString(const std::string& input, const Vector3& defvalue) 507 { 508 // Strip the value-string 509 unsigned int pos1 = input.find("(") + 1; 510 unsigned int pos2 = input.find(")", pos1); 511 512 // Try to convert the stripped value-string to Vector3 513 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 514 { 515 std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 516 if (!ConvertValue(&this->value_.getVector3().x, tokens[0])) 517 { 518 this->value_.setValue(defvalue); 519 return false; 520 } 521 if (!ConvertValue(&this->value_.getVector3().y, tokens[1])) 522 { 523 this->value_.setValue(defvalue); 524 return false; 525 } 526 if (!ConvertValue(&this->value_.getVector3().z, tokens[2])) 527 { 528 this->value_.setValue(defvalue); 529 return false; 530 } 531 532 return true; 533 } 534 535 this->value_.setValue(defvalue); 536 return false; 537 } 538 539 /** 540 @brief Parses a given std::string into a value of the type ColourValue and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 541 @param input The string to convert 542 @param defvalue The default-value 543 @return True if the string was successfully parsed 544 */ 545 bool ConfigValueContainer::parseString(const std::string& input, const ColourValue& defvalue) 546 { 547 // Strip the value-string 548 unsigned int pos1 = input.find("(") + 1; 549 unsigned int pos2 = input.find(")", pos1); 550 551 // Try to convert the stripped value-string to Vector3 552 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 553 { 554 std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 555 if (!ConvertValue(&this->value_.getColourValue().r, tokens[0])) 556 { 557 this->value_.setValue(defvalue); 558 return false; 559 } 560 if (!ConvertValue(&this->value_.getColourValue().g, tokens[1])) 561 { 562 this->value_.setValue(defvalue); 563 return false; 564 } 565 if (!ConvertValue(&this->value_.getColourValue().b, tokens[2])) 566 { 567 this->value_.setValue(defvalue); 568 return false; 569 } 570 if (!ConvertValue(&this->value_.getColourValue().a, tokens[3])) 571 { 572 this->value_.setValue(defvalue); 573 return false; 574 } 575 576 return true; 577 } 578 579 this->value_.setValue(defvalue); 580 return false; 581 } 582 583 /** 584 @brief Parses a given std::string into a value of the type Quaternion and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 585 @param input The string to convert 586 @param defvalue The default-value 587 @return True if the string was successfully parsed 588 */ 589 bool ConfigValueContainer::parseString(const std::string& input, const Quaternion& defvalue) 590 { 591 // Strip the value-string 592 unsigned int pos1 = input.find("(") + 1; 593 unsigned int pos2 = input.find(")", pos1); 594 595 // Try to convert the stripped value-string to Vector3 596 if (pos1 < input.length() && pos2 < input.length() && pos1 < pos2) 597 { 598 std::vector<std::string> tokens = tokenize(input.substr(pos1, pos2 - pos1), ","); 599 if (!ConvertValue(&this->value_.getQuaternion().w, tokens[0])) 600 { 601 this->value_.setValue(defvalue); 602 return false; 603 } 604 if (!ConvertValue(&this->value_.getQuaternion().x, tokens[1])) 605 { 606 this->value_.setValue(defvalue); 607 return false; 608 } 609 if (!ConvertValue(&this->value_.getQuaternion().y, tokens[2])) 610 { 611 this->value_.setValue(defvalue); 612 return false; 613 } 614 if (!ConvertValue(&this->value_.getQuaternion().z, tokens[3])) 615 { 616 this->value_.setValue(defvalue); 617 return false; 618 } 619 620 return true; 621 } 622 623 this->value_.setValue(defvalue); 624 return false; 625 } 626 627 /** 628 @brief Parses a given std::string into a value of the type long double and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 629 @param input The string to convert 630 @param defvalue The default-value 631 @return True if the string was successfully parsed 632 */ 633 bool ConfigValueContainer::parseString(const std::string& input, const Radian& defvalue) 634 { 635 return ConvertValue(&this->value_.getRadian(), input, defvalue); 636 } 637 638 /** 639 @brief Parses a given std::string into a value of the type long double and assigns it to the right variable. If the conversion failed, the default-value gets assigned. 640 @param input The string to convert 641 @param defvalue The default-value 642 @return True if the string was successfully parsed 643 */ 644 bool ConfigValueContainer::parseString(const std::string& input, const Degree& defvalue) 645 { 646 return ConvertValue(&this->value_.getDegree(), input, defvalue); 129 this->value_ = defvalue; 130 return false; 131 } 132 } 133 134 /** 135 @brief Sets the corresponding entry in the config-file to a given value. 136 */ 137 void ConfigValueContainer::setLineInConfigFile(const std::string& input) 138 { 139 (*this->configFileLine_) = this->varname_ + "=" + input; 140 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); 647 141 } 648 142 … … 650 144 @brief Sets the corresponding entry in the config-file back to the default value. 651 145 */ 652 void ConfigValueContainer::resetConfigFileEntry() 653 { 654 (*this->configFileLine_) = this->varname_ + "=" + this->defvalueString_; 655 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); 656 } 657 658 /** 659 @brief Sets the value of the variable back to the default value and resets the config-file entry. 660 */ 661 void ConfigValueContainer::resetConfigValue() 662 { 663 this->parseString(this->defvalueString_, this->value_); 664 this->resetConfigFileEntry(); 146 void ConfigValueContainer::resetLineInConfigFile() 147 { 148 this->setLineInConfigFile(this->defvalueString_); 665 149 } 666 150 … … 668 152 @brief Searches the corresponding entry in the config-file and creates it, if there is no entry. 669 153 */ 670 void ConfigValueContainer::search ConfigFileLine()154 void ConfigValueContainer::searchLineInConfigFile() 671 155 { 672 156 // Read the file if needed … … 677 161 std::string section = ""; 678 162 section.append("["); 679 section.append(this-> classname_);163 section.append(this->identifier_->getName()); 680 164 section.append("]"); 681 165 … … 686 170 { 687 171 // Don't try to parse comments 688 if ( this->isComment(*it1))172 if (isComment(*it1)) 689 173 continue; 690 174 … … 700 184 { 701 185 // Don't try to parse comments 702 if ( this->isComment(*it2))186 if (isComment(*it2)) 703 187 continue; 704 188 … … 706 190 // section but in front of the following empty lines before the next section. 707 191 // (So this helps to keep a nice formatting with empty-lines between sections in the config-file) 708 if ( this->isEmpty(*it2))192 if (isEmpty(*it2)) 709 193 { 710 194 if (!bLineIsEmpty) … … 760 244 { 761 245 // We obviously didn't found the right section, so we'll create it 762 this->getConfigFileLines().push_back("[" + this-> classname_+ "]"); // Create the section246 this->getConfigFileLines().push_back("[" + this->identifier_->getName() + "]"); // Create the section 763 247 this->getConfigFileLines().push_back(this->varname_ + "=" + this->defvalueString_); // Create the line 764 248 this->configFileLine_ = --this->getConfigFileLines().end(); // Set the pointer to the last element 765 249 success = true; 766 this->getConfigFileLines().push_back(""); // Add an empty line - this is needed for the algorithm in the searchConfigFileLine-function 767 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); // Save the changed config-file 768 } 769 } 770 771 /** 772 @brief Determines if a line in the config-file is a comment. 773 @param line The line to check 774 @return True = it's a comment 775 */ 776 bool ConfigValueContainer::isComment(const std::string& line) 777 { 778 // Strip the line, whitespaces are disturbing 779 std::string teststring = getStrippedLine(line); 780 781 // There are four possible comment-symbols: 782 // 1) #comment in script-language style 783 // 2) %comment in matlab style 784 // 3) ;comment in unreal tournament config-file style 785 // 4) //comment in code style 786 if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[0] == '/')) 787 return true; 788 789 return false; 790 } 791 792 /** 793 @brief Determines if a line in the config-file is empty (contains only whitespaces). 794 @param line The line to check 795 @return True = it's empty 796 */ 797 bool ConfigValueContainer::isEmpty(const std::string& line) 798 { 799 return getStrippedLine(line) == ""; 800 } 801 802 /** 803 @brief Removes all whitespaces from a line. 804 @param line The line to strip 805 @return The stripped line 806 */ 807 std::string ConfigValueContainer::getStrippedLine(const std::string& line) 808 { 809 std::string output = line; 810 unsigned int pos; 811 while ((pos = output.find(" ")) < output.length()) 812 output.erase(pos, 1); 813 while ((pos = output.find("\t")) < output.length()) 814 output.erase(pos, 1); 815 816 return output; 250 this->getConfigFileLines().push_back(""); // Add an empty line - this is needed for the algorithm in the searchLineInConfigFile-function 251 ConfigValueContainer::writeConfigFile(CONFIGFILEPATH); // Save the changed config-file 252 } 817 253 } 818 254 … … 822 258 @return The value-string 823 259 */ 824 std::string ConfigValueContainer::parseValueString (bool bStripped)260 std::string ConfigValueContainer::parseValueStringFromConfigFile(bool bStripped) 825 261 { 826 262 std::string output; 827 263 if (bStripped) 828 output = this->getStrippedLine(*this->configFileLine_);264 output = getStripped(*this->configFileLine_); 829 265 else 830 266 output = *this->configFileLine_; … … 889 325 file.getline(line, 1024); 890 326 ConfigValueContainer::getConfigFileLines().push_back(line); 891 // std::cout << "### ->" << line << "<- : empty: " << isEmpty(line) << " comment: " << isComment(line) << std::endl;892 327 } 893 328 … … 896 331 897 332 // Add an empty line to the end of the file if needed 898 // this is needed for the algorithm in the search ConfigFileLine-function333 // this is needed for the algorithm in the searchLineInConfigFile-function 899 334 if ((ConfigValueContainer::getConfigFileLines().size() > 0) && !isEmpty(*ConfigValueContainer::getConfigFileLines().rbegin())) 900 {901 // std::cout << "### newline added" << std::endl;902 335 ConfigValueContainer::getConfigFileLines().push_back(""); 903 }904 336 905 337 file.close(); … … 949 381 if (!this->bAddedDescription_) 950 382 { 951 this->description_ = std::string("ConfigValueDescription::" + this-> classname_+ "::" + this->varname_);383 this->description_ = std::string("ConfigValueDescription::" + this->identifier_->getName() + "::" + this->varname_); 952 384 AddLanguageEntry(this->description_, description); 953 385 this->bAddedDescription_ = true; -
code/branches/core2/src/orxonox/core/ConfigValueContainer.h
r947 r957 72 72 { 73 73 public: 74 ConfigValueContainer( const std::string& classname, const std::string& varname, MultiTypeMath defvalue);74 ConfigValueContainer(Identifier* identifier, const std::string& varname, MultiTypeMath defvalue); 75 75 76 76 /** @brief Returns the configured value. @param value This is only needed to determine the right type. @return The value */ 77 /* template <typename T> 78 inline ConfigValueContainer& getValue(T& value) { this->value_.getValue(value); return *this; } 79 */ 80 inline ConfigValueContainer& getValue(int* value) { this->value_.getValue(value); return *this; } 81 inline ConfigValueContainer& getValue(unsigned int* value) { this->value_.getValue(value); return *this; } 82 inline ConfigValueContainer& getValue(char* value) { this->value_.getValue(value); return *this; } 83 inline ConfigValueContainer& getValue(unsigned char* value) { this->value_.getValue(value); return *this; } 84 inline ConfigValueContainer& getValue(short* value) { this->value_.getValue(value); return *this; } 85 inline ConfigValueContainer& getValue(unsigned short* value) { this->value_.getValue(value); return *this; } 86 inline ConfigValueContainer& getValue(long* value) { this->value_.getValue(value); return *this; } 87 inline ConfigValueContainer& getValue(unsigned long* value) { this->value_.getValue(value); return *this; } 88 inline ConfigValueContainer& getValue(float* value) { this->value_.getValue(value); return *this; } 89 inline ConfigValueContainer& getValue(double* value) { this->value_.getValue(value); return *this; } 90 inline ConfigValueContainer& getValue(long double* value) { this->value_.getValue(value); return *this; } 91 inline ConfigValueContainer& getValue(bool* value) { this->value_.getValue(value); return *this; } 92 inline ConfigValueContainer& getValue(std::string* value) { this->value_.getValue(value); return *this; } 93 inline ConfigValueContainer& getValue(const char** value) { this->value_.getValue(value); return *this; } 94 inline ConfigValueContainer& getValue(Vector2* value) { this->value_.getValue(value); return *this; } 95 inline ConfigValueContainer& getValue(Vector3* value) { this->value_.getValue(value); return *this; } 96 inline ConfigValueContainer& getValue(ColourValue* value) { this->value_.getValue(value); return *this; } 97 inline ConfigValueContainer& getValue(Quaternion* value) { this->value_.getValue(value); return *this; } 98 inline ConfigValueContainer& getValue(Radian* value) { this->value_.getValue(value); return *this; } 99 inline ConfigValueContainer& getValue(Degree* value) { this->value_.getValue(value); return *this; } 77 template <typename T> 78 inline ConfigValueContainer& getValue(T* value) 79 { this->value_.getValue(value); return *this; } 100 80 101 81 void description(const std::string& description); 102 82 const std::string& getDescription() const; 103 83 104 bool parseString(const std::string& input, const MultiTypeMath& defvalue = MT_null); 105 bool valueToString(std::string* output, MultiTypeMath& input); 106 void resetConfigFileEntry(); 107 void resetConfigValue(); 84 bool set(const std::string& input); 85 bool tset(const std::string& input); 86 bool reset(); 108 87 109 static std::string getStrippedLine(const std::string& line);110 static bool isEmpty(const std::string& line);111 static bool isComment(const std::string& line);112 88 /** @brief Converts the config-value to a string. @return The string */ 89 inline std::string toString() const 90 { return this->value_.toString(); } 91 /** @brief Returns the typename of the assigned config-value. @return The typename */ 113 92 inline std::string getTypename() const 114 93 { return this->value_.getTypename(); } 115 94 116 95 private: 117 bool parseString(const std::string& input, int defvalue); 118 bool parseString(const std::string& input, unsigned int defvalue); 119 bool parseString(const std::string& input, char defvalue); 120 bool parseString(const std::string& input, unsigned char defvalue); 121 bool parseString(const std::string& input, short defvalue); 122 bool parseString(const std::string& input, unsigned short defvalue); 123 bool parseString(const std::string& input, long defvalue); 124 bool parseString(const std::string& input, unsigned long defvalue); 125 bool parseString(const std::string& input, float defvalue); 126 bool parseString(const std::string& input, double defvalue); 127 bool parseString(const std::string& input, long double defvalue); 128 bool parseString(const std::string& input, bool defvalue); 129 bool parseString(const std::string& input, const std::string& defvalue); 130 bool parseString(const std::string& input, const char* defvalue); 131 bool parseString(const std::string& input, const Vector2& defvalue); 132 bool parseString(const std::string& input, const Vector3& defvalue); 133 bool parseString(const std::string& input, const ColourValue& defvalue); 134 bool parseString(const std::string& input, const Quaternion& defvalue); 135 bool parseString(const std::string& input, const Radian& defvalue); 136 bool parseString(const std::string& input, const Degree& defvalue); 137 96 static void readConfigFile(const std::string& filename); 97 static void writeConfigFile(const std::string& filename); 138 98 static std::list<std::string>& getConfigFileLines(); 139 99 static bool finishedReadingConfigFile(bool finished = false); 140 void searchConfigFileLine();141 std::string parseValueString(bool bStripped = true);142 100 143 static void readConfigFile(const std::string& filename);144 static void writeConfigFile(const std::string& filename);101 bool parse(const std::string& input); 102 bool parse(const std::string& input, const MultiTypeMath& defvalue); 145 103 146 std::string classname_; //!< The name of the class the variable belongs to 104 void setLineInConfigFile(const std::string& input); 105 void resetLineInConfigFile(); 106 void searchLineInConfigFile(); 107 108 std::string parseValueStringFromConfigFile(bool bStripped = true); 109 110 Identifier* identifier_; //!< The name of the class the variable belongs to 147 111 std::string varname_; //!< The name of the variable 148 112 std::string defvalueString_; //!< The string of the default-variable -
code/branches/core2/src/orxonox/core/CoreIncludes.h
r871 r957 120 120 if (!container##varname) \ 121 121 { \ 122 container##varname = new orxonox::ConfigValueContainer(this->getIdentifier() ->getName(), #varname, varname = defvalue); \122 container##varname = new orxonox::ConfigValueContainer(this->getIdentifier(), #varname, varname = defvalue); \ 123 123 this->getIdentifier()->addConfigValueContainer(#varname, container##varname); \ 124 124 } \ … … 133 133 if (container##varname##reset) \ 134 134 { \ 135 container##varname##reset->reset ConfigValue(); \135 container##varname##reset->reset(); \ 136 136 container##varname##reset->getValue(&varname); \ 137 137 } \ -
code/branches/core2/src/orxonox/core/Executor.cc
r947 r957 64 64 } 65 65 66 voidExecutor::setDescription(const std::string& description)66 Executor& Executor::setDescription(const std::string& description) 67 67 { 68 68 if (!this->bAddedDescription_) … … 72 72 this->bAddedDescription_ = true; 73 73 } 74 return (*this); 74 75 } 75 76 … … 79 80 } 80 81 81 voidExecutor::setDescriptionParam(int param, const std::string& description)82 Executor& Executor::setDescriptionParam(int param, const std::string& description) 82 83 { 83 84 if (param >= 0 && param < MAX_FUNCTOR_ARGUMENTS) … … 87 88 std::string paramnumber; 88 89 if (!Convert::ToString(¶mnumber, param)) 89 return ;90 return (*this); 90 91 91 92 this->descriptionParam_[param] = std::string("ExecutorDescription::" + this->name_ + "::param" + paramnumber); … … 94 95 } 95 96 } 97 return (*this); 96 98 } 97 99 … … 104 106 } 105 107 106 voidExecutor::setDescriptionReturnvalue(const std::string& description)108 Executor& Executor::setDescriptionReturnvalue(const std::string& description) 107 109 { 108 110 if (!this->bAddedDescriptionReturnvalue_) … … 112 114 this->bAddedDescriptionReturnvalue_ = true; 113 115 } 116 return (*this); 114 117 } 115 118 … … 119 122 } 120 123 121 void Executor::setDefaultValues(const MultiTypeMath& param1) 122 { 123 this->defaultValue_[0] = param1; 124 this->bAddedDefaultValue_[0] = true; 125 } 126 127 void Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) 128 { 129 this->defaultValue_[0] = param1; 130 this->bAddedDefaultValue_[0] = true; 131 this->defaultValue_[1] = param2; 132 this->bAddedDefaultValue_[1] = true; 133 } 134 135 void Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) 124 Executor& Executor::setDefaultValues(const MultiTypeMath& param1) 125 { 126 this->defaultValue_[0] = param1; 127 this->bAddedDefaultValue_[0] = true; 128 129 return (*this); 130 } 131 132 Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2) 133 { 134 this->defaultValue_[0] = param1; 135 this->bAddedDefaultValue_[0] = true; 136 this->defaultValue_[1] = param2; 137 this->bAddedDefaultValue_[1] = true; 138 139 return (*this); 140 } 141 142 Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3) 136 143 { 137 144 this->defaultValue_[0] = param1; … … 141 148 this->defaultValue_[2] = param3; 142 149 this->bAddedDefaultValue_[2] = true; 143 } 144 145 void Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) 150 151 return (*this); 152 } 153 154 Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4) 146 155 { 147 156 this->defaultValue_[0] = param1; … … 153 162 this->defaultValue_[3] = param4; 154 163 this->bAddedDefaultValue_[3] = true; 155 } 156 157 void Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) 164 165 return (*this); 166 } 167 168 Executor& Executor::setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5) 158 169 { 159 170 this->defaultValue_[0] = param1; … … 167 178 this->defaultValue_[4] = param5; 168 179 this->bAddedDefaultValue_[4] = true; 169 } 170 171 void Executor::setDefaultValue(unsigned int index, const MultiTypeMath& param) 180 181 return (*this); 182 } 183 184 Executor& Executor::setDefaultValue(unsigned int index, const MultiTypeMath& param) 172 185 { 173 186 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) … … 176 189 this->bAddedDefaultValue_[index] = true; 177 190 } 191 return (*this); 178 192 } 179 193 -
code/branches/core2/src/orxonox/core/Executor.h
r947 r957 165 165 bool parse(const std::string& params, const std::string& delimiter = " ") const; 166 166 167 voidsetDescription(const std::string& description);167 Executor& setDescription(const std::string& description); 168 168 const std::string& getDescription() const; 169 169 170 voidsetDescriptionParam(int param, const std::string& description);170 Executor& setDescriptionParam(int param, const std::string& description); 171 171 const std::string& getDescriptionParam(int param) const; 172 172 173 voidsetDescriptionReturnvalue(const std::string& description);173 Executor& setDescriptionReturnvalue(const std::string& description); 174 174 const std::string& getDescriptionReturnvalue(int param) const; 175 175 … … 197 197 { return this->accessLevel_; } 198 198 199 void setDefaultValues(const MultiTypeMath& param1); 200 void setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2); 201 void setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3); 202 void setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4); 203 void setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5); 204 void setDefaultValue(unsigned int index, const MultiTypeMath& param); 199 Executor& setDefaultValues(const MultiTypeMath& param1); 200 Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2); 201 Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3); 202 Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4); 203 Executor& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5); 204 Executor& setDefaultValue(unsigned int index, const MultiTypeMath& param); 205 206 inline MultiTypeMath getDefaultValue(unsigned int index) const 207 { 208 if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS) 209 return this->defaultValue_[index]; 210 211 return MT_null; 212 } 205 213 206 214 bool allDefaultValuesSet() const; -
code/branches/core2/src/orxonox/core/Identifier.h
r947 r957 109 109 bool isDirectParentOf(const Identifier* identifier) const; 110 110 111 virtual const ObjectList<BaseObject>* getObjectList() const = 0; 112 113 virtual void updateConfigValues() const = 0; 114 111 115 /** @brief Removes all objects of the corresponding class. */ 112 116 virtual void removeObjects() const = 0; … … 304 308 void removeObjects() const; 305 309 void setName(const std::string& name); 310 /** @brief Returns the list of all existing objects of this class. @return The list */ 306 311 inline const ObjectList<T>* getObjects() const { return this->objects_; } 312 /** @brief Returns a list of all existing objects of this class. @return The list */ 313 inline const ObjectList<BaseObject>* getObjectList() const { return (ObjectList<BaseObject>*)this->objects_; } 314 315 void updateConfigValues() const; 307 316 308 317 XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname); … … 395 404 for (Iterator<T> it = this->objects_->start(); it;) 396 405 delete *(it++); 406 } 407 408 /** 409 @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function. 410 */ 411 template <class T> 412 void ClassIdentifier<T>::updateConfigValues() const 413 { 414 for (Iterator<T> it = this->objects_->start(); it; ++it) 415 ((T*)*it)->setConfigValues(); 397 416 } 398 417 -
code/branches/core2/src/orxonox/objects/Ambient.cc
r947 r957 47 47 namespace orxonox 48 48 { 49 ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false) ;49 ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false).setDefaultValues(ColourValue(1, 1, 1, 1)); 50 50 51 51 CreateFactory(Ambient); -
code/branches/core2/src/orxonox/objects/Projectile.cc
r790 r957 71 71 SetConfigValue(lifetime_, 10.0).description("The time in seconds a projectile stays alive"); 72 72 SetConfigValue(speed_, 2000.0).description("The speed of a projectile in units per second"); 73 74 this->setVelocity(Vector3(1, 0, 0) * this->speed_); 73 75 } 74 76 -
code/branches/core2/src/orxonox/tools/Timer.h
r871 r957 83 83 /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */ 84 84 inline bool isActive() const { return this->bActive_; } 85 /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */ 86 inline void addTime(float time) { this->time_ += time; } 87 /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */ 88 inline void removeTime(float time) { this->time_ -= time; } 85 89 86 90 protected: -
code/branches/core2/src/util/String.cc
r947 r957 72 72 // 3) ;comment in unreal tournament config-file style 73 73 // 4) //comment in code style 74 if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[0] == '/')) 75 return true; 74 if (teststring.size() >= 2) 75 { 76 if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[1] == '/')) 77 return true; 78 } 79 else if (teststring.size() == 1) 80 { 81 if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';') 82 return true; 83 } 76 84 77 85 return false;
Note: See TracChangeset
for help on using the changeset viewer.