Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 14, 2006, 5:24:31 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: new Executor construct, that is much more typesafe, faster, and easier to extend…

Also changed the LoadParam process, and adapted ScriptEngine calls

Then at the end, some missing headers appeared, and appended them to all the cc-files again.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/load_param_xml.h

    r9726 r9727  
    1515
    1616/*!
    17  * @file load_param.h
    18  * A Class and macro-functions, that makes our lives easy to load-in parameters
     17 * @file load_param_xml.h
     18 * A Class and macro-functions, that makes our lives easy to load-in parameters from XML
    1919 */
    2020
    21 #ifndef _LOAD_PARAM_H
    22 #define _LOAD_PARAM_H
     21#ifndef _LOAD_PARAM_XML_H
     22#define _LOAD_PARAM_XML_H
    2323
    24 #include "base_object.h"
    25 
    26 #include "executor/executor.h"
     24#include "load_param.h"
    2725#include "executor/executor_xml.h"
    2826
    29 // Forward Declaration //
    30 class LoadClassDescription;
    31 class LoadParamDescription;
    32 class MultiType;
    33 
    34 
    35 /**
    36  * Loads a Parameter from ROOT named PARAMETER_NAME
    37  * onto OBJECT of CLASS, trough the FUNCTION
    38  * @param ROOT the TiXmlElement to load the Parameter from
    39  * @param PARAMETER_NAME the Name of the Parameter to load
    40  * @param OBJECT The BaseObject to load the new setting to.
    41  * @param CLASS What Class the BaseObejct is of (this is for identifying the Functuon)
    42  * @param FUNCTION The function of Class to Load (if you want to call &CLASS::FUNCTION write FUNCTION here).
    43  */
    44 #define LoadParam(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    45          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), false)
    46 
    47 #define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    48          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), true)
    49 
    5027#define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    51          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
     28         XmlLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
    5229
    5330#define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    54          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
     31         XmlLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
    5532
    56 
    57 /**
    58  * this Starts a Cycle in the Loading Process
    59  * be aware, that in the cycle the first parameter of load_param should because
    60  * called element, and that you must say true at the Fith parameter, or it will fail
    61  * also you will have to close the Cycle again with LOAD_PARAM_END_CYCLE
    62  *
    63  * @param ROOT The root XLM-element to search element under.
    64  * @param ELEMENT the element to search
    65  */
    66 #define LOAD_PARAM_START_CYCLE(ROOT, ELEMENT) \
    67   const TiXmlElement* ELEMENT; \
    68   ELEMENT= ROOT->FirstChildElement(); \
    69   while( ELEMENT != NULL) \
    70 {
    71 /**
    72    * closes a LoadParam Loop
    73    * @see LOAD_PARAM_START_CYCLE
    74    * @param ELEMENT the Element to step through.
    75  */
    76 #define LOAD_PARAM_END_CYCLE(ELEMENT) \
    77   ELEMENT = ELEMENT->NextSiblingElement(); \
    78 }
    79 
    80 /**************************
    81 **** REAL DECLARATIONS ****
    82 **************************/
    83 //! abstract Base class for a Loadable parameter
    84 class CLoadParam : public BaseObject
     33class XmlLoadParam : public LoadParamBase
    8534{
    8635  public:
    87     CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor* executor, bool inLoadCycle = false);
    88     virtual ~CLoadParam();
     36    XmlLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor<const TiXmlElement*>* executor, bool inLoadCycle = false);
     37    virtual ~XmlLoadParam();
    8938
    90     CLoadParam& describe(const std::string& descriptionText);
    91     CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    92                               const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    93                               const MultiType& value4 = MT_NULL);
    94     CLoadParam& attribute(const std::string& attributeName, const Executor& executor);
    95 
     39    XmlLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(descriptionText); return *this; };
    9640
    9741  private:
    98     bool                     inLoadCycle;
    99     Executor*                executor;
    100     BaseObject*              object;
    101     const std::string        paramName;
    102 
    103     LoadClassDescription*    classDesc;            //!< The LoadClassDescription of this CLoadParameter
    104     LoadParamDescription*    paramDesc;            //!< The LoadParameterDescription of this LoadParameter
    105     const TiXmlElement*      loadElem;             //!< The Element to load.
    106     const void*              pointerToParam;       //!< A Pointer to a Parameter.
    107 
    108     MultiType*               defaultValue;
     42    Executor<const TiXmlElement*>*    executor;
    10943};
    11044
    111 // helper function
    112 
    113 std::string grabParameter(const TiXmlElement* root, const std::string& parameterName);
    114 const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName);
    115 
    116 #endif /* _LOAD_PARAM_H */
     45#endif /* _LOAD_PARAM_XML_H */
Note: See TracChangeset for help on using the changeset viewer.