Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9769 in orxonox.OLD for branches/new_class_id/src


Ignore:
Timestamp:
Sep 19, 2006, 9:35:11 PM (18 years ago)
Author:
bensch
Message:

orxonox/branches/new_class_id: even more templates (mostly to safe space)

Location:
branches/new_class_id/src/lib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/shell/shell_command.h

    r9742 r9769  
    4040   */
    4141#define SHELL_COMMAND(command, class, function) \
    42            OrxShell::ShellCommand* shell_command_##class##_##command = OrxShell::ShellCommand::registerCommand(#command, #class, createExecutor<class>(&class::function))
     42           OrxShell::ShellCommand* shell_command_##class##_##command = OrxShell::ShellCommand::registerCommand(#command, #class, createExecutor<class, BaseObject>(&class::function))
    4343
    4444  /**
     
    5656   */
    5757#define SHELL_COMMAND_STATIC(command, class, function) \
    58            OrxShell::ShellCommand* shell_command_##class##_##command = OrxShell::ShellCommand::registerCommand(#command, #class, createExecutor<class>(function))
     58           OrxShell::ShellCommand* shell_command_##class##_##command = OrxShell::ShellCommand::registerCommand(#command, #class, createExecutor<class, BaseObject>(function))
    5959
    6060
  • branches/new_class_id/src/lib/util/executor/executor.h

    r9752 r9769  
    112112
    113113  /** @returns the Clone as a new Copy of the Executor. */
    114   virtual Executor<CallType>* clone () const = 0;
     114  virtual Executor<CallType, BaseClass>* clone () const = 0;
    115115
    116116
  • branches/new_class_id/src/lib/util/executor/executor_generic.h

    r9748 r9769  
    6868///////////
    6969//! @brief ExecutorClass, that can execute Functions without any parameters.
    70 template<class T, typename CallType, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     70template<class T, typename CallType, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    7171class __EXECUTOR_FUNCTIONAL_NAME(0,) :public Executor<CallType, BaseClass>
    7272{
     
    8989   * @param eval the CallType to get the Parameters from.
    9090   */
    91   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     91  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    9292  {
    9393    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     
    100100  virtual Executor<CallType, BaseClass>* clone() const
    101101  {
    102     return new __EXECUTOR_FUNCTIONAL_NAME(0,)<T, CallType>(this->functionPointer);
     102    return new __EXECUTOR_FUNCTIONAL_NAME(0,)<T, CallType, BaseClass>(this->functionPointer);
    103103  };
    104104};
     
    110110///////////
    111111//! @brief ExecutorClass, that can execute Functions with one parameter.
    112 template<class T, typename CallType, typename type0, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     112template<class T, typename CallType, typename type0, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    113113class __EXECUTOR_FUNCTIONAL_NAME(1,) : public Executor<CallType, BaseClass>
    114114{
     
    131131   * @param eval the CallType to get the Parameters from.
    132132   */
    133   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     133  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    134134  {
    135135    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    143143  virtual Executor<CallType, BaseClass>* clone() const
    144144  {
    145     return  new __EXECUTOR_FUNCTIONAL_NAME(1,)<T, CallType, type0>(this->functionPointer);
     145    return  new __EXECUTOR_FUNCTIONAL_NAME(1,)<T, CallType, type0, BaseClass>(this->functionPointer);
    146146  };
    147147};
     
    153153///////////
    154154//! @brief ExecutorClass, that can execute Functions with two parameters.
    155 template<class T, typename CallType, typename type0, typename type1, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     155template<class T, typename CallType, typename type0, typename type1, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    156156class __EXECUTOR_FUNCTIONAL_NAME(2,) : public Executor<CallType, BaseClass>
    157157{
     
    174174   * @param eval the CallType to get the Parameters from.
    175175   */
    176   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     176  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    177177  {
    178178    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    187187  virtual Executor<CallType, BaseClass>* clone() const
    188188  {
    189     return new __EXECUTOR_FUNCTIONAL_NAME(2,)<T, CallType, type0, type1>(this->functionPointer);
     189    return new __EXECUTOR_FUNCTIONAL_NAME(2,)<T, CallType, type0, type1, BaseClass>(this->functionPointer);
    190190  };
    191191};
     
    197197///////////
    198198//! @brief ExecutorClass, that can execute Functions with three parameters.
    199 template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     199template<class T, typename CallType, typename type0, typename type1, typename type2, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    200200class __EXECUTOR_FUNCTIONAL_NAME(3,) : public Executor<CallType, BaseClass>
    201201{
     
    218218   * @param eval the CallType to get the Parameters from.
    219219   */
    220   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     220  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    221221  {
    222222    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    232232  virtual Executor<CallType, BaseClass>* clone() const
    233233  {
    234     return new __EXECUTOR_FUNCTIONAL_NAME(3,)<T, CallType, type0, type1, type2>(this->functionPointer);
     234    return new __EXECUTOR_FUNCTIONAL_NAME(3,)<T, CallType, type0, type1, type2, BaseClass>(this->functionPointer);
    235235  };
    236236};
     
    242242///////////
    243243//! @brief ExecutorClass, that can execute Functions with four parameters.
    244 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     244template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    245245class __EXECUTOR_FUNCTIONAL_NAME(4,) : public Executor<CallType, BaseClass>
    246246{
     
    263263  * @param eval the CallType to get the Parameters from.
    264264   */
    265   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     265  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    266266  {
    267267    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    278278  virtual Executor<CallType, BaseClass>* clone() const
    279279  {
    280     return new __EXECUTOR_FUNCTIONAL_NAME(4,)<T, CallType, type0, type1, type2, type3>(this->functionPointer);
     280    return new __EXECUTOR_FUNCTIONAL_NAME(4,)<T, CallType, type0, type1, type2, type3, BaseClass>(this->functionPointer);
    281281  };
    282282};
     
    288288///////////
    289289//! @brief ExecutorClass, that can execute Functions with five parameters.
    290 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     290template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    291291class __EXECUTOR_FUNCTIONAL_NAME(5,) : public Executor<CallType, BaseClass>
    292292{
     
    309309  * @param eval the CallType to get the Parameters from.
    310310   */
    311   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     311  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    312312  {
    313313    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    325325  virtual Executor<CallType, BaseClass>* clone() const
    326326  {
    327     return new __EXECUTOR_FUNCTIONAL_NAME(5,)<T, CallType, type0, type1, type2, type3, type4>(this->functionPointer);
     327    return new __EXECUTOR_FUNCTIONAL_NAME(5,)<T, CallType, type0, type1, type2, type3, type4, BaseClass>(this->functionPointer);
    328328  };
    329329};
     
    334334////////////////////
    335335//! @brief ExecutorClass, that can execute Functions with one parameter.
    336 template<class T, typename CallType, typename ReturnType, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     336template<class T, typename CallType, typename ReturnType, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    337337class __EXECUTOR_FUNCTIONAL_NAME(0,ret) : public Executor<CallType, BaseClass>
    338338{
     
    355355     * @param eval the CallType to get the Parameters from.
    356356   */
    357   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     357  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    358358  {
    359359    Evaluater<CallType>::template storeRet<ReturnType>(eval, (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)());
     
    366366  virtual Executor<CallType, BaseClass>* clone() const
    367367  {
    368     return  new __EXECUTOR_FUNCTIONAL_NAME(0,ret)<T, CallType, ReturnType>(this->functionPointer);
     368    return  new __EXECUTOR_FUNCTIONAL_NAME(0,ret)<T, CallType, ReturnType, BaseClass>(this->functionPointer);
    369369  };
    370370};
     
    374374////////////////////
    375375//! @brief ExecutorClass, that can execute Functions with one parameter.
    376 template<class T, typename CallType, typename ReturnType, typename type0, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     376template<class T, typename CallType, typename ReturnType, typename type0, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    377377class __EXECUTOR_FUNCTIONAL_NAME(1,ret) : public Executor<CallType, BaseClass>
    378378{
     
    395395     * @param eval the CallType to get the Parameters from.
    396396   */
    397   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     397  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    398398  {
    399399    Evaluater<CallType>::template storeRet<ReturnType>(eval, (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    407407  virtual Executor<CallType, BaseClass>* clone() const
    408408  {
    409     return  new __EXECUTOR_FUNCTIONAL_NAME(1,ret)<T, CallType, ReturnType, type0>(this->functionPointer);
     409    return  new __EXECUTOR_FUNCTIONAL_NAME(1,ret)<T, CallType, ReturnType, type0, BaseClass>(this->functionPointer);
    410410  };
    411411};
     
    416416////////////////////
    417417//! @brief ExecutorClass, that can execute Functions with one parameter.
    418 template<class T, typename CallType, typename ReturnType, typename type0, typename type1, template<typename> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     418template<class T, typename CallType, typename ReturnType, typename type0, typename type1, class BaseClass = BaseObject, template<typename> class Evaluater = ExecutorEvaluater>
    419419class __EXECUTOR_FUNCTIONAL_NAME(2,ret) : public Executor<CallType, BaseClass>
    420420{
     
    437437     * @param eval the CallType to get the Parameters from.
    438438   */
    439   virtual void operator()(BaseObject* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
     439  virtual void operator()(BaseClass* object, CallType& eval = Evaluater<CallType>::defaultValue()) const
    440440  {
    441441    Evaluater<CallType>::template storeRet<ReturnType>(eval, (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     
    450450  virtual Executor<CallType, BaseClass>* clone() const
    451451  {
    452     return  new __EXECUTOR_FUNCTIONAL_NAME(2,ret)<T, CallType, ReturnType, type0, type1>(this->functionPointer);
     452    return  new __EXECUTOR_FUNCTIONAL_NAME(2,ret)<T, CallType, ReturnType, type0, type1, BaseClass>(this->functionPointer);
    453453  };
    454454};
  • branches/new_class_id/src/lib/util/executor/functor_generic.h

    r9745 r9769  
    2727 */
    2828#define EXECUTOR_FUNCTIONAL_CREATOR0(CallType) \
    29 template<class T> Executor<CallType>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
     29template<class T, class BaseClass> Executor<CallType, BaseClass>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
    3030{ \
    31   return new __EXECUTOR_FUNCTIONAL_NAME(0,)<T, CallType>(functionPointer); \
     31  return new __EXECUTOR_FUNCTIONAL_NAME(0,)<T, CallType, BaseClass>(functionPointer); \
    3232}
    3333
     
    3838 */
    3939#define EXECUTOR_FUNCTIONAL_CREATOR1(CallType, type0) \
    40 template<class T> Executor<CallType>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) \
     40template<class T, class BaseClass> Executor<CallType, BaseClass>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) \
    4141{ \
    42   return new __EXECUTOR_FUNCTIONAL_NAME(1,)<T, CallType, type0>(functionPointer); \
     42  return new __EXECUTOR_FUNCTIONAL_NAME(1,)<T, CallType, type0, BaseClass>(functionPointer); \
    4343}
    4444
     
    5050 */
    5151#define EXECUTOR_FUNCTIONAL_CREATOR2(CallType, type0, type1) \
    52 template<class T> Executor<CallType>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) \
     52template<class T, class BaseClass> Executor<CallType, BaseClass>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) \
    5353{ \
    54   return new __EXECUTOR_FUNCTIONAL_NAME(2,)<T, CallType, type0, type1>(functionPointer); \
     54  return new __EXECUTOR_FUNCTIONAL_NAME(2,)<T, CallType, type0, type1, BaseClass>(functionPointer); \
    5555}
    5656
     
    6363 */
    6464#define EXECUTOR_FUNCTIONAL_CREATOR3(CallType, type0, type1, type2) \
    65 template<class T> Executor<CallType>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) \
     65template<class T, class BaseClass> Executor<CallType, BaseClass>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) \
    6666{ \
    67   return new __EXECUTOR_FUNCTIONAL_NAME(3,)<T, CallType, type0, type1, type2>(functionPointer); \
     67  return new __EXECUTOR_FUNCTIONAL_NAME(3,)<T, CallType, type0, type1, type2, BaseClass>(functionPointer); \
    6868}
    6969
     
    7777 */
    7878#define EXECUTOR_FUNCTIONAL_CREATOR4(CallType, type0, type1, type2, type3) \
    79 template<class T> Executor<CallType>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) \
     79template<class T, class BaseClass> Executor<CallType, BaseClass>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) \
    8080{ \
    81   return new __EXECUTOR_FUNCTIONAL_NAME(4,)<T, CallType, type0, type1, type2, type3>(functionPointer); \
     81  return new __EXECUTOR_FUNCTIONAL_NAME(4,)<T, CallType, type0, type1, type2, type3, BaseClass>(functionPointer); \
    8282}
    8383
     
    9292 */
    9393#define EXECUTOR_FUNCTIONAL_CREATOR5(CallType, type0, type1, type2, type3, type4) \
    94 template<class T> Executor<CallType>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) \
     94template<class T, class BaseClass> Executor<CallType, BaseClass>* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) \
    9595{ \
    96     return new __EXECUTOR_FUNCTIONAL_NAME(5,)<T, CallType, type0, type1, type2, type3, type4>(functionPointer); \
     96    return new __EXECUTOR_FUNCTIONAL_NAME(5,)<T, CallType, type0, type1, type2, type3, type4, BaseClass>(functionPointer); \
    9797}
    9898
  • branches/new_class_id/src/lib/util/loading/load_param.cc

    r9765 r9769  
    2727 * @param inLoadCycle If we are in a LoadCycle (loading differs.).
    2828 */
    29 LoadParamBase::LoadParamBase(const TiXmlElement* root, const std::string& paramName, BaseObject* object, bool inLoadCycle)
    30     :  object(object), paramName(paramName), inLoadCycle(inLoadCycle)
     29LoadParamBase::LoadParamBase(const TiXmlElement* root, const std::string& paramName, bool inLoadCycle)
     30    :  paramName(paramName), inLoadCycle(inLoadCycle)
    3131{
    3232  // determin the LoadString.
     
    5555
    5656
    57 /**
    58  * @brief generates a LoadParam based on
    59  * @param root the Root Element to load onto the object.
    60  * @param paramName the Parameter name that is loaded.
    61  * @param object the Object to apply the changes on.
    62  * @param executor the Functional Object, that actually executes the function Call.
    63  * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
    64  */
    65 CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor<const SubString>* executor, bool inLoadCycle)
    66     : LoadParamBase(root, paramName, object, inLoadCycle)
    67 {
    68   assert (executor != NULL);
    69   // set the Executor.
    70   this->executor = executor;
    71   //if (this->executor)
    72   //  this->executor->setName(paramName);
    73 }
    74 
    75 /**
    76  * This is a VERY SPECIAL deconsrtuctor.
    77  * It is made, so that it loads the Parameters on destruction.
    78  * meaning, if an Executor a valid Object exist, and all
    79  * Execution-Conditions are met, they are executed here.
    80  */
    81 CLoadParam::~CLoadParam()
    82 {
    83   assert(this->object != NULL);
    84 
    85   std::string loadString;
    86   if (this->loadElem != NULL &&  this->loadElem->ToText())
    87   {
    88     loadString = this->loadElem->Value();
    89     if (!loadString.empty())
    90     {
    91       PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n",
    92                 this->paramName.c_str(), loadString.c_str(), this->object->getClassCName(), this->object->getCName());
    93       (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\'));
    94     }
    95   }
    96   delete this->executor;
    97 }
    98 
    99 /**
    100  * @brief set the default values of the executor
    101  * @param value0 the first default value
    102  * @param value1 the second default value
    103  * @param value2 the third default value
    104  * @param value3 the fourth default value
    105  * @param value4 the fifth default value
    106  */
    107 CLoadParam& CLoadParam::defaultValues(const MultiType& value0, const MultiType& value1,
    108                                       const MultiType& value2, const MultiType& value3,
    109                                       const MultiType& value4)
    110 {
    111   assert(this->executor != NULL);
    112   this->executor->defaultValues(value0, value1, value2, value3, value4);
    113 
    114   return *this;
    115 }
    11657
    11758
  • branches/new_class_id/src/lib/util/loading/load_param.h

    r9765 r9769  
    4545 */
    4646#define LoadParam(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    47          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), false)
     47         CLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS, CLASS>(&CLASS::FUNCTION), false)
    4848
    4949/**
     
    5656 */
    5757#define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    58          CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), true)
     58         CLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS, CLASS>(&CLASS::FUNCTION), true)
    5959
    6060/**
     
    8989{
    9090protected:
    91   LoadParamBase(const TiXmlElement* root, const std::string& paramName, BaseObject* object, bool inLoadCycle = false);
     91  LoadParamBase(const TiXmlElement* root, const std::string& paramName, bool inLoadCycle = false);
    9292
    9393protected:
     
    9595
    9696protected:
    97   BaseObject*              object;               //!< The Object to work on
    9897  const std::string        paramName;            //!< The Name of the Parameter this LoadParams applies to.
    9998  bool                     inLoadCycle;          //!< If the Parameter is in a LoadCycle.
     
    104103
    105104//! The Loading Class of the LoadParam, that acctually executes the loading process.
    106 class CLoadParam : public LoadParamBase
     105template <class OperateClass> class CLoadParam : public LoadParamBase
    107106{
    108107public:
    109   CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor<const SubString>* executor, bool inLoadCycle = false);
    110   virtual ~CLoadParam();
    111 
     108  /**
     109   * @brief generates a LoadParam based on
     110   * @param root the Root Element to load onto the object.
     111   * @param paramName the Parameter name that is loaded.
     112   * @param object the Object to apply the changes on.
     113   * @param executor the Functional Object, that actually executes the function Call.
     114   * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
     115   */
     116  CLoadParam(const TiXmlElement* root, const std::string& paramName, OperateClass* object, Executor<const SubString, OperateClass>* executor, bool inLoadCycle = false)
     117      : LoadParamBase(root, paramName, inLoadCycle)
     118  {
     119    assert (executor != NULL);
     120    this->object = object;
     121    this->executor = executor;
     122  }
     123  virtual ~CLoadParam()
     124  {
     125    std::string loadString;
     126    if (this->loadElem != NULL &&  this->loadElem->ToText())
     127    {
     128      loadString = this->loadElem->Value();
     129      if (!loadString.empty())
     130      {
     131        /*      PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n",
     132                this->paramName.c_str(), loadString.c_str(), this->object->getClassCName(), this->object->getCName());*/
     133        (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\'));
     134      }
     135    }
     136    delete this->executor;
     137  }
     138  /**
     139   * @brief set the default values of the executor
     140   * @param value0 the first default value   @param value1 the second default value
     141   * @param value2 the third default value   @param value3 the fourth default value
     142   * @param value4 the fifth default value
     143   */
    112144  CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    113145                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    114                             const MultiType& value4 = MT_NULL);
     146                            const MultiType& value4 = MT_NULL)
     147  { this->executor->defaultValues(value0, value1, value2, value3, value4); return *this;  };
    115148  CLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(descriptionText); return *this; };
    116149  //     CLoadParam& attribute(const std::string& attributeName, const Executor<SubString>& executor);
     
    118151
    119152private:
    120   Executor<const SubString>*         executor;            //!< The Executor, that actually executes the Loading process.
     153  Executor<const SubString, OperateClass>*         executor;            //!< The Executor, that actually executes the Loading process.
     154  OperateClass*                                    object;
    121155};
    122156
  • branches/new_class_id/src/lib/util/loading/load_param_xml.cc

    r9763 r9769  
    1 /*
    2    orxonox - the future of 3D-vertical-scrollers
    3 
    4    Copyright (C) 2004 orx
    5 
    6    This program is free software; you can redistribute it and/or modify
    7    it under the terms of the GNU General Public License as published by
    8    the Free Software Foundation; either version 2, or (at your option)
    9    any later version.
    10 
    11    ### File Specific:
    12    main-programmer: Benjamin Grauer
    13    co-programmer: ...
    14 */
    151
    162#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
     
    195#include "load_param_description.h"
    206
    21 
    22 /**
    23  * @brief generates a LoadParam based on
    24  * @param root the Root Element to load onto the object.
    25  * @param paramName the Parameter name that is loaded.
    26  * @param object the Object to apply the changes on.
    27  * @param executor the Functional Object, that actually executes the function Call.
    28  * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
    29  */
    30 XmlLoadParam::XmlLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor<const TiXmlElement*>* executor, bool inLoadCycle )
    31     : LoadParamBase(root, paramName, object, inLoadCycle)
    32 {
    33   this->executor = executor;
    34 }
    35 
    36 
    37 XmlLoadParam::~XmlLoadParam()
    38 {
    39   assert(this->object != NULL);
    40 
    41   (*this->executor)(this->object, this->loadElem);
    42 
    43   delete this->executor;
    44 }
  • branches/new_class_id/src/lib/util/loading/load_param_xml.h

    r9763 r9769  
    3535 */
    3636#define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    37          XmlLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
     37         XmlLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS, CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
    3838
    3939
     
    4747 */
    4848#define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
    49          XmlLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
     49         XmlLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS, CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
    5050
    5151//! A Class that can load XML tags onto an Object.
    52 class XmlLoadParam : public LoadParamBase
     52template <class BaseClass = BaseObject> class XmlLoadParam : public LoadParamBase
    5353{
    54   public:
    55     XmlLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor<const TiXmlElement*>* executor, bool inLoadCycle = false);
    56     virtual ~XmlLoadParam();
     54public:
     55  /**
     56   * @brief generates a LoadParam based on
     57   * @param root the Root Element to load onto the object.
     58   * @param paramName the Parameter name that is loaded.
     59   * @param object the Object to apply the changes on.
     60   * @param executor the Functional Object, that actually executes the function Call.
     61   * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
     62   */
     63  XmlLoadParam(const TiXmlElement* root, const std::string& paramName, BaseClass* object, Executor<const TiXmlElement*>* executor, bool inLoadCycle = false)
     64      : LoadParamBase(root, paramName, inLoadCycle), object(object) , executor(executor)
     65  {
     66    assert(this->object != NULL);
     67    assert(this->executor != NULL);
     68  }
    5769
    58     /** @param descriptionText the description @returns self @brief describes the Loading parameter. */
    59     XmlLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(descriptionText); return *this; };
     70  /** @brief executes and destroys the executor */
     71  virtual ~XmlLoadParam()
     72  {
     73    (*this->executor)(this->object, this->loadElem);
     74    delete this->executor;
     75  }
    6076
    61   private:
    62     Executor<const TiXmlElement*>*    executor;       //!< The Executor, that does the actual loading process.
     77  /** @param descriptionText the description @returns self @brief describes the Loading parameter. */
     78  XmlLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(descriptionText); return *this; };
     79
     80private:
     81  BaseClass*                        object;         //!< The Object to apply this to.
     82  Executor<const TiXmlElement*>*    executor;       //!< The Executor, that does the actual loading process.
    6383};
    6484
Note: See TracChangeset for help on using the changeset viewer.