Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/util/executor/executor_xml.h @ 8362

Last change on this file since 8362 was 8362, checked in by bensch, 18 years ago

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

File size: 2.6 KB
RevLine 
[4838]1/*!
[8271]2 * @file executor_xml.h
[5068]3 * Definition of a on-screen-shell
[5391]4 */
[1853]5
[8271]6#ifndef _EXECUTOR_XML_H
7#define _EXECUTOR_XML_H
[1853]8
[5651]9#include "executor.h"
[7711]10#include "compiler.h"
[8362]11#include "debug.h"
[1853]12
[5944]13#include "parser/tinyxml/tinyxml.h"
[3543]14
[5651]15//! Executes a Function with a const TiXmlElement* parameter.
16/**
17 * This is a Special Executor, that finds ParamName in root as XML-sub-element
18 * This is especially usefull, if you have to Load a SubElement from root in a new Function
19 * What must be defined is a XML-root to search the ParameterName under an  a Function to call.
20 */
21template<class T> class ExecutorXML : public Executor
[5170]22{
23  public:
[5651]24    /**
[7331]25   * @brief Constructor of a ExecutorXML
[5651]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)
[7197]31      : Executor(MT_EXT1)
[5651]32    {
33      PRINTF(4)("Loading %s from XML-element %p\n", paramName, root);
[5641]34
[5651]35      if (likely(root != NULL && paramName != NULL))
36        this->element = root->FirstChildElement(paramName);
37      else
38        this->element = NULL;
[5641]39
[5651]40      this->functionPointer = function;
[5652]41      this->functorType = Executor_Objective | Executor_NoLoadString;
[5651]42    }
[5164]43
[5651]44    /**
[7331]45     * @brief clones an ExecutorXML, used to copy this Element.
[5651]46     * @returns a _new_ Copy of this Executor
47     */
[5641]48    virtual Executor* clone () const
49    {
[5651]50      ExecutorXML<T>* executor = new ExecutorXML<T>();
[5641]51      this->cloning(executor);
[5651]52      executor->functionPointer = this->functionPointer;
53      executor->element = this->element;
[5641]54      return executor;
55    }
[5633]56
[5651]57    /**
[7331]58     * @brief executes the Command on BaseObject
[5651]59     * @param object the BaseObject to execute this Executor on
60     * @param loadString ignored in this case
61     */
[7474]62    virtual void operator()(BaseObject* object, const SubString& = SubString()) const
[5135]63    {
[5651]64      if (object != NULL && this->element != NULL)
65        (dynamic_cast<T*>(object)->*(functionPointer))(this->element);
[5145]66    }
[5113]67
[8271]68    virtual void operator()(BaseObject* object, int& count, void* values) const
[8035]69    {
[8048]70      PRINTF(1)("missuse of XML-operator, OR IMPLEMENT.\n");
[8035]71    }
72
[5651]73  private:
74    /**
[7331]75   * @brief used for the copy-(Clone)-constructor
[5651]76     */
77    ExecutorXML() : Executor() { };
[5632]78
[5326]79
80  private:
[5651]81    void    (T::*functionPointer)(const TiXmlElement*);  //!< The functionPointer to the function to be called
82    const   TiXmlElement* element;                       //!< The XML-element to call.
[5326]83};
84
[8271]85#endif /* _EXECUTOR_XML_H */
Note: See TracBrowser for help on using the repository browser.