Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 15, 2006, 3:39:51 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: removed all the base of Executor.
Now it is purely Templated :), since it is not needed otherwise

@note: The Explicit Specializations may not be Templatet and defined in the header, that is why still there exist some cc-file

File:
1 edited

Legend:

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

    r9732 r9733  
    99#include "base_object.h"
    1010
    11 #include "helper_functions.h"
    1211#include "multi_type.h"
    13 #include "functor_list.h" //< MUST BE INCLUDED HERE AT LEAST ONCE.
    14 
    15 //! an enumerator for the definition of the Type.
    16 typedef enum {
    17   Executor_Objective,
    18   Executor_Static,
    19 } Executor_Type;
    2012
    2113//! The maximum Count of Arguments of the Executor
     
    4739 *  Functions with many types (@see functor_list.h)
    4840 */
    49 class ExecutorBase
     41template <typename CallType> class Executor
    5042{
    5143public:
     44  //! an enumerator for the definition of the Type.
     45  typedef enum {
     46    FunctionDefault,
     47    FunctionStatic,
     48    FunctionConst,
     49  } FunctionType;
     50
     51public:
     52  virtual ~Executor() {};
     53
     54  // RETRIEVE INFORMATION
    5255  /** @param i the i'th defaultValue, @returns reference to the MultiType */
    5356  inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
     57  /** @returns the default Values as a List */
     58  inline const MultiType* const getDefaultValues() { return defaultValue; };
    5459
    55   // RETRIEVE INFORMATION
    5660  /** @returns the Type of this Function (either static or objective) */
    57   inline Executor_Type getType() const { return this->functorType; };
     61  inline FunctionType getType() const { return this->functionType; };
    5862
    5963  /** @returns the Count of Parameters this Executor takes */
     
    6165  /** @returns true if the Executor has a return Value. */
    6266  inline bool hasRetVal() const { return bRetVal; };
    63 
    64   static void debug();
    65 
    66 protected:
    67   virtual ~ExecutorBase() {};
    68   ExecutorBase(bool hasRetVal = false,
    69                const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
    70                const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    71                const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
    72                const MultiType& param6 = MT_NULL);
    73 
    74   // SETTING up the EXECUTOR
    75   void defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    76                      const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    77                      const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL,
    78                      const MultiType& param6 = MT_NULL);
    79 
    80   void cloning(ExecutorBase* executor) const;
    81 
    82 protected:
    83   Executor_Type               functorType;      //!< The type of Function we've got (either static or objective).
    84   unsigned int                paramCount;       //!< the count of parameters.
    85   MultiType                   defaultValue[7];  //!< Default Values.
    86 
    87 private:
    88   const bool                  bRetVal;          //!< True if the Executor has a return Value.
    89   const bool                  bStaticFunction;  //!< A Executor to a Static Function
    90   const bool                  bConstFunction;   //!< A Executor to a Constant Function
    91 };
    92 
    93 template <typename CallType> class Executor : public ExecutorBase
    94 {
    95 public:
    96   virtual Executor<CallType>* clone () const = 0;
    9767
    9868  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     
    11484                          const MultiType& value6 = MT_NULL)
    11585  {
    116     this->ExecutorBase::defaultValues(value0, value1, value2, value3, value4, value5, value6);
     86    const MultiType* value[5];
     87    value[0] = &value0;
     88    value[1] = &value1;
     89    value[2] = &value2;
     90    value[3] = &value3;
     91    value[4] = &value4;
     92    value[5] = &value5;
     93    value[6] = &value6;
     94    for (unsigned int i = 0; i < this->paramCount; i++)
     95    {
     96      if (*value[i] != MT_NULL)
     97      {
     98        this->defaultValue[i].setValueOf(*value[i]);
     99        this->defaultValue[i].storeString();
     100      }
     101    }
    117102    return this;
    118103  }
     104
     105  virtual Executor<CallType>* clone () const = 0;
    119106
    120107protected:
     
    124111           const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
    125112           const MultiType& param6 = MT_NULL)
    126       : ExecutorBase(hasRetVal, param0, param1, param2, param3, param4, param5, param6)
    127 {}}
    128 ;
     113      : bRetVal(hasRetVal)
     114  {
     115    // What Parameters have we got
     116    this->defaultValue[0] = param0;
     117    this->defaultValue[1] = param1;
     118    this->defaultValue[2] = param2;
     119    this->defaultValue[3] = param3;
     120    this->defaultValue[4] = param4;
     121    this->defaultValue[5] = param5;
     122    this->defaultValue[6] = param6;
     123
     124    this->paramCount = 0;
     125    for (unsigned int i = 0; i <= EXECUTOR_MAX_ARGUMENTS; i++)
     126    {
     127      if (this->defaultValue[i] == MT_NULL || i == EXECUTOR_MAX_ARGUMENTS)
     128      {
     129        this->paramCount = i;
     130        break;
     131      }
     132      else
     133        this->defaultValue[i].storeString();
     134    }
     135  }
     136
     137
     138
     139protected:
     140  unsigned int                paramCount;       //!< the count of parameters.
     141  MultiType                   defaultValue[7];  //!< Default Values.
     142
     143  FunctionType          functionType;     //!< What Type of Function it is.
     144private:
     145  const bool                  bRetVal;          //!< True if the Executor has a return Value.
     146};
    129147
    130148#endif /* _EXECUTOR_H */
Note: See TracChangeset for help on using the changeset viewer.