Changeset 7221 in orxonox.OLD for trunk/src/lib/util/executor/executor.h
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.h
r7200 r7221 16 16 //! an enumerator for the definition of the Type. 17 17 typedef enum { 18 Executor_Objective = 0x00000001,19 Executor_Static = 0x00000002,20 21 Executor_NoLoadString = 0x00000010,18 Executor_Objective = 1, 19 Executor_Static = 2, 20 21 Executor_NoLoadString = 8, 22 22 } Executor_Type; 23 23 … … 48 48 49 49 /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */ 50 virtual void execute (BaseObject* object, const void* parameters = NULL) = 0;50 virtual void execute (BaseObject* object, const std::string& parameters = "") = 0; 51 51 52 52 /** @returns the Type of this Function (either static or objective) */ … … 87 87 #define l_FLOAT_DEFGRAB(i) this->defaultValue[i].getFloat() 88 88 //! where to chek for default STRING values 89 #define l_STRING_DEFGRAB(i) this->defaultValue[i].getString() 90 //! where to chek for default CSTRING values 89 91 #define l_CSTRING_DEFGRAB(i) this->defaultValue[i].getCString() 90 92 … … 190 192 #define ExecutorExecute1(t1) \ 191 193 else if (this->paramCount == 1 && this->defaultValue[0] == t1##_PARAM) \ 192 EXECUTOREXECUTER(_1_##t1)(t1##_FUNC( (const char*)parameters, t1##_DEFGRAB(0)))194 EXECUTOREXECUTER(_1_##t1)(t1##_FUNC(sub[0], t1##_DEFGRAB(0))) 193 195 194 196 //! execute-macro for functions with two parameters 195 197 #define ExecutorExecute2(t1,t2) \ 196 198 else if (this->paramCount == 2 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM) \ 197 EXECUTOREXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub .getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))199 EXECUTOREXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1))) 198 200 199 201 //! execute-macro for functions with three parameters 200 202 #define ExecutorExecute3(t1,t2,t3) \ 201 203 else if (this->paramCount == 3 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM) \ 202 EXECUTOREXECUTER(_3_##t1##_##t2##_##t3)(t1##_FUNC(sub .getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)))204 EXECUTOREXECUTER(_3_##t1##_##t2##_##t3)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)), t3##_FUNC(sub[2], t3##_DEFGRAB(2))) 203 205 204 206 //! execute-macro for functions with four parameters 205 207 #define ExecutorExecute4(t1,t2,t3,t4) \ 206 208 else if (this->paramCount == 4 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM && this->defaultValue[3] == t4##_PARAM) \ 207 EXECUTOREXECUTER(_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub .getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3))) \209 EXECUTOREXECUTER(_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)), t3##_FUNC(sub[2], t3##_DEFGRAB(2)), t4##_FUNC(sub[3], t4##_DEFGRAB(3))) \ 208 210 209 211 … … 211 213 #define ExecutorExecute5(t1,t2,t3,t4,t5) \ 212 214 else if (this->paramCount == 5 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM && this->defaultValue[3] == t4##_PARAM && this->defaultValue[4] == t5##_PARAM) \ 213 EXECUTOREXECUTER(_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_FUNC(sub .getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3)), t5##_FUNC(sub.getString(4), t5##_DEFGRAB(4)))215 EXECUTOREXECUTER(_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_FUNC(sub[0], t1##_DEFGRAB(0)), t2##_FUNC(sub[1], t2##_DEFGRAB(1)), t3##_FUNC(sub[2], t3##_DEFGRAB(2)), t4##_FUNC(sub[3], t4##_DEFGRAB(3)), t5##_FUNC(sub[4], t5##_DEFGRAB(4))) 214 216 215 217 … … 240 242 #define EXECUTORTYPE Executor_Objective 241 243 //! keeps information about a Executor 242 template<class T> class E xecutorObjective: public Executor244 template<class T> class EXECUTOR : public Executor 243 245 { 244 246 public: 245 E xecutorObjective() : Executor() { };247 EXECUTOR() : Executor() { }; 246 248 // COPY constuctor (virtual version) 247 249 virtual Executor* clone () const 248 250 { 249 E xecutorObjective<T>* executor = new ExecutorObjective<T>();251 EXECUTOR<T>* executor = new EXECUTOR<T>(); 250 252 this->cloning(executor); 251 253 executor->fp = this->fp; … … 266 268 } fp; 267 269 268 virtual void execute (BaseObject* object, const void* parameters = NULL)270 virtual void execute (BaseObject* object, const std::string& parameters = "") 269 271 { 270 SubString sub ((const char*) parameters, " \n\t,", '\\');271 printf("%s :: %s\n", this->getName(), (const char*) parameters);272 SubString sub; 273 sub.split(parameters, " \n\t,", '\\'); 272 274 //! FUNCTOR_LIST is the List of Executive Functions 273 275 #define FUNCTOR_LIST(x) ExecutorExecute ## x … … 305 307 { 306 308 public: 307 E xecutorStatic() : Executor() { };309 EXECUTOR() : Executor() { }; 308 310 // COPY constuctor 309 311 virtual Executor* clone () const 310 312 { 311 E xecutorStatic<T>* executor = new ExecutorStatic<T>();313 EXECUTOR<T>* executor = new EXECUTOR<T>(); 312 314 this->cloning(executor); 313 315 executor->fp = this->fp; … … 329 331 330 332 331 virtual void execute (BaseObject* object, const void* parameters = NULL)333 virtual void execute (BaseObject* object, const std::string& parameters = "") 332 334 { 333 SubString sub((const char*)parameters, " \n\t,"); 335 SubString sub; 336 sub.split(parameters, " \n\t,", '\\'); 334 337 //! FUNCTOR_LIST is the List of Executive Functions 335 338 #define FUNCTOR_LIST(x) ExecutorExecute ## x
Note: See TracChangeset
for help on using the changeset viewer.