Changeset 9768 in orxonox.OLD for branches/new_class_id/src
- Timestamp:
- Sep 19, 2006, 6:13:52 PM (18 years ago)
- Location:
- branches/new_class_id/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/Makefile.am
r9766 r9768 21 21 loading/load_param_xml.cc \ 22 22 loading/load_param_description.cc \ 23 loading/load_param_class_desc tiption.cc \23 loading/load_param_class_description.cc \ 24 24 loading/factory.cc \ 25 25 loading/fast_factory.cc \ -
branches/new_class_id/src/lib/util/loading/load_param_class_description.cc
r9765 r9768 17 17 18 18 #include "multi_type.h" 19 #include <stdarg.h>20 19 #include "debug.h" 21 22 /**23 * @param paramName the name of the parameter to load24 */25 LoadParamDescription::LoadParamDescription(const std::string& paramName)26 {27 this->types = NULL;28 this->defaultValues = NULL;29 this->paramName = paramName;30 }31 32 /**33 * removes all the alocated memory34 */35 LoadParamDescription::~LoadParamDescription()36 {37 if (this->defaultValues != NULL)38 {39 for(int i = 0; i < this->paramCount; i++)40 {41 delete[] this->defaultValues[i];42 }43 }44 45 delete[] this->types;46 delete[] this->defaultValues;47 }48 49 /**50 * @param descriptionText The text to set as a description for this Parameter51 */52 void LoadParamDescription::setDescription(const std::string& descriptionText)53 {54 this->description = descriptionText;55 }56 57 /**58 * prints out this parameter, its input method and the description (if availiable)59 */60 void LoadParamDescription::print() const61 {62 PRINT(3)(" <%s>", this->paramName.c_str());63 for (int i = 0; i < this->paramCount; i++)64 {65 if (i > 0)66 PRINT(3)(",");67 // FIXME68 // switch (this->types[i])69 // {70 // default:71 // PRINTF(3)("none");72 // break;73 // case ParameterBool:74 // PRINT(3)("bool");75 // break;76 // case ParameterChar:77 // PRINT(3)("char");78 // break;79 // case ParameterString:80 // PRINT(3)("string");81 // break;82 // case ParameterInt:83 // PRINT(3)("int");84 // break;85 // case ParameterUInt:86 // PRINT(3)("Uint");87 // break;88 // case ParameterFloat:89 // PRINT(3)("float");90 // break;91 // case ParameterLong:92 // PRINT(3)("long");93 // break;94 // case ParameterXML:95 // PRINT(3)("XML");96 // break;97 // }98 }99 PRINT(3)("</%s>", this->paramName.c_str());100 if (!this->description.empty())101 PRINT(3)(" -- %s", this->description.c_str());102 // default values103 if (this->paramCount > 0)104 {105 PRINT(3)(" (Default: ");106 for (int i = 0; i < this->paramCount; i++)107 {108 if (i > 0)109 PRINT(3)(", ");110 if (this->types[i] & MT_STRING)111 { // leave brackets !!112 PRINT(3)("\"%s\"", this->defaultValues[i]);113 }114 else115 {116 PRINT(3)("%s", this->defaultValues[i]);117 }118 }119 PRINT(3)(")");120 }121 PRINT(3)("\n");122 }123 20 124 21 /** 125 22 * A list, that holds all the classes that are loadable (classes not objects!!) 126 23 */ 127 std::list<LoadParamClassDescription*>* LoadParamClassDescription::classList = NULL;24 LoadParamClassDescription::ClassDescriptionSet LoadParamClassDescription::_classList; 128 25 129 26 /** 130 27 * if the description of Parameters should be executed 131 28 */ 132 bool LoadParamClassDescription:: parametersDescription = false;29 bool LoadParamClassDescription::_parametersDescription = false; 133 30 134 31 /** … … 136 33 */ 137 34 LoadParamClassDescription::LoadParamClassDescription(const std::string& className) 138 { 139 this->className = className; 140 141 if (LoadParamClassDescription::classList == NULL) 142 LoadParamClassDescription::classList = new std::list<LoadParamClassDescription*>; 143 144 LoadParamClassDescription::classList->push_back(this); 145 } 35 : _className(className) 36 { } 146 37 147 38 /** … … 149 40 */ 150 41 LoadParamClassDescription::~LoadParamClassDescription() 151 { 152 std::list<LoadParamDescription*>::iterator it = this->paramList.begin(); 153 while (!this->paramList.empty()) 154 { 155 delete this->paramList.front(); 156 this->paramList.pop_front(); 157 } 158 } 42 {} 159 43 160 44 void LoadParamClassDescription::deleteAllDescriptions() 161 45 { 162 if (LoadParamClassDescription::classList != NULL) 163 { 164 while (!LoadParamClassDescription::classList->empty()) 165 { 166 delete LoadParamClassDescription::classList->front(); 167 LoadParamClassDescription::classList->pop_front(); 168 } 169 delete LoadParamClassDescription::classList; 170 } 171 LoadParamClassDescription::classList = NULL; 46 LoadParamClassDescription::_classList.clear(); 172 47 } 173 48 174 175 /**176 * adds a class to the list of loadable classes177 * @param className The name of the class to add178 179 this function searches for the className string, and if found just returns the appropriate Class.180 Otherwise it returns a new classDescription181 */182 LoadParamClassDescription* LoadParamClassDescription::addClass(const std::string& className)183 {184 if (LoadParamClassDescription::classList != NULL)185 {186 std::list<LoadParamClassDescription*>::iterator it = LoadParamClassDescription::classList->begin();187 while (it != LoadParamClassDescription::classList->end())188 {189 if ((*it)->className == className)190 {191 return (*it);192 }193 it++;194 }195 }196 return new LoadParamClassDescription(className);197 }198 199 /**200 * does the same as addClass(const std::string& className), but with params201 * @param paramName the name of the parameter to add.202 */203 LoadParamDescription* LoadParamClassDescription::addParam(const std::string& paramName)204 {205 std::list<LoadParamDescription*>::iterator it = this->paramList.begin();206 while (it != this->paramList.end())207 {208 if ((*it)->paramName == paramName)209 {210 return NULL;211 }212 it++;213 }214 215 LoadParamDescription* newParam = new LoadParamDescription(paramName);216 217 this->paramList.push_back(newParam);218 return newParam;219 }220 49 221 50 /** … … 228 57 PRINT(3)("===============================================================\n"); 229 58 PRINT(3)(" Listing all the Loadable Options (loaded since Game started).\n\n"); 230 if (LoadParamClassDescription::classList != NULL) 59 for (ClassDescriptionSet::const_iterator classIt = LoadParamClassDescription::_classList.begin(); 60 classIt != LoadParamClassDescription::_classList.begin(); 61 classIt ++) 231 62 { 232 std::list<LoadParamClassDescription*>::iterator classDesc = LoadParamClassDescription::classList->begin(); 233 while (classDesc != LoadParamClassDescription::classList->end()) 63 PRINT(3)("<%s>\n", (*classIt)._className.c_str()); 64 for (ParamDescriptionSet::const_iterator param = (*classIt)._parameters.begin(); 65 param != (*classIt)._parameters.end(); 66 ++param) 234 67 { 235 PRINT(3)("<%s>\n", (*classDesc)->className.c_str()); 236 std::list<LoadParamDescription*>::iterator param = (*classDesc)->paramList.begin(); 237 while (param != (*classDesc)->paramList.end()) 238 { 239 (*param)->print(); 240 param++; 241 } 242 PRINT(3)("</%s>\n\n", (*classDesc)->className.c_str()); 243 classDesc++; 68 (*param).print(); 244 69 } 70 PRINT(3)("</%s>\n\n", (*classIt)._className.c_str()); 245 71 } 246 else247 PRINT(3)("no Classes defined so far\n");248 72 PRINT(3)("===============================================================\n"); 249 73 } 250 251 /**252 * searches for classes, which beginn with classNameBegin253 * @param classNameBegin the beginning string of a Class254 * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,255 * !! The strings MUST NOT be deleted !!256 */257 std::list<std::string> LoadParamClassDescription::searchClassWithShort(const std::string& classNameBegin)258 {259 /// FIXME260 // NOT USED261 /* unsigned int searchLength = strlen(classNameBegin);262 std::list<const std::string&> retVal;263 264 tIterator<LoadParamClassDescription>* iterator = LoadParamClassDescription::classList->getIterator();265 LoadParamClassDescription* enumClassDesc = iterator->firstElement();266 while (enumClassDesc)267 {268 if (strlen(enumClassDesc->className)>searchLength+1 &&269 !strncasecmp(enumClassDesc->className, classNameBegin, searchLength))270 {271 retVal->add(enumClassDesc->className);272 }273 enumClassDesc = iterator->nextElement();274 }275 delete iterator;276 277 return retVal;*/278 std::list<std::string> a;279 return a;280 } -
branches/new_class_id/src/lib/util/loading/load_param_class_description.h
r9767 r9768 44 44 45 45 static void printAll(const std::string& fileName = ""); 46 static std::list<std::string> searchClassWithShort(const std::string& classNameBegin);47 // static const LoadParamDescription* getClass(const std::string& className);48 46 49 47 private: … … 53 51 static bool _parametersDescription; //!< if parameter-description should be enabled globally. 54 52 55 static ClassDescriptionSet *_classList; //!< a list, that stores all the loadable classes. (after one instance has been loaded)53 static ClassDescriptionSet _classList; //!< a list, that stores all the loadable classes. (after one instance has been loaded) 56 54 57 55 private: -
branches/new_class_id/src/lib/util/loading/load_param_description.cc
r9767 r9768 107 107 PRINT(3)("\n"); 108 108 } 109 110 -
branches/new_class_id/src/orxonox.cc
r9767 r9768 53 53 #include "shell_buffer.h" 54 54 55 #include "util/loading/load_param_class_description.h"56 57 55 #include "network_manager.h" 58 56 #include "shared_network_data.h" … … 128 126 FastFactory::deleteAll(); 129 127 OrxShell::ShellCommandClass::unregisterAllCommands(); 130 131 LoadParamClassDescription::deleteAllDescriptions();132 128 133 129 // handlers
Note: See TracChangeset
for help on using the changeset viewer.