Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9735 in orxonox.OLD for branches/new_class_id/src/lib


Ignore:
Timestamp:
Sep 15, 2006, 4:16:06 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: better usage of the FunctionType in the FunctionalExecutor

Location:
branches/new_class_id/src/lib/util/executor
Files:
3 edited

Legend:

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

    r9734 r9735  
    3939 *  Functions with many types (@see functor_list.h)
    4040 */
    41 template <typename CallType> class Executor
     41template <typename CallType, class BaseClass = BaseObject> class Executor
    4242{
    4343public:
    4444  //! an enumerator for the definition of the Type.
    4545  typedef enum {
    46     FunctionDefault,
    47     FunctionStatic,
    48     FunctionConst,
     46    FunctionDefault,     //!< The function is neither Static nor Constant
     47    FunctionStatic,      //!< The Function is Static and pointing to either a Static Member or a C-style function.
     48    FunctionConst,       //!< The Function is Constant and pointing to a Member that does not change the Object.
    4949  } FunctionType;
    5050
     
    6767
    6868  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    69   virtual void operator()(BaseObject* object, CallType& values) const = 0;
     69  virtual void operator()(BaseClass* object, CallType& values) const = 0;
    7070
    7171  /**
     
    103103  }
    104104
     105  /** @returns the Clone as a new Copy of the Executor. */
    105106  virtual Executor<CallType>* clone () const = 0;
    106107
     
    193194protected:
    194195  const bool                  bRetVal;          //!< True if the Executor has a return Value.
    195   unsigned int                paramCount;       //!< the count of parameters.
     196  const unsigned int          paramCount;       //!< the count of parameters.
    196197  MultiType                   defaultValue[7];  //!< Default Values.
    197198
  • branches/new_class_id/src/lib/util/executor/executor_functional.h

    r9734 r9735  
    6161{
    6262public:
     63  /** @brief Executes the Evaluator
     64   * @param CallValue the Value that should be converted
     65   * @param defaults the default Values.
     66   */
    6367  ToType operator()(FromType& CallValue, const MultiType* const defaults)
    6468  {
     
    7983//! The Function-Pointer, and how to save it internally.
    8084#define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER   T::*functionPointer
     85#define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionDefault
    8186
    8287#ifdef EXECUTOR_FUNCTIONAL_USE_CONST            //! USING CONST FUNCTIONALS
     
    8893 #undef __EXECUTOR_FUNCTIONAL_CONST
    8994 #define __EXECUTOR_FUNCTIONAL_CONST const
     95 #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
     96 #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionConst
    9097 #undef __EXECUTOR_FUNCTIONAL_NAME
    9198 #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params_const
     
    109116 #undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER
    110117 #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER    *functionPointer
     118 #undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
     119 #define __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE       Executor<CallType, BaseClass>::FunctionStatic
    111120
    112121//#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
     
    121130#ifndef __EXECUTOR_FUNCTIONAL_NOT_INCLUDE_THIS
    122131
     132
     133
     134
    123135///////////
    124136//// 0 ////
    125137///////////
    126138//! @brief ExecutorClass, that can execute Functions without any parameters.
    127 template<class T, typename CallType, template<typename, typename, int> class Evaluater = ExecutorEvaluater>
    128 class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor<CallType>
     139template<class T, typename CallType, template<typename, typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     140class __EXECUTOR_FUNCTIONAL_NAME(0) :public Executor<CallType, BaseClass>
    129141{
    130142private:
     
    138150   */
    139151  __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST )
    140       : Executor<CallType>(false)
     152      : Executor<CallType, BaseClass>(false, __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    141153  {
    142154    this->functionPointer = functionPointer;
     
    157169   * @returns a new Executor that's a copy of this one.
    158170   */
    159   virtual Executor<CallType>* clone() const
     171  virtual Executor<CallType, BaseClass>* clone() const
    160172  {
    161173    return new __EXECUTOR_FUNCTIONAL_NAME(0)<T, CallType>(this->functionPointer);
     
    165177
    166178
     179
     180
    167181///////////
    168182//// 1 ////
    169183///////////
    170184//! @brief ExecutorClass, that can execute Functions with one parameter.
    171 template<class T, typename CallType, typename type0, template<typename, typename, int> class Evaluater = ExecutorEvaluater>
    172 class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<CallType>
     185template<class T, typename CallType, typename type0, template<typename, typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     186class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor<CallType, BaseClass>
    173187{
    174188private:
     
    182196   */
    183197  __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST)
    184       : Executor<CallType>(false, ExecutorParamType<type0>())
     198      : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    185199  {
    186200    this->functionPointer = functionPointer;
     
    202216   * @returns a new Executor that's a copy of this one.
    203217   */
    204   virtual Executor<CallType>* clone() const
     218  virtual Executor<CallType, BaseClass>* clone() const
    205219  {
    206220    return  new __EXECUTOR_FUNCTIONAL_NAME(1)<T, CallType, type0>(this->functionPointer);
     
    208222};
    209223
     224
     225
     226
     227
    210228///////////
    211229//// 2 ////
    212230///////////
    213231//! @brief ExecutorClass, that can execute Functions with two parameters.
    214 template<class T, typename CallType, typename type0, typename type1, template<typename, typename, int> class Evaluater = ExecutorEvaluater>
    215 class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<CallType>
     232template<class T, typename CallType, typename type0, typename type1, template<typename, typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     233class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor<CallType, BaseClass>
    216234{
    217235private:
     
    225243   */
    226244  __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST)
    227       : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>())
     245  : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    228246  {
    229247    this->functionPointer = functionPointer;
     
    246264   * @returns a new Executor that's a copy of this one.
    247265   */
    248   virtual Executor<CallType>* clone() const
     266  virtual Executor<CallType, BaseClass>* clone() const
    249267  {
    250268    return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, CallType, type0, type1>(this->functionPointer);
     
    253271
    254272
     273
     274
     275
    255276///////////
    256277//// 3 ////
    257278///////////
    258279//! @brief ExecutorClass, that can execute Functions with three parameters.
    259 template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename, typename, int> class Evaluater = ExecutorEvaluater>
    260 class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<CallType>
     280template<class T, typename CallType, typename type0, typename type1, typename type2, template<typename, typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     281class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor<CallType, BaseClass>
    261282{
    262283private:
     
    270291   */
    271292  __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST)
    272       : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
     293  : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    273294  {
    274295    this->functionPointer = functionPointer;
     
    292313   * @returns a new Executor that's a copy of this one.
    293314   */
    294   virtual Executor<CallType>* clone() const
     315  virtual Executor<CallType, BaseClass>* clone() const
    295316  {
    296317    return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, CallType, type0, type1, type2>(this->functionPointer);
     
    300321
    301322
     323
     324
    302325///////////
    303326//// 4 ////
    304327///////////
    305328//! @brief ExecutorClass, that can execute Functions with four parameters.
    306 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename, typename, int> class Evaluater = ExecutorEvaluater>
    307 class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<CallType>
     329template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, template<typename, typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     330class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor<CallType, BaseClass>
    308331{
    309332private:
     
    317340   */
    318341  __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST)
    319       : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
     342  : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    320343  {
    321344    this->functionPointer = functionPointer;
     
    340363   * @returns a new Executor that's a copy of this one.
    341364   */
    342   virtual Executor<CallType>* clone() const
     365  virtual Executor<CallType, BaseClass>* clone() const
    343366  {
    344367    return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, CallType, type0, type1, type2, type3>(this->functionPointer);
     
    348371
    349372
     373
     374
     375
    350376///////////
    351377//// 5 ////
    352378///////////
    353379//! @brief ExecutorClass, that can execute Functions with five parameters.
    354 template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename, typename, int> class Evaluater = ExecutorEvaluater>
    355 class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<CallType>
     380template<class T, typename CallType, typename type0, typename type1, typename type2, typename type3, typename type4, template<typename, typename, int> class Evaluater = ExecutorEvaluater, class BaseClass = BaseObject>
     381class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor<CallType, BaseClass>
    356382{
    357383private:
     
    365391   */
    366392  __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST)
    367       : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
     393  : Executor<CallType, BaseClass>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>(), __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE)
    368394  {
    369395    this->functionPointer = functionPointer;
     
    389415   * @returns a new Executor that's a copy of this one.
    390416   */
    391   virtual Executor<CallType>* clone() const
     417  virtual Executor<CallType, BaseClass>* clone() const
    392418  {
    393419    return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, CallType, type0, type1, type2, type3, type4>(this->functionPointer);
     
    489515#undef __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC
    490516#undef __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER
     517#undef __EXECUTOR_FUNCTIONAL_FUNCTIONTYPE
    491518
    492519#ifdef EXECUTOR_FUNCTIONAL_USE_CONST
  • branches/new_class_id/src/lib/util/executor/executor_xml.h

    r9734 r9735  
    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<const TiXmlElement*>
     21template<class T, class BaseClass = BaseObject> class ExecutorXML : public Executor<const TiXmlElement*>
    2222{
    2323public:
Note: See TracChangeset for help on using the changeset viewer.