Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4496 in orxonox.OLD for orxonox/trunk/src/util/loading


Ignore:
Timestamp:
Jun 3, 2005, 3:52:05 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: cycling read-in of parameters should work now… this is quite tricky, and the TrackManager has to be rewritten in some parts…. :(

Location:
orxonox/trunk/src/util/loading
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/loading/game_loader.cc

    r4487 r4496  
    252252  // free the XML data
    253253  delete XMLDoc;
    254        
     254
    255255  return c;
    256256}
  • orxonox/trunk/src/util/loading/load_param.cc

    r4492 r4496  
    2626   \param paramName: The name of the parameter loaded.
    2727   \param paramCount: how many parameters this loading-function takes
     28   \param multi: if false LoadParam assumes only one occurence of this parameter in root, if true it assumes multiple occurences.
    2829   \param ...: the parameter information
    2930*/
    30 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, ...)
    31 {
    32   this->loadString = grabParameter(root, paramName);
     31BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName,
     32                             int paramCount, bool multi, ...)
     33{
     34  this->loadString = NULL;
     35
     36  if (likely(!multi))
     37    this->loadString = grabParameter(root, paramName);
     38  else
     39    {
     40      printf("paramName:::::%s\n", root->Value());
     41      if (!strcmp(root->Value(), paramName))
     42        {
     43          const TiXmlNode* val = root->FirstChild();
     44          if( val->ToText())
     45            this->loadString = val->Value();
     46        }
     47    }
     48  if (loadString)
     49    printf("%s\n", loadString);
    3350
    3451  this->paramDesc = NULL;
     
    4360
    4461      va_list types;
    45       va_start (types, paramCount);
     62      va_start (types, multi);
    4663      for(int i = 0; i < paramCount; i++)
    4764        {
  • orxonox/trunk/src/util/loading/load_param.h

    r4495 r4496  
    7373*/
    7474#define LoadParam1(type1) \
    75  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE)) \
    76    : BaseLoadParam(root, pt2Object, paramName, 1, type1##_NAME)         \
     75 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), bool multi = false) \
     76   : BaseLoadParam(root, pt2Object, paramName, 1, multi, type1##_NAME)          \
    7777    { \
    7878      if (loadString != NULL && root != NULL) \
     
    9090*/
    9191#define LoadParam2(type1, type2) \
    92  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE)) \
    93    : BaseLoadParam(root, pt2Object, paramName, 2, type1##_NAME, type2##_NAME) \
     92 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), bool multi = false) \
     93   : BaseLoadParam(root, pt2Object, paramName, 2, multi, type1##_NAME, type2##_NAME) \
    9494    { \
    9595      if (loadString != NULL && root != NULL) \
     
    115115*/
    116116#define LoadParam3(type1, type2, type3) \
    117  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE))\
    118    : BaseLoadParam(root, pt2Object, paramName, 3, type1##_NAME, type2##_NAME, type3##_NAME) \
     117 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), bool multi = false)\
     118   : BaseLoadParam(root, pt2Object, paramName, 3, multi, type1##_NAME, type2##_NAME, type3##_NAME) \
    119119    { \
    120120      if (loadString != NULL && root != NULL) \
     
    141141*/
    142142#define LoadParam4(type1, type2, type3, type4) \
    143  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE)) \
    144    : BaseLoadParam(root, pt2Object, paramName, 4, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
     143 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE), bool multi = false) \
     144   : BaseLoadParam(root, pt2Object, paramName, 4, multi, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
    145145    { \
    146146      if (loadString != NULL && root != NULL) \
     
    168168*/
    169169#define LoadParam5(type1, type2, type3, type4, type5) \
    170  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE)) \
    171    : BaseLoadParam(root, pt2Object, paramName, 5, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
     170 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) \
     171   : BaseLoadParam(root, pt2Object, paramName, 5, multi, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
    172172    { \
    173173      if (loadString != NULL && root != NULL) \
     
    221221
    222222 private:
    223   static bool                         parametersDescription;  //!< if parameter-description should be enabled.
    224   static tList<LoadClassDescription>* classList;              //!< a list, that holds all the loadable classes. (after one instance has been loaded)
    225   char*                               className;              //!< name of the class
    226   tList<LoadParamDescription>*        paramList;              //!< List of parameters this class knows.
     223  static bool                          parametersDescription;  //!< if parameter-description should be enabled.
     224  static tList<LoadClassDescription>*  classList;              //!< a list, that holds all the loadable classes. (after one instance has been loaded)
     225  char*                                className;              //!< name of the class
     226  tList<LoadParamDescription>*         paramList;              //!< List of parameters this class knows.
    227227};
    228228
     
    234234
    235235 protected:
    236   BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, ...);
     236  BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, ...);
    237237
    238238 protected:
Note: See TracChangeset for help on using the changeset viewer.