Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5654 in orxonox.OLD for trunk/src/util/loading/load_param.h


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

orxonox/trunk: cycle-loading of LoadParam works…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.