Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5654 in orxonox.OLD for trunk


Ignore:
Timestamp:
Nov 20, 2005, 9:12:50 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: cycle-loading of LoadParam works…

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r5652 r5654  
    162162  if (root != NULL)
    163163  {
    164     const TiXmlElement* element = root->FirstChildElement();
    165     while (element != NULL)
     164    LOAD_PARAM_START_CYCLE(root, element);
    166165    {
    167       LoadParam<PNode>(element, "parent", this, &PNode::addChild, true)
     166      LoadParam_CYCLE(element, "parent", this, PNode, addChild)
    168167          .describe("adds a new Child to the current Node.");
    169168
    170       element = element->NextSiblingElement();
    171169    }
     170    LOAD_PARAM_END_CYCLE(element);
    172171  }
    173172}
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5652 r5654  
    165165  if (root != NULL)
    166166  {
    167     const TiXmlElement* element = root->FirstChildElement();
    168     while (element != NULL)
    169     {
    170       LoadParam<Element2D>(root, "parent", this, &Element2D::addChild2D, true)
     167    LOAD_PARAM_START_CYCLE(root, element);
     168    {
     169      LoadParam_CYCLE(element, "parent", this, Element2D, addChild2D)
    171170          .describe("adds a new Child to the current Node.");
    172 
    173       element = element->NextSiblingElement();
    174     }
     171    }
     172    LOAD_PARAM_END_CYCLE(element);
    175173  }
    176174}
  • trunk/src/lib/particles/particle_engine.cc

    r5447 r5654  
    9090void ParticleEngine::loadParams(const TiXmlElement* root)
    9191{
    92   const TiXmlElement* element = root->FirstChildElement();
    93   while( element != NULL)
    94   {
    95     LoadParam<ParticleEngine>(element, "connect", this, &ParticleEngine::addConnection, true)
     92  LOAD_PARAM_START_CYCLE(root, element);
     93  {
     94    LoadParam_CYCLE(element, "connect", this, ParticleEngine, addConnection)
    9695        .describe("connects an Emitter to a System (emitterName, systemName)");
    97     element = element->NextSiblingElement();
    98   }
     96  }
     97  LOAD_PARAM_END_CYCLE(element);
    9998}
    10099
  • trunk/src/lib/particles/particle_system.cc

    r5652 r5654  
    122122      .describe("the maximal count of Particles, that can be emitted into this system");
    123123
    124   //LoadParam<ParticleSystem>(root, "type", this, &ParticleSystem::setType);
    125124  LoadParamNEW(root, "life-span", this, ParticleSystem, setLifeSpan)
    126125      .describe("sets the life-span of the Particles.");
     
    132131      .describe("sets the type of the Particles, (dot, spark, sprite or model)");
    133132
    134   const TiXmlElement* element = root->FirstChildElement();
    135   while (element != NULL)
     133  LOAD_PARAM_START_CYCLE(root, element);
    136134  {
    137 
     135    element->ToText();
    138136  // PER-PARTICLE-ATTRIBUTES:
    139     LoadParam<ParticleSystem>(element, "radius", this, &ParticleSystem::setRadius, true)
     137    LoadParam_CYCLE(element, "radius", this, ParticleSystem, setRadius)
    140138        .describe("The Radius of each particle over time (TimeIndex [0-1], radius at TimeIndex, randomRadius at TimeIndex)");
    141139
    142     LoadParam<ParticleSystem>(element, "mass", this, &ParticleSystem::setMass, true)
     140    LoadParam_CYCLE(element, "mass", this, ParticleSystem, setMass)
    143141        .describe("The Mass of each particle over time (TimeIndex: [0-1], mass at TimeIndex, randomMass at TimeIndex)");
    144142
    145     LoadParam<ParticleSystem>(element, "color", this, &ParticleSystem::setColor, true)
     143    LoadParam_CYCLE(element, "color", this, ParticleSystem, setColor)
    146144        .describe("The Color of each particle over time (TimeIndex: [0-1], red: [0-1], green: [0-1], blue: [0-1], alpha: [0-1])");
    147     element = element->NextSiblingElement();
    148145  }
     146  LOAD_PARAM_END_CYCLE(element);
    149147
    150148}
  • trunk/src/util/loading/load_param.cc

    r5653 r5654  
    1313   co-programmer: ...
    1414*/
     15
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
    1517
    1618#include "functor_list.h"
     
    114116 * @param executor the Executor, that executes the loading procedure.
    115117 */
    116 LoadParamBase::LoadParamBase(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor)
    117 {
    118   this->loadString = grabParameter(root, paramName);
     118LoadParamBase::LoadParamBase(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle)
     119{
    119120  this->paramName = paramName;
    120121  this->object = object;
    121   if (root != NULL)
    122   {
    123     this->executor = executor.clone();
    124   }
     122  this->inLoadCycle = inLoadCycle;
     123
     124  // determin the LoadString.
     125  if (likely(!inLoadCycle))
     126    this->loadString = grabParameter(root, paramName);
    125127  else
    126128  {
    127     this->executor = NULL;
     129    if (!strcmp(root->Value(), paramName))
     130    {
     131      const TiXmlNode* val = root->FirstChild();
     132      if( val->ToText())
     133        this->loadString = val->Value();
     134    }
     135    else
     136      this->loadString = NULL;
    128137  }
    129138
     139  // set the Executor.
     140  this->executor = executor.clone();
    130141}
    131142
  • trunk/src/util/loading/load_param.h

    r5653 r5654  
    4646 */
    4747#define LoadParamNEW(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    48          LoadParamBase(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION))
     48         LoadParamBase(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), false)
     49
     50#define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
     51         LoadParamBase(ROOT, PARAMETER_NAME, OBJECT, ExecutorObjective<CLASS>(&CLASS::FUNCTION), true)
    4952
    5053#define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    51          LoadParamBase(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME))
     54         LoadParamBase(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
     55
     56#define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
     57         LoadParamBase(ROOT, PARAMETER_NAME, OBJECT, ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
     58
     59
     60/**
     61 * this Starts a Cycle in the Loading Process
     62 * be aware, that in the cycle the first parameter of load_param should because
     63 * called element, and that you must say true at the Fith parameter, or it will fail
     64 * also you will have to close the Cycle again with LOAD_PARAM_END_CYCLE
     65 *
     66 * @param ROOT The root XLM-element to search element under.
     67 * @param ELEMENT the element to search
     68 */
     69#define LOAD_PARAM_START_CYCLE(ROOT, ELEMENT) \
     70  const TiXmlElement* ELEMENT; \
     71  ELEMENT= ROOT->FirstChildElement(); \
     72  while( ELEMENT != NULL) \
     73{
     74/**
     75   * closes a LoadParam Loop
     76   * @see LOAD_PARAM_START_CYCLE
     77   * @param ELEMENT the Element to step through.
     78 */
     79#define LOAD_PARAM_END_CYCLE(ELEMENT) \
     80  ELEMENT = ELEMENT->NextSiblingElement(); \
     81}
     82
     83
    5284
    5385
     
    5991{
    6092  public:
    61     LoadParamBase(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& exeutor);
     93    LoadParamBase(const TiXmlElement* root, const char* paramName, BaseObject* object, const Executor& executor, bool inLoadCycle = false);
    6294    ~LoadParamBase();
    6395
     
    69101
    70102  protected:
    71     bool                     withLoadString;       //!< If we need the loadString to execute this.
     103    bool                     inLoadCycle;
    72104    Executor*                executor;
    73105    BaseObject*              object;
     
    82114};
    83115
    84 
    85 //! macro that makes it even more easy to load a Parameter
    86 /**
    87  * @param className the name of the class to load
    88  * @param parameterName the name of the parameter to load as written in the XML-file
    89  * @param function the function to call
    90  */
    91 #define LOAD_PARAM(className, parameterName, paramFunction) \
    92         LoadParam<className>(root, #parameterName, this, &className::paramFunction)
    93 
    94 /**
    95  * this Starts a Cycle in the Loading Process
    96  * be aware, that in the cycle the first parameter of load_param should because
    97  * called element, and that you must say true at the Fith parameter, or it will fail
    98  * also you will have to close the Cycle again with LOAD_PARAM_END_CYCLE
    99  *
    100  * @param ROOT The root XLM-element to search element under.
    101  * @param ELEMENT the element to search
    102  */
    103 #define LOAD_PARAM_START_CYCLE(ROOT, ELEMENT) \
    104   const TiXmlElement* ELEMENT; \
    105   ELEMENT= ROOT->FirstChildElement(); \
    106   while( ELEMENT != NULL) \
    107   {
    108 /**
    109  * closes a LoadParam Loop
    110  * @see LOAD_PARAM_START_CYCLE
    111  * @param ELEMENT the Element to step through.
    112  */
    113 #define LOAD_PARAM_END_CYCLE(ELEMENT) \
    114   ELEMENT = ELEMENT->NextSiblingElement(); \
    115   }
    116116
    117117
  • trunk/src/util/track/track_manager.cc

    r5644 r5654  
    398398  double x, y, z, d;
    399399
    400   LOAD_PARAM_START_CYCLE(root, element)
    401 
    402       LoadParam<TrackManager>(element, "WorkOn", this, &TrackManager::workOnS, true)
     400  LOAD_PARAM_START_CYCLE(root, element);
     401  {
     402
     403    LoadParam_CYCLE(element, "WorkOn", this, TrackManager, workOnS)
    403404        .describe("Selects a TrackElement (by name) to work on");
    404405
    405       LoadParam<TrackManager>(element, "Point", this, &TrackManager::addPoint, true)
     406    LoadParam_CYCLE(element, "Point", this, TrackManager, addPoint)
    406407        .describe("Adds a new Point to the currently selected TrackElement");
    407408
    408       LoadParam<TrackManager>(element, "Duration", this, &TrackManager::setDuration, true)
     409    LoadParam_CYCLE(element, "Duration", this, TrackManager, setDuration)
    409410        .describe("Sets the Duration of the currently selected TrackElement");
    410411
    411       LoadParam<TrackManager>(element, "HotPoint", this, &TrackManager::addHotPoint, true)
     412    LoadParam_CYCLE(element, "HotPoint", this, TrackManager, addHotPoint)
    412413        .describe("Sets a new Point that acts as a hot point. meaning, the curve will flow through this Point");
    413414
    414       LoadParam<TrackManager>(element, "SavePoint", this, &TrackManager::setSavePointS, true)
     415    LoadParam_CYCLE(element, "SavePoint", this, TrackManager, setSavePointS)
    415416        .describe("Sets the current selected Point to a Savepoint, meaning that the curve will be ended and a new one starts, and that one starts again from this point on");
    416417
    417       LoadParam<TrackManager>(element, "Fork", this, &TrackManager::forkS, true)
     418    LoadParam_CYCLE(element, "Fork", this, TrackManager, forkS)
    418419        .describe("Forks the Path into multiple forked Path names seperated by ','");
    419420
    420       LoadParam<TrackManager>(element, "Join", this, &TrackManager::joinS, true)
     421    LoadParam_CYCLE(element, "Join", this, TrackManager, joinS)
    421422        .describe("Joins multiple joining Path names seperated by ','");
    422423
    423424      /*
    424         if( !strcmp( element->Value(), "Fork"))
    425         {
    426         container = element->FirstChild();
    427         if( container->ToText())
     425    if( !strcmp( element->Value(), "Fork"))
     426    {
     427    container = element->FirstChild();
     428    if( container->ToText())
    428429        {
    429430        assert( container->Value() != NULL);
     
    445446        }
    446447      */
    447       LOAD_PARAM_END_CYCLE(element);
     448  }
     449  LOAD_PARAM_END_CYCLE(element);
    448450}
    449451
  • trunk/src/world_entities/terrain.cc

    r5652 r5654  
    106106  LoadParamNEW(root, "vegetation", this, Terrain, loadVegetation)
    107107      .describe("the fileName of the vegetation, that should be loaded onto this terrain. (must be relative to the data-dir)") ;
    108 
    109   //LoadParam<Terrain>(root, "DebugTerrain",  );
    110108}
    111109
  • trunk/src/world_entities/weapons/weapon_manager.cc

    r5653 r5654  
    123123
    124124  LOAD_PARAM_START_CYCLE(root, element);
    125 
    126 
    127   LoadParamXML(element, "weapons", this, WeaponManager, loadWeapons)
    128       .describe("loads Weapons");
    129 
     125  {
     126    // CHECK IF THIS WORKS....
     127    LoadParamXML_CYCLE(element, "weapons", this, WeaponManager, loadWeapons)
     128        .describe("loads Weapons");
     129  }
    130130  LOAD_PARAM_END_CYCLE(element);
    131131}
Note: See TracChangeset for help on using the changeset viewer.