Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 14, 2006, 5:24:31 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: new Executor construct, that is much more typesafe, faster, and easier to extend…

Also changed the LoadParam process, and adapted ScriptEngine calls

Then at the end, some missing headers appeared, and appended them to all the cc-files again.

File:
1 edited

Legend:

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

    r9715 r9727  
    1818  Executor_Objective         = 1,
    1919  Executor_Static            = 2,
    20 
    21   Executor_NoLoadString      = 8,
    2220} Executor_Type;
    2321
     
    3634 *  Functions with many types (@see functor_list.h)
    3735 */
    38 class Executor : public BaseObject
     36class ExecutorBase : public BaseObject
    3937{
    40   ObjectListDeclaration(Executor);
    41   public:
    42     virtual ~Executor();
     38  ObjectListDeclaration(ExecutorBase);
     39public:
     40  //    virtual bool operator==(const Executor* executor) const = 0;
    4341
    44     virtual Executor* clone () const = 0;
    45 //    virtual bool operator==(const Executor* executor) const = 0;
     42  /** @param i the i'th defaultValue, @returns reference to the MultiType */
     43  inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
    4644
    47     // SETTING up the EXECUTOR
    48     Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    49                             const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    50                             const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL,
    51                             const MultiType& param6 = MT_NULL);
    52     /** @param i the i'th defaultValue, @returns reference to the MultiType */
    53     inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
     45  // EXECUTE
     46  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     47  //     virtual void operator()(BaseObject* object, int& count, void* values) const = 0;
     48  /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
     49  //     virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
    5450
    55     // EXECUTE
    56     /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
    57     virtual void operator()(BaseObject* object, int& count, void* values) const = 0;
    58     /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    59     virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
     51  // RETRIEVE INFORMATION
     52  /** @returns the Type of this Function (either static or objective) */
     53  inline long getType() const { return this->functorType; };
     54  /** @returns the Count of Parameters this Executor takes */
     55  inline unsigned int getParamCount() const { return this->paramCount; };
     56  /** @returns true if the Executor has a return Value. */
     57  inline bool hasRetVal() const { return bRetVal; };
    6058
    61     // RETRIEVE INFORMATION
    62     /** @returns the Type of this Function (either static or objective) */
    63     inline long getType() const { return this->functorType; };
    64     /** @returns the Count of Parameters this Executor takes */
    65     inline unsigned int getParamCount() const { return this->paramCount; };
     59  static void debug();
    6660
    67     static void debug();
     61protected:
     62  ExecutorBase(bool hasRetVal = false,
     63               const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     64               const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
     65               const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
     66               const MultiType& param6 = MT_NULL);
    6867
    69   protected:
    70     Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
    71              const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    72              const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
    73              const MultiType& param6 = MT_NULL);
     68  // SETTING up the EXECUTOR
     69  void defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     70                     const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     71                     const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL,
     72                     const MultiType& param6 = MT_NULL);
    7473
    75     void cloning(Executor* executor) const;
     74  void cloning(ExecutorBase* executor) const;
    7675
    77   protected:
    78     short                       functorType;      //!< The type of Function we've got (either static or objective).
    79     unsigned int                paramCount;       //!< the count of parameters.
    80     MultiType                   defaultValue[7];  //!< Default Values.
     76protected:
     77  short                       functorType;      //!< The type of Function we've got (either static or objective).
     78  unsigned int                paramCount;       //!< the count of parameters.
     79  MultiType                   defaultValue[7];  //!< Default Values.
     80
     81  bool                        bRetVal;          //!< True if the Executor has a return Value.
    8182};
     83
     84template <typename CallType> class Executor : public ExecutorBase
     85{
     86public:
     87  virtual Executor<CallType>* clone () const = 0;
     88
     89  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     90  virtual void operator()(BaseObject* object, CallType& values) const = 0;
     91
     92  /**
     93   * @brief set the default values of the executor
     94   * @param value0 the first default value
     95   * @param value1 the second default value
     96   * @param value2 the third default value
     97   * @param value3 the fourth default value
     98   * @param value4 the fifth default value
     99   * @returns itself
     100   * @note: THIS FUNCTION WILL BE REPLACED BY A CONFIGURATOR (most probably).
     101  */
     102  Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     103                          const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     104                          const MultiType& value4 = MT_NULL, const MultiType& value5 = MT_NULL,
     105                          const MultiType& value6 = MT_NULL)
     106  {
     107    this->ExecutorBase::defaultValues(value0, value1, value2, value3, value4, value5, value6);
     108    return this;
     109  }
     110
     111
     112
     113protected:
     114  Executor(bool hasRetVal,
     115           const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     116           const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
     117           const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL,
     118           const MultiType& param6 = MT_NULL)
     119      : ExecutorBase(hasRetVal, param0, param1, param2, param3, param4, param5, param6)
     120  {}
     121};
     122
     123
    82124
    83125#include "executor/executor_functional.h"
Note: See TracChangeset for help on using the changeset viewer.