Changeset 4598 in orxonox.OLD for orxonox/trunk/src/util/loading/load_param.h
- Timestamp:
- Jun 11, 2005, 3:08:36 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/load_param.h
r4597 r4598 26 26 #include "debug.h" 27 27 #include "substring.h" 28 #include "tinyxml.h" 28 29 29 30 // Forward Declaration // … … 41 42 /** 42 43 useable FunctionParameters are: 43 l_INT: int 44 l_LONG: long 45 l_SHORT: short 46 l_FLOAT: float 47 l_STRING: const char* 48 */ 49 50 #define l_INT_TYPE int //!< The type of an INT 51 #define l_INT_FUNC atoi //!< the function to call to parse INT 52 #define l_INT_NAME "int" //!< the name of an INT 53 54 #define l_LONG_TYPE long //!< The type of a LONG 55 #define l_LONG_FUNC atol //!< The function to parse a LONG 56 #define l_LONG_NAME "long" //!< The name of a LONG 57 58 #define l_SHORT_TYPE short //!< The type of a SHORT 59 #define l_SHORT_FUNC atoi //!< The function to parse a SHORT 60 #define l_SHORT_NAME "short" //!< The name of a SHORT 61 62 #define l_FLOAT_TYPE float //!< The type of a FLOAT 63 #define l_FLOAT_FUNC atof //!< The function to parse a FLOAT 64 #define l_FLOAT_NAME "float" //!< The name of a FLOAT 65 66 #define l_STRING_TYPE const char* //!< The type fo a STRING 67 #define l_STRING_FUNC //!< The function to parse a STRING 68 #define l_STRING_NAME "string" //!< The name of a STRING 44 l_INT: int 45 l_LONG: long 46 l_SHORT: short 47 l_FLOAT: float 48 l_STRING: const char* 49 l_XML_ELEM: TiXmlElement* 50 */ 51 52 #define l_INT_TYPE int //!< The type of an INT 53 #define l_INT_FUNC atoi //!< the function to call to parse INT 54 #define l_INT_NAME "int" //!< the name of an INT 55 56 #define l_LONG_TYPE long //!< The type of a LONG 57 #define l_LONG_FUNC atol //!< The function to parse a LONG 58 #define l_LONG_NAME "long" //!< The name of a LONG 59 60 #define l_SHORT_TYPE short //!< The type of a SHORT 61 #define l_SHORT_FUNC atoi //!< The function to parse a SHORT 62 #define l_SHORT_NAME "short" //!< The name of a SHORT 63 64 #define l_FLOAT_TYPE float //!< The type of a FLOAT 65 #define l_FLOAT_FUNC atof //!< The function to parse a FLOAT 66 #define l_FLOAT_NAME "float" //!< The name of a FLOAT 67 68 #define l_STRING_TYPE const char* //!< The type of a STRING 69 #define l_STRING_FUNC //!< The function to parse a STRING 70 #define l_STRING_NAME "string" //!< The name of a STRING 71 72 #define l_XML_ELEM_TYPE const TiXmlElement* //!< The type of an XML_ELEM 73 #define l_XML_ELEM_FUNC //!< The function to parse an XML_ELEM 74 #define l_XML_ELEM_NAME "XML" //!< The name of an XML_ELEM 69 75 70 76 // 1. TYPE … … 75 81 #define LoadParam1(type1) \ 76 82 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), bool multi = false) \ 77 : BaseLoadParam(root, pt2Object, paramName, 1, multi, type1##_NAME)\83 : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, type1##_NAME) \ 78 84 { \ 79 85 if (loadString != NULL && root != NULL) \ … … 92 98 #define LoadParam2(type1, type2) \ 93 99 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), bool multi = false) \ 94 : BaseLoadParam(root, pt2Object, paramName, 2, multi, type1##_NAME, type2##_NAME) \100 : BaseLoadParam(root, pt2Object, paramName, 2, multi, NULL, type1##_NAME, type2##_NAME) \ 95 101 { \ 96 102 if (loadString != NULL && root != NULL) \ … … 117 123 #define LoadParam3(type1, type2, type3) \ 118 124 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), bool multi = false)\ 119 : BaseLoadParam(root, pt2Object, paramName, 3, multi, type1##_NAME, type2##_NAME, type3##_NAME) \125 : BaseLoadParam(root, pt2Object, paramName, 3, multi, NULL, type1##_NAME, type2##_NAME, type3##_NAME) \ 120 126 { \ 121 127 if (loadString != NULL && root != NULL) \ … … 143 149 #define LoadParam4(type1, type2, type3, type4) \ 144 150 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE), bool multi = false) \ 145 : BaseLoadParam(root, pt2Object, paramName, 4, multi, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \151 : BaseLoadParam(root, pt2Object, paramName, 4, multi, NULL, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \ 146 152 { \ 147 153 if (loadString != NULL && root != NULL) \ … … 170 176 #define LoadParam5(type1, type2, type3, type4, type5) \ 171 177 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE), bool multi = false) \ 172 : BaseLoadParam(root, pt2Object, paramName, 5, multi, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \178 : BaseLoadParam(root, pt2Object, paramName, 5, multi, NULL, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \ 173 179 { \ 174 180 if (loadString != NULL && root != NULL) \ … … 185 191 } 186 192 193 // Pointer TYPE 194 /** 195 \brief a Macro to easily implement many different Constructors for the LoadParam-Class with 1 argument 196 \param type1 The type of the Pointer 197 */ 198 #define LoadParamPT(type1) \ 199 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), type1##_TYPE pointerToParam, bool multi = false) \ 200 : BaseLoadParam(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_NAME) \ 201 { \ 202 if (pointerToParam != NULL && root != NULL) \ 203 (*pt2Object.*function)((type1##_TYPE) pointerToParam); \ 204 else \ 205 PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \ 206 } 187 207 188 208 //! A class that handles the description of loadable parameters … … 235 255 236 256 protected: 237 BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, ...);257 BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...); 238 258 239 259 protected: … … 241 261 LoadParamDescription* paramDesc; //!< The LoadParameterDescription of this LoadParameter 242 262 const char* loadString; //!< The string loaded by this LoadParam 263 const void* pointerToParam; //!< A Pointer to a Parameter. 243 264 }; 244 265 … … 249 270 public: 250 271 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false) 251 : BaseLoadParam(root, pt2Object, paramName, 0, multi, "")272 : BaseLoadParam(root, pt2Object, paramName, 0, multi, NULL, "") 252 273 { 253 274 if (loadString != NULL && root != NULL) … … 284 305 //! makes functions with four floats loadable 285 306 LoadParam4(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT); 307 308 LoadParamPT(l_XML_ELEM); 286 309 }; 287 310
Note: See TracChangeset
for help on using the changeset viewer.