Changeset 7221 in orxonox.OLD for trunk/src/lib/util/executor
- Timestamp:
- Mar 15, 2006, 3:10:45 PM (19 years ago)
- Location:
- trunk/src/lib/util/executor
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.cc
r7201 r7221 105 105 value[4] = &value4; 106 106 107 printf("%s ::: paramCount: %d\n", this->getName(), this->paramCount);108 107 for (unsigned int i = 0; i < this->paramCount; i++) 109 108 { 110 109 if (*value[i] != MT_NULL) 111 110 { 112 printf("1:::: %d : %s \n",i, MultiType::MultiTypeToString(this->defaultValue[i].getType())); 113 114 this->defaultValue[i].debug(); 115 //this->defaultValue[i].setValueOf(*value[i]); 116 //printf("2::::%s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType())); 117 //this->defaultValue[i].debug(); 118 //this->defaultValue[i].setValueOf(*value[i]); 111 this->defaultValue[i].setValueOf(*value[i]); 119 112 } 120 113 } -
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 -
trunk/src/lib/util/executor/executor_specials.h
r7197 r7221 60 60 * @param loadString ignored in this case 61 61 */ 62 virtual void execute(BaseObject* object, const void* parameters = NULL)62 virtual void execute(BaseObject* object, const std::string& = "") 63 63 { 64 64 if (object != NULL && this->element != NULL) -
trunk/src/lib/util/executor/functor_list.h
r7199 r7221 21 21 l_SHORT: short 22 22 l_FLOAT: float 23 l_ CSTRING: const char*23 l_STRING: const std::string& 24 24 l_XML_ELEM: TiXmlElement* 25 25 */ … … 74 74 //#define l_VECTOR_DEFAULT Vector(0,0,0) //!< Default value for a VECTOR 75 75 76 #define l_CSTRING_TYPE const char* //!< The type of a STRING77 #define l_CSTRING_FUNC isString //!< The function to parse a STRING78 #define l_CSTRING_NAME "string" //!< The name of a STRING79 #define l_CSTRING_PARAM MT_STRING //!< the type of the parameter STRING80 #define l_CSTRING_DEFAULT "" //!< a default Value for an STRING81 82 76 #define l_STRING_TYPE const std::string& //!< The type of a STRING 83 77 #define l_STRING_FUNC isString //!< The function to parse a STRING 84 78 #define l_STRING_NAME "string" //!< The name of a STRING 85 #define l_STRING_PARAM MT_STRING 79 #define l_STRING_PARAM MT_STRING //!< the type of the parameter STRING 86 80 #define l_STRING_DEFAULT "" //!< a default Value for an STRING 87 81 … … 99 93 FUNCTOR_LIST(0)(); 100 94 //! makes functions with one string 101 FUNCTOR_LIST(1)(l_ CSTRING);95 FUNCTOR_LIST(1)(l_STRING); 102 96 //! makes functions with two strings 103 FUNCTOR_LIST(2)(l_ CSTRING, l_CSTRING);97 FUNCTOR_LIST(2)(l_STRING, l_STRING); 104 98 //! makes functions with three strings 105 FUNCTOR_LIST(3)(l_ CSTRING, l_CSTRING, l_CSTRING);99 FUNCTOR_LIST(3)(l_STRING, l_STRING, l_STRING); 106 100 //! makes functions with four strings 107 FUNCTOR_LIST(4)(l_CSTRING, l_CSTRING, l_CSTRING, l_CSTRING); 101 FUNCTOR_LIST(4)(l_STRING, l_STRING, l_STRING, l_STRING); 102 108 103 109 104 //! makes functions with one bool … … 141 136 142 137 //! mixed values: 143 FUNCTOR_LIST(2)(l_ CSTRING, l_FLOAT);138 FUNCTOR_LIST(2)(l_STRING, l_FLOAT); 144 139 FUNCTOR_LIST(2)(l_UINT, l_LONG); 145 FUNCTOR_LIST(2)(l_ CSTRING, l_UINT);140 FUNCTOR_LIST(2)(l_STRING, l_UINT); 146 141 147 FUNCTOR_LIST(3)(l_ CSTRING, l_FLOAT, l_UINT);142 FUNCTOR_LIST(3)(l_STRING, l_FLOAT, l_UINT); 148 143 149 144
Note: See TracChangeset
for help on using the changeset viewer.