Changeset 5558 in orxonox.OLD for branches/world_entities/src/util/loading/load_param.h
- Timestamp:
- Nov 13, 2005, 3:10:49 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/world_entities/src/util/loading/load_param.h
r5499 r5558 23 23 24 24 #include "functor_list.h" 25 #include "base_object.h" 25 26 #include "debug.h" 26 27 27 28 #include "factory.h" 28 #include "debug.h"29 29 #include "substring.h" 30 30 #include "tinyxml.h" 31 31 32 #include "helper_functions.h" 32 33 33 34 // Forward Declaration // 34 35 template<class T> class tList; 35 36 /************************ 37 *** DESCRIPTION STUFF *** 38 ************************/ 39 //! A class that handles the description of loadable parameters 40 class LoadParamDescription 41 { 42 friend class BaseLoadParam; 43 friend class LoadClassDescription; 44 public: 45 LoadParamDescription(const char* paramName); 46 ~LoadParamDescription(); 47 48 void setDescription(const char* descriptionText); 49 /** @returns the descriptionString */ 50 const char* getDescription() { return this->description; }; 51 52 void print() const; 53 private: 54 char* paramName; //!< The name of the parameter. 55 int paramCount; //!< The count of parameters. 56 int* types; //!< What kind of parameters does this function take ?? 57 char* description; //!< A longer description about this function. 58 char** defaultValues; //!< The 'Default Values'. 59 }; 60 61 //! A class for descriptions of a loadable module 62 class LoadClassDescription 63 { 64 friend class BaseLoadParam; 65 public: 66 LoadClassDescription(const char* className); 67 ~LoadClassDescription(); 68 69 static LoadClassDescription* addClass(const char* className); 70 LoadParamDescription* addParam(const char* paramName); 71 72 static void deleteAllDescriptions(); 73 74 static void printAll(const char* fileName = NULL); 75 static tList<const char>* searchClassWithShort(const char* classNameBegin); 76 // static const LoadParamDescription* getClass(const char* className); 77 78 private: 79 static bool parametersDescription; //!< if parameter-description should be enabled. 80 static tList<LoadClassDescription>* classList; //!< a list, that holds all the loadable classes. (after one instance has been loaded) 81 char* className; //!< name of the class 82 tList<LoadParamDescription>* paramList; //!< List of parameters this class knows. 83 }; 84 36 class LoadClassDescription; 37 class LoadParamDescription; 38 class MultiType; 85 39 86 40 /************************** … … 88 42 **************************/ 89 43 //! abstract Base class for a Loadable parameter 90 class BaseLoadParam: public BaseObject44 class LoadParamBase : public BaseObject 91 45 { 92 46 public: 93 BaseLoadParam* describe(const char* descriptionText); 47 LoadParamBase* describe(const char* descriptionText); 48 LoadParamBase* defaultValues(unsigned int count, ...); 94 49 95 50 protected: 96 BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);51 LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...); 97 52 98 53 protected: … … 101 56 const char* loadString; //!< The string loaded by this LoadParam 102 57 const void* pointerToParam; //!< A Pointer to a Parameter. 58 59 MultiType* defaultValue; 103 60 }; 104 61 … … 140 97 #define LoadParam0() \ 141 98 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false) \ 142 : BaseLoadParam(root, pt2Object, paramName, 0, multi, NULL, "") \99 : LoadParamBase(root, pt2Object, paramName, 0, multi, NULL) \ 143 100 { \ 144 101 if (loadString != NULL && root != NULL) \ … … 156 113 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), \ 157 114 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT) \ 158 : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \115 : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \ 159 116 { \ 160 117 if (loadString != NULL && root != NULL) \ … … 175 132 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), \ 176 133 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT) \ 177 : BaseLoadParam(root, pt2Object, paramName, 2, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2) \134 : LoadParamBase(root, pt2Object, paramName, 2, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2) \ 178 135 { \ 179 136 if (loadString != NULL && root != NULL) \ … … 201 158 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), \ 202 159 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT)\ 203 : BaseLoadParam(root, pt2Object, paramName, 3, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3) \160 : LoadParamBase(root, pt2Object, paramName, 3, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3) \ 204 161 { \ 205 162 if (loadString != NULL && root != NULL) \ … … 229 186 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \ 230 187 type4##_TYPE default4 = type4##_DEFAULT) \ 231 : BaseLoadParam(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \188 : LoadParamBase(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \ 232 189 type4##_PARAM, default4) \ 233 190 { \ … … 260 217 bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \ 261 218 type4##_TYPE default4 = type4##_DEFAULT, type5##_TYPE default5 = type5##_DEFAULT ) \ 262 : BaseLoadParam(root, pt2Object, paramName, 5, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \219 : LoadParamBase(root, pt2Object, paramName, 5, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \ 263 220 type4##_PARAM, default4, type5##_PARAM, default5) \ 264 221 { \ … … 283 240 #define LoadParamPT(type1) \ 284 241 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), type1##_TYPE pointerToParam, bool multi = false) \ 285 : BaseLoadParam(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_PARAM) \242 : LoadParamBase(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_PARAM) \ 286 243 { \ 287 244 if (pointerToParam != NULL && root != NULL) \ … … 292 249 293 250 //! derived template class, so all the Classes can load something. 294 template<class T> class LoadParam : public BaseLoadParam251 template<class T> class LoadParam : public LoadParamBase 295 252 { 296 253 public: … … 305 262 // loads a Ti-XML-element 306 263 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(const TiXmlElement*), bool multi = false) 307 : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, "XML")264 : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, "XML") 308 265 { 309 266 if (root != NULL)
Note: See TracChangeset
for help on using the changeset viewer.