Changeset 4623 in orxonox.OLD for orxonox/trunk/src/util/loading/load_param.cc
- Timestamp:
- Jun 13, 2005, 7:31:50 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/load_param.cc
r4598 r4623 27 27 \param paramCount: how many parameters this loading-function takes 28 28 \param multi: if false LoadParam assumes only one occurence of this parameter in root, if true it assumes multiple occurences. 29 \param ...: the parameter information 29 \param ...: the parameter information (1. Parameter, 2. Default Value for the Parameter, ...) 30 30 */ 31 31 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, … … 55 55 this->paramDesc = NULL; 56 56 if (LoadClassDescription::parametersDescription) 57 { 57 { 58 //! \todo this must only be done once for each class. 58 59 // locating the class 59 this->classDesc = LoadClassDescription::addClass(object->getClassName()); 60 this->paramDesc = this->classDesc->addParam(paramName); 61 60 this->classDesc = LoadClassDescription::addClass(object->getClassName()); 61 62 if ((this->paramDesc = this->classDesc->addParam(paramName)) != NULL) 63 { 64 65 this->paramDesc->paramCount = paramCount; 62 66 this->paramDesc->types = new char*[paramCount]; 63 this->paramDesc-> paramCount = paramCount;67 this->paramDesc->defaultValues = new char*[paramCount]; 64 68 65 69 va_list types; 66 70 va_start (types, pointerToParam); 71 char defaultVal[512]; 67 72 for(int i = 0; i < paramCount; i++) 68 { 69 const char* tmpTypeName = va_arg (types, const char*); 70 this->paramDesc->types[i] = new char[strlen(tmpTypeName)+1]; 71 strcpy(this->paramDesc->types[i], tmpTypeName); 72 } 73 { 74 // parameters parsed 75 const char* tmpTypeName = va_arg (types, const char*); 76 this->paramDesc->types[i] = new char[strlen(tmpTypeName)+1]; 77 strcpy(this->paramDesc->types[i], tmpTypeName); 78 79 // default value description 80 if (!strcmp(tmpTypeName, l_INT_NAME)) 81 { 82 sprintf(defaultVal, "%d", va_arg(types, l_INT_TYPE)); 83 } 84 else if (!strcmp(tmpTypeName, l_LONG_NAME)) 85 { 86 sprintf(defaultVal, "%0.3f", va_arg(types, l_LONG_TYPE)); 87 } 88 /* else if (!strcmp(tmpTypeName, l_SHORT_NAME)) 89 { 90 sprintf(defaultVal, "%d", va_arg(types, l_SHORT_TYPE)); 91 }*/ 92 else if (!strcmp(tmpTypeName, l_FLOAT_NAME)) 93 { 94 sprintf(defaultVal, "%0.3f", va_arg(types, double)); 95 } 96 else if (!strcmp(tmpTypeName, l_STRING_NAME)) 97 { 98 sprintf(defaultVal, "%s", va_arg(types, l_STRING_TYPE)); 99 } 100 else if (!strcmp(tmpTypeName, l_XML_ELEM_NAME)) 101 { 102 sprintf(defaultVal, ""); 103 } 104 105 this->paramDesc->defaultValues[i] = new char[strlen(defaultVal)+1]; 106 strcpy(this->paramDesc->defaultValues[i], defaultVal); 107 } 73 108 va_end(types); 74 109 75 110 int argCount = 0; 76 111 } 112 } 77 113 } 78 114 … … 99 135 this->paramName = new char[strlen(paramName)+1]; 100 136 strcpy(this->paramName, paramName); 137 this->defaultValues = NULL; 101 138 } 102 139 … … 107 144 { 108 145 for(int i = 0; i < this->paramCount; i++) 109 { 110 delete this->types[i]; 111 } 146 { 147 delete this->types[i]; 148 } 149 for(int i = 0; i < this->paramCount; i++) 150 { 151 delete this->defaultValues[i]; 152 } 153 112 154 delete []this->types; 155 delete []this->defaultValues; 113 156 delete []this->paramName; 114 157 delete []this->description; … … 139 182 if (this->description) 140 183 PRINT(3)(" -- %s", this->description); 184 // default values 185 if (this->paramCount > 0) 186 { 187 PRINT(3)(" (Default: "); 188 for (int i = 0; i < this->paramCount; i++) 189 { 190 if (i > 0) 191 PRINT(3)(", "); 192 PRINT(3)("%s", this->defaultValues[i]); 193 } 194 PRINT(3)(")"); 195 } 141 196 PRINT(3)("\n"); 142 197 }
Note: See TracChangeset
for help on using the changeset viewer.