Changeset 9733 in orxonox.OLD for branches/new_class_id/src/lib/util/executor/executor.h
- Timestamp:
- Sep 15, 2006, 3:39:51 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/util/executor/executor.h
r9732 r9733 9 9 #include "base_object.h" 10 10 11 #include "helper_functions.h"12 11 #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;20 12 21 13 //! The maximum Count of Arguments of the Executor … … 47 39 * Functions with many types (@see functor_list.h) 48 40 */ 49 class ExecutorBase 41 template <typename CallType> class Executor 50 42 { 51 43 public: 44 //! an enumerator for the definition of the Type. 45 typedef enum { 46 FunctionDefault, 47 FunctionStatic, 48 FunctionConst, 49 } FunctionType; 50 51 public: 52 virtual ~Executor() {}; 53 54 // RETRIEVE INFORMATION 52 55 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 53 56 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; }; 54 59 55 // RETRIEVE INFORMATION56 60 /** @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; }; 58 62 59 63 /** @returns the Count of Parameters this Executor takes */ … … 61 65 /** @returns true if the Executor has a return Value. */ 62 66 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 EXECUTOR75 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 Function90 const bool bConstFunction; //!< A Executor to a Constant Function91 };92 93 template <typename CallType> class Executor : public ExecutorBase94 {95 public:96 virtual Executor<CallType>* clone () const = 0;97 67 98 68 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ … … 114 84 const MultiType& value6 = MT_NULL) 115 85 { 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 } 117 102 return this; 118 103 } 104 105 virtual Executor<CallType>* clone () const = 0; 119 106 120 107 protected: … … 124 111 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL, 125 112 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 139 protected: 140 unsigned int paramCount; //!< the count of parameters. 141 MultiType defaultValue[7]; //!< Default Values. 142 143 FunctionType functionType; //!< What Type of Function it is. 144 private: 145 const bool bRetVal; //!< True if the Executor has a return Value. 146 }; 129 147 130 148 #endif /* _EXECUTOR_H */
Note: See TracChangeset
for help on using the changeset viewer.