Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/util/executor/executor_xml.h


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor_xml.h

    r8362 r9869  
    1919 * What must be defined is a XML-root to search the ParameterName under an  a Function to call.
    2020 */
    21 template<class T> class ExecutorXML : public Executor
     21template<class T, class BaseClass = BaseObject> class ExecutorXML : public Executor<const TiXmlElement*>
    2222{
    23   public:
    24     /**
     23public:
     24  /**
    2525   * @brief Constructor of a ExecutorXML
    26      * @param function a Function to call
    27      * @param root The XML root to search paramName under
    28      * @param paramName the ParameterName the search in root, and lookup the TiXmlElement from
    29      */
    30     ExecutorXML(void(T::*function)(const TiXmlElement*), const TiXmlElement* root, const char* paramName)
    31       : Executor(MT_EXT1)
    32     {
    33       PRINTF(4)("Loading %s from XML-element %p\n", paramName, root);
     26   * @param function a Function to call
     27   * @param root The XML root to search paramName under
     28   * @param paramName the ParameterName the search in root, and lookup the TiXmlElement from
     29   */
     30  ExecutorXML(void(T::*function)(const TiXmlElement*), const TiXmlElement* root, const std::string& paramName)
     31      : Executor<const TiXmlElement*>(false, MT_EXT1)
     32  {
     33    PRINTF(4)("Loading %s from XML-element %p\n", paramName.c_str(), root);
    3434
    35       if (likely(root != NULL && paramName != NULL))
    36         this->element = root->FirstChildElement(paramName);
    37       else
    38         this->element = NULL;
     35    if (likely(root != NULL))
     36      this->element = root->FirstChildElement(paramName);
     37    else
     38      this->element = NULL;
    3939
    40       this->functionPointer = function;
    41       this->functorType = Executor_Objective | Executor_NoLoadString;
    42     }
     40    this->paramName = paramName;
     41    this->functionPointer = function;
     42  }
    4343
    44     /**
    45      * @brief clones an ExecutorXML, used to copy this Element.
    46      * @returns a _new_ Copy of this Executor
    47      */
    48     virtual Executor* clone () const
    49     {
    50       ExecutorXML<T>* executor = new ExecutorXML<T>();
    51       this->cloning(executor);
    52       executor->functionPointer = this->functionPointer;
    53       executor->element = this->element;
    54       return executor;
    55     }
     44  /**
     45   * @brief clones an ExecutorXML, used to copy this Element.
     46   * @returns a _new_ Copy of this Executor
     47   */
     48  virtual Executor<const TiXmlElement*>* clone () const
     49  {
     50    return new ExecutorXML<T>(functionPointer, element, paramName);
     51  }
    5652
    57     /**
    58      * @brief executes the Command on BaseObject
    59      * @param object the BaseObject to execute this Executor on
    60      * @param loadString ignored in this case
    61      */
    62     virtual void operator()(BaseObject* object, const SubString& = SubString()) const
    63     {
    64       if (object != NULL && this->element != NULL)
    65         (dynamic_cast<T*>(object)->*(functionPointer))(this->element);
    66     }
     53  /**
     54   * @brief executes the Command on BaseObject
     55   * @param object the BaseObject to execute this Executor on
     56   * @param element ignored in this case
     57   */
     58  virtual void operator()(BaseObject* object, const TiXmlElement*& element) const
     59  {
     60    assert (object != NULL);
     61    if (this->element != NULL)
     62      (dynamic_cast<T*>(object)->*(functionPointer))(this->element);
     63  }
    6764
    68     virtual void operator()(BaseObject* object, int& count, void* values) const
    69     {
    70       PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n");
    71     }
    72 
    73   private:
    74     /**
    75    * @brief used for the copy-(Clone)-constructor
    76      */
    77     ExecutorXML() : Executor() { };
    78 
    79 
    80   private:
    81     void    (T::*functionPointer)(const TiXmlElement*);  //!< The functionPointer to the function to be called
    82     const   TiXmlElement* element;                       //!< The XML-element to call.
     65private:
     66  void    (T::*functionPointer)(const TiXmlElement*);  //!< The functionPointer to the function to be called.
     67  const   TiXmlElement* element;                       //!< The XML-element to call.
     68  std::string           paramName;                     //!< The Name of the Parameter this Executor should call.
    8369};
    8470
Note: See TracChangeset for help on using the changeset viewer.