/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Benjamin Grauer co-programmer: ... */ #include "load_param_class_description.h" #include "multi_type.h" #include "debug.h" /** * A list, that holds all the classes that are loadable (classes not objects!!) */ LoadParamClassDescription::ClassDescriptionMap LoadParamClassDescription::_classList; /** * if the description of Parameters should be executed */ bool LoadParamClassDescription::_parametersDescription = false; /** * @param className the name of the class to be loadable */ LoadParamClassDescription::LoadParamClassDescription(const std::string& className) : _className(className) { } /** * deletes a classDescription (deletes all the parameterDescriptions as well */ LoadParamClassDescription::~LoadParamClassDescription() {} void LoadParamClassDescription::deleteAllDescriptions() { LoadParamClassDescription::_classList.clear(); } void LoadParamClassDescription::describeClass(const ClassID& classID, const std::string& paramName, const std::string& descriptionText) { ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName); } void LoadParamClassDescription::setValuesOf(const ClassID& classID, const std::string& paramName, unsigned int paramCount, const MultiType* const defaultValues, bool retVal) { ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName); } /** * @brief finds the Iterator to the ParameterDescription paramName matching classID * @param classID the ClassID to match. * @param paramName the name of the parameter in the Class. * @returns the iterator on match. * * @note this function creates the Element classID.name()::paramName on the go if it does not exist. */ LoadParamClassDescription::ParamDescriptionMap::iterator LoadParamClassDescription::getParamDescription(const ClassID& classID, const std::string& paramName) { /// Locate the ClassDescription first ClassDescriptionMap::iterator classIt = LoadParamClassDescription::_classList.find(classID); if (classIt == LoadParamClassDescription::_classList.end()) { LoadParamClassDescription::_classList[classID] = LoadParamClassDescription(classID.name()); classIt = LoadParamClassDescription::_classList.find(classID); printf("Inserted %s\n", classID.name().c_str()); printAll(""); } // At this position the class-iterator should point to a valid usefull position. assert(classIt != LoadParamClassDescription::_classList.end()); /// Now locate the description with paramName. ParamDescriptionMap::iterator paramIt = (*classIt).second._parameters.find(paramName); if (paramIt == (*classIt).second._parameters.end()) { (*classIt).second._parameters[paramName] = LoadParamDescription(paramName); paramIt = (*classIt).second._parameters.find(paramName); } // at this position the param-iterator should assert (paramIt != (*classIt).second._parameters.end()); return (paramIt); } /** * @brief prints out all loadable Classes, and their parameters * @param fileName prints the output to a File * @todo implement it */ void LoadParamClassDescription::printAll(const std::string& fileName) { PRINT(0)("===============================================================\n"); PRINT(0)(" Listing all the Loadable Options (loaded since Game started).\n\n"); for (ClassDescriptionMap::const_iterator classIt = LoadParamClassDescription::_classList.begin(); classIt != LoadParamClassDescription::_classList.end(); classIt ++) { PRINT(0)("<%s>\n", (*classIt).second._className.c_str()); for (ParamDescriptionMap::const_iterator param = (*classIt).second._parameters.begin(); param != (*classIt).second._parameters.end(); ++param) { /// (*param).second.print(); } PRINT(0)("\n\n", (*classIt).second._className.c_str()); } PRINT(0)("===============================================================\n"); }