Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5558 in orxonox.OLD for branches/world_entities/src/util


Ignore:
Timestamp:
Nov 13, 2005, 3:10:49 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/world_entities: merged the Trunk to the world_entities branche
merged with command
svn merge -r5516:HEAD ../trunk/ world_entities/
no conflicts

Location:
branches/world_entities/src/util
Files:
5 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/util/Makefile.am

    r5479 r5558  
    55
    66libORXutils_a_SOURCES = fast_factory.cc \
     7                        loading/factory.cc \
    78                        garbage_collector.cc \
    89                        state.cc \
     
    1213                        animation/animation_player.cc \
    1314                        loading/resource_manager.cc \
    14                         loading/factory.cc \
    1515                        loading/game_loader.cc \
    1616                        loading/load_param.cc \
     17                        loading/load_param_description.cc \
    1718                        track/pilot_node.cc \
    1819                        track/track_manager.cc \
     
    3132                        loading/game_loader.h \
    3233                        loading/load_param.h \
     34                        loading/load_param_description.h \
    3335                        track/pilot_node.h \
    3436                        track/track_manager.h \
  • branches/world_entities/src/util/Makefile.in

    r5527 r5558  
    5454libORXutils_a_AR = $(AR) $(ARFLAGS)
    5555libORXutils_a_LIBADD =
    56 am_libORXutils_a_OBJECTS = fast_factory.$(OBJEXT) \
     56am_libORXutils_a_OBJECTS = fast_factory.$(OBJEXT) factory.$(OBJEXT) \
    5757        garbage_collector.$(OBJEXT) state.$(OBJEXT) \
    5858        user_control.$(OBJEXT) animation3d.$(OBJEXT) \
    5959        animation.$(OBJEXT) animation_player.$(OBJEXT) \
    60         resource_manager.$(OBJEXT) factory.$(OBJEXT) \
    61         game_loader.$(OBJEXT) load_param.$(OBJEXT) \
     60        resource_manager.$(OBJEXT) game_loader.$(OBJEXT) \
     61        load_param.$(OBJEXT) load_param_description.$(OBJEXT) \
    6262        pilot_node.$(OBJEXT) track_manager.$(OBJEXT) \
    6363        track_node.$(OBJEXT)
     
    190190noinst_LIBRARIES = libORXutils.a
    191191libORXutils_a_SOURCES = fast_factory.cc \
     192                        loading/factory.cc \
    192193                        garbage_collector.cc \
    193194                        state.cc \
     
    197198                        animation/animation_player.cc \
    198199                        loading/resource_manager.cc \
    199                         loading/factory.cc \
    200200                        loading/game_loader.cc \
    201201                        loading/load_param.cc \
     202                        loading/load_param_description.cc \
    202203                        track/pilot_node.cc \
    203204                        track/track_manager.cc \
     
    216217                        loading/game_loader.h \
    217218                        loading/load_param.h \
     219                        loading/load_param_description.h \
    218220                        track/pilot_node.h \
    219221                        track/track_manager.h \
     
    233235          esac; \
    234236        done; \
    235         echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu  src/util/Makefile'; \
     237        echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/util/Makefile'; \
    236238        cd $(top_srcdir) && \
    237           $(AUTOMAKE) --gnu  src/util/Makefile
     239          $(AUTOMAKE) --foreign  src/util/Makefile
    238240.PRECIOUS: Makefile
    239241Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
     
    275277@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/garbage_collector.Po@am__quote@
    276278@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/load_param.Po@am__quote@
     279@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/load_param_description.Po@am__quote@
    277280@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pilot_node.Po@am__quote@
    278281@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/resource_manager.Po@am__quote@
     
    296299@am__fastdepCXX_FALSE@  $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
    297300
     301factory.o: loading/factory.cc
     302@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT factory.o -MD -MP -MF "$(DEPDIR)/factory.Tpo" -c -o factory.o `test -f 'loading/factory.cc' || echo '$(srcdir)/'`loading/factory.cc; \
     303@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/factory.Tpo" "$(DEPDIR)/factory.Po"; else rm -f "$(DEPDIR)/factory.Tpo"; exit 1; fi
     304@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='loading/factory.cc' object='factory.o' libtool=no @AMDEPBACKSLASH@
     305@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     306@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o factory.o `test -f 'loading/factory.cc' || echo '$(srcdir)/'`loading/factory.cc
     307
     308factory.obj: loading/factory.cc
     309@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT factory.obj -MD -MP -MF "$(DEPDIR)/factory.Tpo" -c -o factory.obj `if test -f 'loading/factory.cc'; then $(CYGPATH_W) 'loading/factory.cc'; else $(CYGPATH_W) '$(srcdir)/loading/factory.cc'; fi`; \
     310@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/factory.Tpo" "$(DEPDIR)/factory.Po"; else rm -f "$(DEPDIR)/factory.Tpo"; exit 1; fi
     311@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='loading/factory.cc' object='factory.obj' libtool=no @AMDEPBACKSLASH@
     312@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     313@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o factory.obj `if test -f 'loading/factory.cc'; then $(CYGPATH_W) 'loading/factory.cc'; else $(CYGPATH_W) '$(srcdir)/loading/factory.cc'; fi`
     314
    298315animation3d.o: animation/animation3d.cc
    299316@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT animation3d.o -MD -MP -MF "$(DEPDIR)/animation3d.Tpo" -c -o animation3d.o `test -f 'animation/animation3d.cc' || echo '$(srcdir)/'`animation/animation3d.cc; \
     
    352369@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o resource_manager.obj `if test -f 'loading/resource_manager.cc'; then $(CYGPATH_W) 'loading/resource_manager.cc'; else $(CYGPATH_W) '$(srcdir)/loading/resource_manager.cc'; fi`
    353370
    354 factory.o: loading/factory.cc
    355 @am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT factory.o -MD -MP -MF "$(DEPDIR)/factory.Tpo" -c -o factory.o `test -f 'loading/factory.cc' || echo '$(srcdir)/'`loading/factory.cc; \
    356 @am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/factory.Tpo" "$(DEPDIR)/factory.Po"; else rm -f "$(DEPDIR)/factory.Tpo"; exit 1; fi
    357 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='loading/factory.cc' object='factory.o' libtool=no @AMDEPBACKSLASH@
    358 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    359 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o factory.o `test -f 'loading/factory.cc' || echo '$(srcdir)/'`loading/factory.cc
    360 
    361 factory.obj: loading/factory.cc
    362 @am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT factory.obj -MD -MP -MF "$(DEPDIR)/factory.Tpo" -c -o factory.obj `if test -f 'loading/factory.cc'; then $(CYGPATH_W) 'loading/factory.cc'; else $(CYGPATH_W) '$(srcdir)/loading/factory.cc'; fi`; \
    363 @am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/factory.Tpo" "$(DEPDIR)/factory.Po"; else rm -f "$(DEPDIR)/factory.Tpo"; exit 1; fi
    364 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='loading/factory.cc' object='factory.obj' libtool=no @AMDEPBACKSLASH@
    365 @AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    366 @am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o factory.obj `if test -f 'loading/factory.cc'; then $(CYGPATH_W) 'loading/factory.cc'; else $(CYGPATH_W) '$(srcdir)/loading/factory.cc'; fi`
    367 
    368371game_loader.o: loading/game_loader.cc
    369372@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT game_loader.o -MD -MP -MF "$(DEPDIR)/game_loader.Tpo" -c -o game_loader.o `test -f 'loading/game_loader.cc' || echo '$(srcdir)/'`loading/game_loader.cc; \
     
    393396@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    394397@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o load_param.obj `if test -f 'loading/load_param.cc'; then $(CYGPATH_W) 'loading/load_param.cc'; else $(CYGPATH_W) '$(srcdir)/loading/load_param.cc'; fi`
     398
     399load_param_description.o: loading/load_param_description.cc
     400@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT load_param_description.o -MD -MP -MF "$(DEPDIR)/load_param_description.Tpo" -c -o load_param_description.o `test -f 'loading/load_param_description.cc' || echo '$(srcdir)/'`loading/load_param_description.cc; \
     401@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/load_param_description.Tpo" "$(DEPDIR)/load_param_description.Po"; else rm -f "$(DEPDIR)/load_param_description.Tpo"; exit 1; fi
     402@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='loading/load_param_description.cc' object='load_param_description.o' libtool=no @AMDEPBACKSLASH@
     403@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     404@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o load_param_description.o `test -f 'loading/load_param_description.cc' || echo '$(srcdir)/'`loading/load_param_description.cc
     405
     406load_param_description.obj: loading/load_param_description.cc
     407@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT load_param_description.obj -MD -MP -MF "$(DEPDIR)/load_param_description.Tpo" -c -o load_param_description.obj `if test -f 'loading/load_param_description.cc'; then $(CYGPATH_W) 'loading/load_param_description.cc'; else $(CYGPATH_W) '$(srcdir)/loading/load_param_description.cc'; fi`; \
     408@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/load_param_description.Tpo" "$(DEPDIR)/load_param_description.Po"; else rm -f "$(DEPDIR)/load_param_description.Tpo"; exit 1; fi
     409@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='loading/load_param_description.cc' object='load_param_description.obj' libtool=no @AMDEPBACKSLASH@
     410@AMDEP_TRUE@@am__fastdepCXX_FALSE@      DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     411@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o load_param_description.obj `if test -f 'loading/load_param_description.cc'; then $(CYGPATH_W) 'loading/load_param_description.cc'; else $(CYGPATH_W) '$(srcdir)/loading/load_param_description.cc'; fi`
    395412
    396413pilot_node.o: track/pilot_node.cc
  • branches/world_entities/src/util/loading/game_loader.cc

    r5300 r5558  
    8989  this->eventHandler = EventHandler::getInstance();
    9090  this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_PAUSE);
     91  this->eventHandler->subscribe(this, ES_ALL, EV_MAIN_QUIT);          //< External Quit Event
    9192  this->eventHandler->subscribe(this, ES_ALL, KeyMapper::PEV_QUIT);
    9293  this->eventHandler->subscribe(this, ES_GAME, KeyMapper::PEV_NEXT_WORLD);
     
    274275 *  handle keyboard commands
    275276 * @param event the event to handle
    276 */
     277 */
    277278void GameLoader::process(const Event& event)
    278279{
    279280  if( event.type == KeyMapper::PEV_NEXT_WORLD)
    280     {
    281       if( likely(event.bPressed))
    282         {
    283           this->nextLevel();
    284         }
    285     }
     281  {
     282    if( likely(event.bPressed))
     283    {
     284      this->nextLevel();
     285    }
     286  }
    286287  else if( event.type == KeyMapper::PEV_PREVIOUS_WORLD)
    287     {
    288       if( likely(event.bPressed))
    289         {
    290           this->previousLevel();
    291         }
    292     }
     288  {
     289    if( likely(event.bPressed))
     290    {
     291      this->previousLevel();
     292    }
     293  }
    293294  else if( event.type == KeyMapper::PEV_PAUSE)
    294     {
    295       if( likely(event.bPressed))
    296         {
    297           if(this->isPaused)
    298             this->resume();
    299           else
    300             this->pause();
    301         }
    302     }
     295  {
     296    if( likely(event.bPressed))
     297    {
     298      if(this->isPaused)
     299        this->resume();
     300      else
     301        this->pause();
     302    }
     303  }
    303304  else if( event.type == KeyMapper::PEV_QUIT)
    304     {
    305       if( event.bPressed) this->stop();
    306     }
     305  {
     306    if( event.bPressed) this->stop();
     307  }
     308  else if (event.type == EV_MAIN_QUIT)
     309    this->stop();
    307310}
    308311
  • branches/world_entities/src/util/loading/load_param.cc

    r5334 r5558  
    1717
    1818#include "load_param.h"
     19#include "load_param_description.h"
    1920
    2021#include "list.h"
    21 #include "base_object.h"
    2222
    2323#include <stdarg.h>
     
    3131 * @param ...: the parameter information (1. Parameter, 2. Default Value for the Parameter, ...)
    3232*/
    33 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName,
     33LoadParamBase::LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName,
    3434                             int paramCount, bool multi, const void* pointerToParam, ...)
    3535{
     
    3939  this->pointerToParam = pointerToParam;
    4040
    41   if (paramCount == 0 || this->pointerToParam)
     41  if (paramCount == 0 || this->pointerToParam != NULL)
    4242    this->loadString = "none";
    4343  else
     
    110110 * @returns a pointer to itself.
    111111*/
    112 BaseLoadParam* BaseLoadParam::describe(const char* descriptionText)
     112LoadParamBase* LoadParamBase::describe(const char* descriptionText)
    113113{
    114114  if (LoadClassDescription::parametersDescription && this->paramDesc && !this->paramDesc->getDescription())
     
    117117    }
    118118  return this;
    119 }
    120 
    121 /**
    122  * @param paramName the name of the parameter to load
    123 */
    124 LoadParamDescription::LoadParamDescription(const char* paramName)
    125 {
    126   this->types = NULL;
    127   this->description = NULL;
    128   this->defaultValues = NULL;
    129   this->paramName = new char[strlen(paramName)+1];
    130   strcpy(this->paramName, paramName);
    131 }
    132 
    133 /**
    134  *  removes all the alocated memory
    135 */
    136 LoadParamDescription::~LoadParamDescription()
    137 {
    138   if (this->defaultValues != NULL)
    139   {
    140     for(int i = 0; i < this->paramCount; i++)
    141     {
    142       delete[] this->defaultValues[i];
    143     }
    144   }
    145 
    146   delete[] this->types;
    147   delete[] this->defaultValues;
    148   delete[] this->paramName;
    149   delete[] this->description;
    150 }
    151 
    152 /**
    153  * @param descriptionText The text to set as a description for this Parameter
    154 */
    155 void LoadParamDescription::setDescription(const char* descriptionText)
    156 {
    157   this->description = new char[strlen(descriptionText)+1];
    158   strcpy(this->description, descriptionText);
    159 }
    160 
    161 /**
    162  *  prints out this parameter, its input method and the description (if availiable)
    163 */
    164 void LoadParamDescription::print() const
    165 {
    166   PRINT(3)(" <%s>", this->paramName);
    167   for (int i = 0; i < this->paramCount; i++)
    168     {
    169       if (i > 0)
    170         PRINT(3)(",");
    171       switch (this->types[i])
    172       {
    173         default:
    174           PRINTF(3)("none");
    175           break;
    176         case ParameterBool:
    177           PRINT(3)("bool");
    178           break;
    179         case ParameterChar:
    180           PRINT(3)("char");
    181           break;
    182         case ParameterString:
    183           PRINT(3)("string");
    184           break;
    185         case ParameterInt:
    186           PRINT(3)("int");
    187           break;
    188         case ParameterUInt:
    189           PRINT(3)("Uint");
    190           break;
    191         case ParameterFloat:
    192           PRINT(3)("float");
    193           break;
    194         case ParameterLong:
    195           PRINT(3)("long");
    196           break;
    197         case ParameterXML:
    198           PRINT(3)("XML");
    199           break;
    200       }
    201     }
    202   PRINT(3)("</%s>", this->paramName);
    203   if (this->description)
    204     PRINT(3)(" -- %s", this->description);
    205   // default values
    206   if (this->paramCount > 0)
    207   {
    208     PRINT(3)(" (Default: ");
    209     for (int i = 0; i < this->paramCount; i++)
    210     {
    211       if (i > 0)
    212         PRINT(3)(", ");
    213       if (this->types[i] & ParameterString)
    214       { // leave brackets !!
    215         PRINT(3)("\"%s\"", this->defaultValues[i]);
    216       }
    217       else
    218       {
    219         PRINT(3)("%s", this->defaultValues[i]);
    220       }
    221     }
    222     PRINT(3)(")");
    223   }
    224   PRINT(3)("\n");
    225 }
    226 
    227 /**
    228  *  A list, that holds all the classes that are loadable (classes not objects!!)
    229 */
    230 tList<LoadClassDescription>* LoadClassDescription::classList = NULL;
    231 
    232 /**
    233  *  if the description of Parameters should be executed
    234 */
    235 bool LoadClassDescription::parametersDescription = true;
    236 
    237 /**
    238  * @param className the name of the class to be loadable
    239 */
    240 LoadClassDescription::LoadClassDescription(const char* className)
    241 {
    242   this->className = new char[strlen(className)+1];
    243   strcpy(this->className, className);
    244 
    245   if (LoadClassDescription::classList == NULL)
    246     LoadClassDescription::classList = new tList<LoadClassDescription>;
    247 
    248   LoadClassDescription::classList->add(this);
    249 
    250   this->paramList = new tList<LoadParamDescription>;
    251 }
    252 
    253 /**
    254  *  deletes a classDescription (deletes all the parameterDescriptions as well
    255 */
    256 LoadClassDescription::~LoadClassDescription()
    257 {
    258   tIterator<LoadParamDescription>* iterator = this->paramList->getIterator();
    259   LoadParamDescription* enumParamDesc = iterator->firstElement();
    260   while (enumParamDesc)
    261     {
    262       delete enumParamDesc;
    263       enumParamDesc = iterator->nextElement();
    264     }
    265   delete iterator;
    266   delete this->paramList;
    267 
    268   delete[] this->className;
    269 }
    270 
    271 void LoadClassDescription::deleteAllDescriptions()
    272 {
    273   if (LoadClassDescription::classList != NULL)
    274   {
    275     tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
    276     LoadClassDescription* delElem = iterator->firstElement();
    277     while (delElem != NULL)
    278     {
    279       delete delElem;
    280       delElem = iterator->nextElement();
    281     }
    282     delete iterator;
    283     delete LoadClassDescription::classList;
    284   }
    285   LoadClassDescription::classList = NULL;
    286 }
    287 
    288 
    289 /**
    290  *  adds a class to the list of loadable classes
    291  * @param className The name of the class to add
    292 
    293    this function searches for the className string, and if found just returns the appropriate Class.
    294    Otherwise it returns a new classDescription
    295 */
    296 LoadClassDescription* LoadClassDescription::addClass(const char* className)
    297 {
    298   if (LoadClassDescription::classList != NULL)
    299   {
    300     tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
    301    LoadClassDescription* enumClassDesc = iterator->firstElement();
    302    while (enumClassDesc)
    303      {
    304        if (!strcmp(enumClassDesc->className, className))
    305          {
    306            delete iterator;
    307            return enumClassDesc;
    308          }
    309        enumClassDesc = iterator->nextElement();
    310      }
    311    delete iterator;
    312   }
    313   return new LoadClassDescription(className);
    314 }
    315 
    316 /**
    317  *  does the same as addClass(const char* className), but with params
    318  * @param paramName the name of the parameter to add.
    319 */
    320 LoadParamDescription* LoadClassDescription::addParam(const char* paramName)
    321 {
    322   tIterator<LoadParamDescription>* iterator = this->paramList->getIterator();
    323   LoadParamDescription* enumParamDesc = iterator->firstElement();
    324   while (enumParamDesc)
    325     {
    326       if (!strcmp(enumParamDesc->paramName, paramName))
    327         {
    328           delete iterator;
    329           //return enumParamDesc;
    330           return NULL;
    331         }
    332       enumParamDesc = iterator->nextElement();
    333     }
    334   delete iterator;
    335 
    336   LoadParamDescription* newParam = new LoadParamDescription(paramName);
    337 
    338   this->paramList->add(newParam);
    339   return newParam;
    340 }
    341 
    342 /**
    343  *  prints out all loadable Classes, and their parameters
    344  * @param fileName prints the output to a File
    345  * @todo implement it
    346 */
    347 void LoadClassDescription::printAll(const char* fileName)
    348 {
    349   PRINT(3)("===============================================================\n");
    350   PRINT(3)(" Listing all the Loadable Options (loaded since Game started).\n\n");
    351   if (LoadClassDescription::classList != NULL)
    352   {
    353     tIterator<LoadClassDescription>* classIT = LoadClassDescription::classList->getIterator();
    354     LoadClassDescription* enumClassDesc = classIT->firstElement();
    355     while (enumClassDesc)
    356      {
    357        PRINT(3)("<%s>\n", enumClassDesc->className);
    358        tIterator<LoadParamDescription>* paramIT = enumClassDesc->paramList->getIterator();
    359        LoadParamDescription* enumParamDesc = paramIT->firstElement();
    360        while (enumParamDesc)
    361          {
    362            enumParamDesc->print();
    363            enumParamDesc = paramIT->nextElement();
    364          }
    365        delete paramIT;
    366 
    367        PRINT(3)("</%s>\n\n", enumClassDesc->className);
    368        enumClassDesc = classIT->nextElement();
    369      }
    370     delete classIT;
    371   }
    372   else
    373     PRINT(3)("no Classes defined so far\n");
    374   PRINT(3)("===============================================================\n");
    375 }
    376 
    377 /**
    378  * searches for classes, which beginn with classNameBegin
    379  * @param classNameBegin the beginning string of a Class
    380  * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
    381  * !! The strings MUST NOT be deleted !!
    382  */
    383 tList<const char>* LoadClassDescription::searchClassWithShort(const char* classNameBegin)
    384 {
    385   unsigned int searchLength = strlen(classNameBegin);
    386   tList<const char>* retVal = new tList<const char>;
    387 
    388   tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
    389   LoadClassDescription* enumClassDesc = iterator->firstElement();
    390   while (enumClassDesc)
    391   {
    392     if (strlen(enumClassDesc->className)>searchLength+1 &&
    393         !strncasecmp(enumClassDesc->className, classNameBegin, searchLength))
    394     {
    395       retVal->add(enumClassDesc->className);
    396     }
    397     enumClassDesc = iterator->nextElement();
    398   }
    399   delete iterator;
    400 
    401   return retVal;
    402119}
    403120
  • branches/world_entities/src/util/loading/load_param.h

    r5499 r5558  
    2323
    2424#include "functor_list.h"
    25 #include "base_object.h"
     25
     26#include "debug.h"
    2627
    2728#include "factory.h"
    28 #include "debug.h"
    2929#include "substring.h"
    3030#include "tinyxml.h"
     31
    3132#include "helper_functions.h"
    3233
    3334// Forward Declaration //
    3435template<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 
     36class LoadClassDescription;
     37class LoadParamDescription;
     38class MultiType;
    8539
    8640/**************************
     
    8842**************************/
    8943//! abstract Base class for a Loadable parameter
    90 class BaseLoadParam : public BaseObject
     44class LoadParamBase : public BaseObject
    9145{
    9246 public:
    93   BaseLoadParam* describe(const char* descriptionText);
     47  LoadParamBase* describe(const char* descriptionText);
     48  LoadParamBase* defaultValues(unsigned int count, ...);
    9449
    9550 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, ...);
    9752
    9853 protected:
     
    10156  const char*              loadString;           //!< The string loaded by this LoadParam
    10257  const void*              pointerToParam;       //!< A Pointer to a Parameter.
     58
     59  MultiType*               defaultValue;
    10360};
    10461
     
    14097#define LoadParam0() \
    14198LoadParam(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) \
    143100{ \
    144101  if (loadString != NULL && root != NULL) \
     
    156113 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), \
    157114           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) \
    159116{ \
    160117      if (loadString != NULL && root != NULL) \
     
    175132 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), \
    176133           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) \
    178135{ \
    179136      if (loadString != NULL && root != NULL) \
     
    201158 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), \
    202159           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) \
    204161{ \
    205162      if (loadString != NULL && root != NULL) \
     
    229186           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \
    230187           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, \
    232189                  type4##_PARAM, default4) \
    233190{ \
     
    260217           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \
    261218           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, \
    263220                  type4##_PARAM, default4, type5##_PARAM, default5) \
    264221{ \
     
    283240#define LoadParamPT(type1) \
    284241 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) \
    286243{ \
    287244      if (pointerToParam != NULL && root != NULL) \
     
    292249
    293250//! derived template class, so all the Classes can load something.
    294 template<class T> class LoadParam : public BaseLoadParam
     251template<class T> class LoadParam : public LoadParamBase
    295252{
    296253  public:
     
    305262  // loads a Ti-XML-element
    306263  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")
    308265  {
    309266    if (root != NULL)
Note: See TracChangeset for help on using the changeset viewer.