Changeset 4598 in orxonox.OLD for orxonox/trunk/src/util
- Timestamp:
- Jun 11, 2005, 3:08:36 AM (20 years ago)
- Location:
- orxonox/trunk/src/util/loading
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/util/loading/game_loader.cc
r4597 r4598 337 337 \param element a XMLElement containing all the needed info 338 338 */ 339 BaseObject* GameLoader::fabricate( TiXmlElement* element)339 BaseObject* GameLoader::fabricate(const TiXmlElement* element) 340 340 { 341 341 assert( element != NULL); -
orxonox/trunk/src/util/loading/game_loader.h
r4511 r4598 1 /*! 1 /*! 2 2 \file game_loader.h 3 3 \brief loads campaigns, worlds and all other story_entities 4 */ 4 */ 5 5 6 6 #ifndef _GAME_LOADER_H … … 60 60 bool worldCommand(Command* cmd); 61 61 ErrorMessage loadDebugCampaign(Uint32 campaignID); 62 62 63 63 void registerFactory( Factory* factory ); 64 BaseObject* fabricate( TiXmlElement* data);64 BaseObject* fabricate(const TiXmlElement* data); 65 65 66 66 void process(const Event &event); … … 78 78 79 79 Campaign* currentCampaign; //!< reference to the current campaign playing 80 80 81 81 EventHandler* eventHandler; //!< reference to the eventHandler 82 82 -
orxonox/trunk/src/util/loading/load_param.cc
r4597 r4598 30 30 */ 31 31 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, 32 int paramCount, bool multi, ...)32 int paramCount, bool multi, const void* pointerToParam, ...) 33 33 { 34 34 this->setClassID(CL_LOAD_PARAM, "LoadParam"); 35 35 this->loadString = NULL; 36 37 if (paramCount == 0) 36 this->pointerToParam = pointerToParam; 37 38 if (paramCount == 0 || this->pointerToParam) 38 39 this->loadString = "none"; 39 40 else … … 63 64 64 65 va_list types; 65 va_start (types, multi);66 va_start (types, pointerToParam); 66 67 for(int i = 0; i < paramCount; i++) 67 68 { -
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.