Changeset 7724 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- May 19, 2006, 4:41:01 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor_functional.h
r7722 r7724 51 51 #endif /* __EXECUTOR_FUNCTIONAL_H_ */ 52 52 53 53 //! if Functional is constant calling 54 54 #define __EXECUTOR_FUNCTIONAL_CONST 55 //! The Name to be attached to the functional (for normal, static, and const modes) 55 56 #define __EXECUTOR_FUNCTIONAL_NAME(ParamCount) Executor##ParamCount##Params 57 //! The Execution-mode (either static or objective) 56 58 #define __EXECUTOR_FUNCTIONAL_FUNCTION_EXEC dynamic_cast<T*>(object)->*(functionPointer) 59 //! The Function-Pointer, and how to save it internally. 57 60 #define __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER T::*functionPointer 58 61 … … 80 83 #endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */ 81 84 85 //! @brief ExecutorClass, that can execute Functions without any parameters. 82 86 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor 83 87 { 84 88 private: 89 /** @brief the FunctioPointer. */ 85 90 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST; 86 91 87 92 public: 93 /** 94 * @brief constructs the Executor. 95 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 96 */ 88 97 __EXECUTOR_FUNCTIONAL_NAME(0) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST ) 89 98 : Executor() … … 93 102 }; 94 103 104 /** 105 * @brief executes the Functional 106 * @param object the Object the action should be executed on. 107 * @param sub the SubString to get the Parameters from. 108 */ 95 109 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 96 110 { … … 98 112 }; 99 113 114 /** 115 * @brief copies the Executor 116 * @returns a new Executor that's a copy of this one. 117 */ 100 118 virtual Executor* clone() const 101 119 { … … 104 122 }; 105 123 106 //! SINGLE VALUE124 //! @brief ExecutorClass, that can execute Functions with one parameter. 107 125 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor 108 126 { 109 127 private: 128 /** @brief the FunctioPointer. */ 110 129 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST; 111 130 112 131 public: 132 /** 133 * @brief constructs the Executor. 134 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 135 */ 113 136 __EXECUTOR_FUNCTIONAL_NAME(1) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0) __EXECUTOR_FUNCTIONAL_CONST) 114 137 : Executor(ExecutorParamType<type0>()) … … 118 141 }; 119 142 143 /** 144 * @brief executes the Functional 145 * @param object the Object the action should be executed on. 146 * @param sub the SubString to get the Parameters from. 147 */ 120 148 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 121 149 { … … 130 158 }; 131 159 160 /** 161 * @brief copies the Executor 162 * @returns a new Executor that's a copy of this one. 163 */ 132 164 virtual Executor* clone() const 133 165 { … … 136 168 }; 137 169 138 //! DOUBLE VALUE170 //! @brief ExecutorClass, that can execute Functions with two parameters. 139 171 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor 140 172 { 141 173 private: 174 /** @brief the FunctioPointer. */ 142 175 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST; 143 176 144 177 public: 178 /** 179 * @brief constructs the Executor. 180 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 181 */ 145 182 __EXECUTOR_FUNCTIONAL_NAME(2) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1) __EXECUTOR_FUNCTIONAL_CONST) 146 183 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>()) … … 150 187 }; 151 188 189 /** 190 * @brief executes the Functional 191 * @param object the Object the action should be executed on. 192 * @param sub the SubString to get the Parameters from. 193 */ 152 194 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 153 195 { … … 157 199 }; 158 200 201 /** 202 * @brief copies the Executor 203 * @returns a new Executor that's a copy of this one. 204 */ 159 205 virtual Executor* clone() const 160 206 { … … 164 210 165 211 166 //! TRIPPLE VALUE212 //! @brief ExecutorClass, that can execute Functions with three parameters. 167 213 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor 168 214 { 169 215 private: 216 /** @brief the FunctioPointer. */ 170 217 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST; 171 218 172 219 public: 220 /** 221 * @brief constructs the Executor. 222 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 223 */ 173 224 __EXECUTOR_FUNCTIONAL_NAME(3) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2) __EXECUTOR_FUNCTIONAL_CONST) 174 225 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) … … 178 229 }; 179 230 231 /** 232 * @brief executes the Functional 233 * @param object the Object the action should be executed on. 234 * @param sub the SubString to get the Parameters from. 235 */ 180 236 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 181 237 { … … 186 242 }; 187 243 244 /** 245 * @brief copies the Executor 246 * @returns a new Executor that's a copy of this one. 247 */ 188 248 virtual Executor* clone() const 189 249 { … … 194 254 195 255 196 //! QUADRUPPEL VALUE256 //! @brief ExecutorClass, that can execute Functions with four parameters. 197 257 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor 198 258 { 199 259 private: 260 /** @brief the FunctioPointer. */ 200 261 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST; 201 262 202 263 public: 264 /** 265 * @brief constructs the Executor. 266 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 267 */ 203 268 __EXECUTOR_FUNCTIONAL_NAME(4) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3) __EXECUTOR_FUNCTIONAL_CONST) 204 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 205 { 206 this->functorType = Executor_Objective; 207 this->functionPointer = functionPointer; 208 }; 209 269 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 270 { 271 this->functorType = Executor_Objective; 272 this->functionPointer = functionPointer; 273 }; 274 275 /** 276 * @brief executes the Functional 277 * @param object the Object the action should be executed on. 278 * @param sub the SubString to get the Parameters from. 279 */ 210 280 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 211 281 { … … 217 287 }; 218 288 289 /** 290 * @brief copies the Executor 291 * @returns a new Executor that's a copy of this one. 292 */ 219 293 virtual Executor* clone() const 220 294 { … … 223 297 }; 224 298 225 //! CHINQUE VALUE299 //! @brief ExecutorClass, that can execute Functions with five parameters. 226 300 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor 227 301 { 228 private: 229 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST; 230 231 public: 232 __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) 233 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 234 { 235 this->functorType = Executor_Objective; 236 this->functionPointer = functionPointer; 237 }; 238 239 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 240 { 241 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 242 fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)), 302 private: 303 /** @brief the FunctioPointer. */ 304 void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST; 305 306 public: 307 /** 308 * @brief constructs the Executor. 309 * @param __EXECUTOR_FUNCTIONAL_FUNCTION_POINTER the FunctionPointer to the Calling Function. 310 */ 311 __EXECUTOR_FUNCTIONAL_NAME(5) (void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0, type1, type2, type3, type4) __EXECUTOR_FUNCTIONAL_CONST) 312 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 313 { 314 this->functorType = Executor_Objective; 315 this->functionPointer = functionPointer; 316 }; 317 318 /** 319 * @brief executes the Functional 320 * @param object the Object the action should be executed on. 321 * @param sub the SubString to get the Parameters from. 322 */ 323 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 324 { 325 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 326 fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)), 243 327 fromString<type1>(sub[1], getDefault<type1>(this->defaultValue, 1)), 244 328 fromString<type2>(sub[2], getDefault<type2>(this->defaultValue, 2)), 245 329 fromString<type3>(sub[3], getDefault<type3>(this->defaultValue, 3)), 246 330 fromString<type4>(sub[4], getDefault<type4>(this->defaultValue, 4))); 247 }; 248 249 virtual Executor* clone() const 250 { 251 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer); 252 }; 253 }; 254 255 256 331 }; 332 333 /** 334 * @brief copies the Executor 335 * @returns a new Executor that's a copy of this one. 336 */ 337 virtual Executor* clone() const 338 { 339 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0, type1, type2, type3, type4>(this->functionPointer); 340 }; 341 }; 342 343 344 345 /** 346 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 347 */ 257 348 #define EXECUTOR_FUNCTIONAL_CREATOR0() \ 258 349 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ … … 261 352 } 262 353 354 /** 355 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 356 * @param type0 for internal usage: the first Argument 357 */ 263 358 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \ 264 359 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ … … 267 362 } 268 363 364 /** 365 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 366 * @param type0 for internal usage: the first Argument 367 * @param type1 for internal usage: the second Argument 368 */ 269 369 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \ 270 370 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ … … 273 373 } 274 374 375 /** 376 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 377 * @param type0 for internal usage: the first Argument 378 * @param type1 for internal usage: the second Argument 379 * @param type2 for internal usage: the third Argument 380 */ 275 381 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \ 276 382 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ … … 279 385 } 280 386 387 /** 388 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 389 * @param type0 for internal usage: the first Argument 390 * @param type1 for internal usage: the second Argument 391 * @param type2 for internal usage: the third Argument 392 * @param type3 for internal usage: the fourth Argument 393 */ 281 394 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \ 282 395 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ … … 285 398 } 286 399 400 /** 401 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 402 * @param type0 for internal usage: the first Argument 403 * @param type1 for internal usage: the second Argument 404 * @param type2 for internal usage: the third Argument 405 * @param type3 for internal usage: the fourth Argument 406 * @param type4 for internal usage: the fifth Argument 407 */ 287 408 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \ 288 409 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ … … 292 413 293 414 294 415 /** 416 * Creates the FunctionCallers 417 */ 295 418 #define FUNCTOR_LIST(x) EXECUTOR_FUNCTIONAL_CREATOR ## x 296 419 #include "functor_list.h"
Note: See TracChangeset
for help on using the changeset viewer.