Changeset 9771 in orxonox.OLD for branches/new_class_id/src/lib
- Timestamp:
- Sep 19, 2006, 11:33:27 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/util/loading
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/loading/load_param.cc
r9770 r9771 49 49 classID.name().c_str(), classID.id(), paramName.c_str(), descriptionText.c_str()); 50 50 51 // LoadParamDescription 52 53 /// TODO REIMPLEMENT 54 /* if (LoadParamClassDescription::parametersDescription && this->paramDesc && this->paramDesc->getDescription().empty()) 55 { 56 this->paramDesc->setDescription(descriptionText); 57 }*/ 51 LoadParamClassDescription::describeClass(classID, paramName, descriptionText); 58 52 } 59 53 60 61 54 /** 55 * @brief sets the Values of the Description to a usefull text. 56 */ 57 void LoadParamBase::setDescriptionValues(const ClassID& classID, unsigned int paramCount, const MultiType* const defaultValues, bool retVal) 58 { 59 LoadParamClassDescription::setValuesOf(classID, paramName, paramCount, defaultValues, retVal); 60 } 62 61 63 62 … … 70 69 * @returns the Value of the parameter if found, NULL otherwise 71 70 */ 72 const std::string&LoadParamBase::grabParameter(const TiXmlElement* root, const std::string& parameterName)71 std::string LoadParamBase::grabParameter(const TiXmlElement* root, const std::string& parameterName) 73 72 { 74 73 const TiXmlElement* const element = grabParameterElement(root, parameterName); -
branches/new_class_id/src/lib/util/loading/load_param.h
r9770 r9771 92 92 93 93 protected: 94 void describe(const ClassID& id, const std::string& descriptionText); 94 void describe(const ClassID& classID, const std::string& descriptionText); 95 void setDescriptionValues(const ClassID& classID, unsigned int paramCount, const MultiType* const defaultValues, bool retVal = false); 95 96 96 private: 97 const std::string& grabParameter(const TiXmlElement* root, const std::string& parameterName); 98 const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName); 99 97 public: 98 static std::string grabParameter(const TiXmlElement* root, const std::string& parameterName); 99 static const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName); 100 100 101 101 protected: … … 112 112 public: 113 113 /** 114 * @brief generates a LoadParam based on 115 * @param root the Root Element to load onto the object. 116 * @param paramName the Parameter name that is loaded. 117 * @param object the Object to apply the changes on. 118 * @param executor the Functional Object, that actually executes the function Call. 114 * @brief generates a LoadParam based on: 115 * @param root the Root Element to load onto the object. @param paramName the Parameter name that is loaded. 116 * @param object the Object to apply the changes on. @param executor the Functional Object, that actually executes the function Call. 119 117 * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here) 120 118 */ … … 139 137 } 140 138 } 139 this->setDescriptionValues(OperateClass::staticClassID(), executor->getParamCount(), executor->getDefaultValues(), executor->hasRetVal()); 141 140 delete this->executor; 142 141 } … … 159 158 }; 160 159 161 // helper function162 163 164 160 #endif /* _LOAD_PARAM_H */ -
branches/new_class_id/src/lib/util/loading/load_param_class_description.cc
r9768 r9771 22 22 * A list, that holds all the classes that are loadable (classes not objects!!) 23 23 */ 24 LoadParamClassDescription::ClassDescription SetLoadParamClassDescription::_classList;24 LoadParamClassDescription::ClassDescriptionMap LoadParamClassDescription::_classList; 25 25 26 26 /** … … 48 48 49 49 50 51 void LoadParamClassDescription::describeClass(const ClassID& classID, 52 const std::string& paramName, 53 const std::string& descriptionText) 54 { 55 ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName); 56 57 } 58 59 60 void LoadParamClassDescription::setValuesOf(const ClassID& classID, 61 const std::string& paramName, 62 unsigned int paramCount, 63 const MultiType* const defaultValues, 64 bool retVal) 65 { 66 ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName); 67 68 } 69 70 50 71 /** 51 * prints out all loadable Classes, and their parameters 72 * @brief finds the Iterator to the ParameterDescription paramName matching classID 73 * @param classID the ClassID to match. 74 * @param paramName the name of the parameter in the Class. 75 * @returns the iterator on match. 76 * 77 * @note this function creates the Element classID.name()::paramName on the go if it does not exist. 78 */ 79 LoadParamClassDescription::ParamDescriptionMap::iterator 80 LoadParamClassDescription::getParamDescription(const ClassID& classID, const std::string& paramName) 81 { 82 /// Locate the ClassDescription first 83 ClassDescriptionMap::iterator classIt = LoadParamClassDescription::_classList.find(classID); 84 if (classIt == LoadParamClassDescription::_classList.end()) 85 { 86 LoadParamClassDescription::_classList[classID] = LoadParamClassDescription(classID.name()); 87 classIt = LoadParamClassDescription::_classList.find(classID); 88 printf("Inserted %s\n", classID.name().c_str()); 89 printAll(""); 90 } 91 // At this position the class-iterator should point to a valid usefull position. 92 assert(classIt != LoadParamClassDescription::_classList.end()); 93 94 /// Now locate the description with paramName. 95 ParamDescriptionMap::iterator paramIt = (*classIt).second._parameters.find(paramName); 96 if (paramIt == (*classIt).second._parameters.end()) 97 { 98 (*classIt).second._parameters[paramName] = LoadParamDescription(paramName); 99 paramIt = (*classIt).second._parameters.find(paramName); 100 } 101 // at this position the param-iterator should 102 assert (paramIt != (*classIt).second._parameters.end()); 103 104 return (paramIt); 105 } 106 107 108 109 110 /** 111 * @brief prints out all loadable Classes, and their parameters 52 112 * @param fileName prints the output to a File 53 113 * @todo implement it … … 55 115 void LoadParamClassDescription::printAll(const std::string& fileName) 56 116 { 57 PRINT( 3)("===============================================================\n");58 PRINT( 3)(" Listing all the Loadable Options (loaded since Game started).\n\n");59 for (ClassDescription Set::const_iterator classIt = LoadParamClassDescription::_classList.begin();60 classIt != LoadParamClassDescription::_classList. begin();117 PRINT(0)("===============================================================\n"); 118 PRINT(0)(" Listing all the Loadable Options (loaded since Game started).\n\n"); 119 for (ClassDescriptionMap::const_iterator classIt = LoadParamClassDescription::_classList.begin(); 120 classIt != LoadParamClassDescription::_classList.end(); 61 121 classIt ++) 62 122 { 63 PRINT( 3)("<%s>\n", (*classIt)._className.c_str());64 for (ParamDescription Set::const_iterator param = (*classIt)._parameters.begin();65 param != (*classIt). _parameters.end();123 PRINT(0)("<%s>\n", (*classIt).second._className.c_str()); 124 for (ParamDescriptionMap::const_iterator param = (*classIt).second._parameters.begin(); 125 param != (*classIt).second._parameters.end(); 66 126 ++param) 67 127 { 68 (*param).print();128 /// (*param).second.print(); 69 129 } 70 PRINT( 3)("</%s>\n\n", (*classIt)._className.c_str());130 PRINT(0)("</%s>\n\n", (*classIt).second._className.c_str()); 71 131 } 72 PRINT( 3)("===============================================================\n");132 PRINT(0)("===============================================================\n"); 73 133 } -
branches/new_class_id/src/lib/util/loading/load_param_class_description.h
r9768 r9771 23 23 24 24 #include "load_param_description.h" 25 #include "class_id.h" 26 #include <map> 25 27 #include <set> 26 27 28 // Forward Declaration // 28 29 class MultiType; … … 32 33 { 33 34 public: 34 LoadParamClassDescription(const std::string& className );35 LoadParamClassDescription(const std::string& className = ""); 35 36 ~LoadParamClassDescription(); 36 37 … … 39 40 bool operator<(const LoadParamClassDescription& classDescr) const { return this->_className < classDescr._className; } 40 41 42 43 static void describeClass(const ClassID& classID, 44 const std::string& paramName, 45 const std::string& descriptionText); 46 static void setValuesOf(const ClassID& classID, 47 const std::string& paramName, 48 unsigned int paramCount, 49 const MultiType* const defaultValues, 50 bool retVal = false); 51 41 52 static void deleteAllDescriptions(); 42 43 44 53 45 54 static void printAll(const std::string& fileName = ""); 46 55 47 56 private: 48 typedef std::set<LoadParamClassDescription> ClassDescriptionSet; 49 typedef std::set<LoadParamDescription> ParamDescriptionSet; 57 typedef std::map<ClassID, LoadParamClassDescription> ClassDescriptionMap; 58 typedef std::map<std::string, LoadParamDescription> ParamDescriptionMap; 59 60 private: 61 static ParamDescriptionMap::iterator getParamDescription(const ClassID& classID, const std::string& paramName); 62 63 private: 50 64 51 65 static bool _parametersDescription; //!< if parameter-description should be enabled globally. 52 66 53 static ClassDescription Set_classList; //!< a list, that stores all the loadable classes. (after one instance has been loaded)67 static ClassDescriptionMap _classList; //!< a list, that stores all the loadable classes. (after one instance has been loaded) 54 68 55 69 private: 56 70 std::string _className; //!< name of the class 57 ParamDescription Set _parameters;//!< List of parameters this class knows.71 ParamDescriptionMap _parameters; //!< List of parameters this class knows. 58 72 }; 59 73 -
branches/new_class_id/src/lib/util/loading/load_param_description.h
r9767 r9771 35 35 { 36 36 public: 37 LoadParamDescription(const std::string& paramName );37 LoadParamDescription(const std::string& paramName = ""); 38 38 ~LoadParamDescription(); 39 39 … … 49 49 50 50 private: 51 const std::string_name; //!< The Name of the Parameter.51 std::string _name; //!< The Name of the Parameter. 52 52 unsigned int _parameterCount; //!< The Count of parameters. 53 53 std::string _description; //!< A longer description about this function. -
branches/new_class_id/src/lib/util/loading/load_param_xml.h
r9770 r9771 71 71 virtual ~XmlLoadParam() 72 72 { 73 this->setDescriptionValues(OperateClass::staticClassID(), executor->getParamCount(), executor->getDefaultValues(), executor->hasRetVal()); 73 74 (*this->executor)(this->object, this->loadElem); 74 75 delete this->executor;
Note: See TracChangeset
for help on using the changeset viewer.