Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9733 in orxonox.OLD for branches/new_class_id


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

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

Legend:

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

    r9732 r9733  
    1818#include "executor.h"
    1919
    20 
    2120template<> MT_Type ExecutorParamType<bool>() { return MT_BOOL; };
    2221template<> MT_Type ExecutorParamType<int>() { return MT_INT; };
     
    2524template<> MT_Type ExecutorParamType<char>() { return MT_CHAR; };
    2625template<> MT_Type ExecutorParamType<const std::string&>() { return MT_STRING; };
    27 
    28 
    29 
    30 /**
    31  * @brief constructs and registers a new Command
    32  * @param commandName the name of the Command
    33  * @param className the name of the class to apply this command to
    34  * @param paramCount the count of parameters this command takes
    35  */
    36 ExecutorBase::ExecutorBase(bool hasRetVal,
    37                            const MultiType& param0,
    38                            const MultiType& param1,
    39                            const MultiType& param2,
    40                            const MultiType& param3,
    41                            const MultiType& param4,
    42                            const MultiType& param5,
    43                            const MultiType& param6)
    44   : bRetVal(hasRetVal)
    45 {
    46   // What Parameters have we got
    47   this->defaultValue[0] = param0;
    48   this->defaultValue[1] = param1;
    49   this->defaultValue[2] = param2;
    50   this->defaultValue[3] = param3;
    51   this->defaultValue[4] = param4;
    52   this->defaultValue[5] = param5;
    53   this->defaultValue[6] = param6;
    54 
    55   this->paramCount = 0;
    56   for (unsigned int i = 0; i <= EXECUTOR_MAX_ARGUMENTS; i++)
    57   {
    58     if (this->defaultValue[i] == MT_NULL || i == EXECUTOR_MAX_ARGUMENTS)
    59     {
    60       this->paramCount = i;
    61       break;
    62     }
    63     else
    64       this->defaultValue[i].storeString();
    65   }
    66 }
    67 
    68 /**
    69  * clones this element into executor.
    70  * @param executor the Executor to clone
    71  */
    72 void ExecutorBase::cloning(ExecutorBase* executor) const
    73 {
    74   executor->functorType  = this->functorType;
    75   executor->paramCount   = this->paramCount;
    76   for (unsigned int i = 0; i < this->paramCount; i++)
    77     executor->defaultValue[i] =  this->defaultValue[i];
    78 }
    79 
    80 /**
    81  * @brief set the default values of the executor
    82  * @param value0 the first default value
    83  * @param value1 the second default value
    84  * @param value2 the third default value
    85  * @param value3 the fourth default value
    86  * @param value4 the fifth default value
    87  * @returns itself
    88  */
    89 void ExecutorBase::defaultValues(const MultiType& value0,
    90                                   const MultiType& value1,
    91                                   const MultiType& value2,
    92                                   const MultiType& value3,
    93                                   const MultiType& value4,
    94                                   const MultiType& value5,
    95                                   const MultiType& value6)
    96 {
    97   const MultiType* value[5];
    98   value[0] = &value0;
    99   value[1] = &value1;
    100   value[2] = &value2;
    101   value[3] = &value3;
    102   value[4] = &value4;
    103   value[5] = &value5;
    104   value[6] = &value6;
    105   for (unsigned int i = 0; i < this->paramCount; i++)
    106   {
    107     if (*value[i] != MT_NULL)
    108     {
    109       this->defaultValue[i].setValueOf(*value[i]);
    110       this->defaultValue[i].storeString();
    111     }
    112   }
    113 }
    114 
    115 /**
    116  * @brief prints out nice information about the Executor
    117  */
    118 void ExecutorBase::debug()
    119 {
    120 }
  • 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 */
  • branches/new_class_id/src/lib/util/executor/executor_functional.h

    r9732 r9733  
    140140      : Executor<CallType>(false)
    141141  {
    142     this->functorType = Executor_Objective;
     142    this->functionType = Executor<CallType>::FunctionDefault;
    143143    this->functionPointer = functionPointer;
    144144  };
     
    185185      : Executor<CallType>(false, ExecutorParamType<type0>())
    186186  {
    187     this->functorType = Executor_Objective;
     187    this->functionType = Executor<CallType>::FunctionDefault;
    188188    this->functionPointer = functionPointer;
    189189  };
     
    229229      : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>())
    230230  {
    231     this->functorType = Executor_Objective;
     231    this->functionType = Executor<CallType>::FunctionDefault;
    232232    this->functionPointer = functionPointer;
    233233  };
     
    275275      : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>())
    276276  {
    277     this->functorType = Executor_Objective;
     277    this->functionType = Executor<CallType>::FunctionDefault;
    278278    this->functionPointer = functionPointer;
    279279  };
     
    323323      : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>())
    324324  {
    325     this->functorType = Executor_Objective;
     325    this->functionType = Executor<CallType>::FunctionDefault;
    326326    this->functionPointer = functionPointer;
    327327  };
     
    372372      : Executor<CallType>(false, ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>())
    373373  {
    374     this->functorType = Executor_Objective;
     374    this->functionType = Executor<CallType>::FunctionDefault;
    375375    this->functionPointer = functionPointer;
    376376  };
  • branches/new_class_id/src/lib/util/executor/executor_lua.h

    r9728 r9733  
    5151  {
    5252    this->functionPointer = function;
    53     this->functorType = Executor_Objective;
     53    this->functionType = Executor<lua_State*>::FunctionDefault;
    5454  }
    5555
     
    8888  {
    8989    this->functionPointer = function;
    90     this->functorType = Executor_Objective;
     90    this->functionType = Executor<lua_State*>::FunctionDefault;
    9191  }
    9292
     
    124124  {
    125125    this->functionPointer = function;
    126     this->functorType = Executor_Objective;
     126    this->functionType = Executor<lua_State*>::FunctionDefault;
    127127  }
    128128
     
    161161  {
    162162    this->functionPointer = function;
    163     this->functorType = Executor_Objective;
     163    this->functionType = Executor<lua_State*>::FunctionDefault;
    164164  }
    165165
     
    200200  {
    201201    this->functionPointer = function;
    202     this->functorType = Executor_Objective;
     202    this->functionType = Executor<lua_State*>::FunctionDefault;
    203203  }
    204204
     
    246246  {
    247247    this->functionPointer = function;
    248     this->functorType = Executor_Objective;
     248    this->functionType = Executor<lua_State*>::FunctionDefault;
    249249  }
    250250
     
    282282  {
    283283    this->functionPointer = function;
    284     this->functorType = Executor_Objective;
     284    this->functionType = Executor<lua_State*>::FunctionDefault;
    285285  }
    286286
     
    317317  {
    318318    this->functionPointer = function;
    319     this->functorType = Executor_Objective;
     319    this->functionType = Executor<lua_State*>::FunctionDefault;
    320320  }
    321321
     
    354354  {
    355355    this->functionPointer = function;
    356     this->functorType = Executor_Objective;
     356    this->functionType = Executor<lua_State*>::FunctionDefault;
    357357  }
    358358
     
    392392  {
    393393    this->functionPointer = function;
    394     this->functorType = Executor_Objective;
     394    this->functionType = Executor<lua_State*>::FunctionDefault;
    395395  }
    396396
     
    430430  {
    431431    this->functionPointer = function;
    432     this->functorType = Executor_Objective;
     432    this->functionType = Executor<lua_State*>::FunctionDefault;
    433433  }
    434434
     
    471471  {
    472472    this->functionPointer = function;
    473     this->functorType = Executor_Objective;
     473    this->functionType = Executor<lua_State*>::FunctionDefault;
    474474  }
    475475
     
    514514  {
    515515    this->functionPointer = function;
    516     this->functorType = Executor_Objective;
     516    this->functionType = Executor<lua_State*>::FunctionDefault;
    517517  }
    518518
  • branches/new_class_id/src/lib/util/executor/executor_xml.h

    r9727 r9733  
    4040    this->paramName = paramName;
    4141    this->functionPointer = function;
    42     this->functorType = Executor_Objective;
     42    this->functionType = FunctionDefault;
    4343  }
    4444
Note: See TracChangeset for help on using the changeset viewer.