Changeset 8035 in orxonox.OLD for trunk/src/lib/util/executor/executor_functional.h
- Timestamp:
- May 31, 2006, 4:20:51 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor_functional.h
r7725 r8035 33 33 template<> MT_Type ExecutorParamType<const std::string&>(); 34 34 35 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };35 template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; }; 36 36 template<> bool fromString<bool>(const std::string& input, bool defaultValue); 37 37 template<> int fromString<int>(const std::string& input, int defaultValue); … … 40 40 template<> char fromString<char>(const std::string& input, char defaultValue); 41 41 template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue); 42 43 template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ }; 44 template<> bool fromMulti<bool>(const MultiType& multi); 45 template<> int fromMulti<int>(const MultiType& multi); 46 template<> unsigned int fromMulti<unsigned int>(const MultiType& multi); 47 template<> float fromMulti<float>(const MultiType& multi); 48 template<> char fromMulti<char>(const MultiType& multi); 49 template<> const std::string& fromMulti<const std::string&>(const MultiType& multi); 50 42 51 43 52 template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; }; … … 81 90 #endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */ 82 91 92 /////////// 93 //// 0 //// 94 /////////// 83 95 //! @brief ExecutorClass, that can execute Functions without any parameters. 84 96 template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor … … 110 122 }; 111 123 124 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 125 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 126 { 127 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(); 128 } 129 112 130 /** 113 131 * @brief copies the Executor … … 120 138 }; 121 139 140 141 142 /////////// 143 //// 1 //// 144 /////////// 122 145 //! @brief ExecutorClass, that can execute Functions with one parameter. 123 146 template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor … … 139 162 }; 140 163 164 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 165 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 166 { 167 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 168 fromMulti<type0>((count > 0)? values[0] : this->defaultValue[0]) ); 169 } 170 171 141 172 /** 142 173 * @brief executes the Functional … … 146 177 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 147 178 { 148 149 /* // THE VERY COOL DEBUG150 printf("SUB[0] : %s\n", sub[0].c_str());151 printf("getDefault<type0>(this->defaultValue, 0):::: %d\n", getDefault<type0>(this->defaultValue, 0));152 printf("VALUE: %d\n", fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)));153 */154 179 (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 155 180 fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) ); … … 166 191 }; 167 192 193 /////////// 194 //// 2 //// 195 /////////// 168 196 //! @brief ExecutorClass, that can execute Functions with two parameters. 169 197 template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor … … 197 225 }; 198 226 227 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 228 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 229 { 230 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 231 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 232 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]) ); 233 } 234 199 235 /** 200 236 * @brief copies the Executor … … 208 244 209 245 246 /////////// 247 //// 3 //// 248 /////////// 210 249 //! @brief ExecutorClass, that can execute Functions with three parameters. 211 250 template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor … … 240 279 }; 241 280 281 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 282 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 283 { 284 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 285 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 286 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 287 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]) ); 288 } 289 242 290 /** 243 291 * @brief copies the Executor … … 252 300 253 301 302 /////////// 303 //// 4 //// 304 /////////// 254 305 //! @brief ExecutorClass, that can execute Functions with four parameters. 255 306 template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor … … 285 336 }; 286 337 338 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 339 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 340 { 341 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 342 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 343 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 344 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]), 345 fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]) ); 346 } 347 287 348 /** 288 349 * @brief copies the Executor … … 295 356 }; 296 357 358 359 360 /////////// 361 //// 5 //// 362 /////////// 297 363 //! @brief ExecutorClass, that can execute Functions with five parameters. 298 364 template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor … … 329 395 }; 330 396 397 /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */ 398 virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const 399 { 400 return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)( 401 fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]), 402 fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]), 403 fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]), 404 fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]), 405 fromMulti<type4>((count > 4) ? values[4] : this->defaultValue[4]) ); 406 } 407 331 408 /** 332 409 * @brief copies the Executor … … 344 421 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all) 345 422 */ 346 #define EXECUTOR_FUNCTIONAL_CREATOR0( ) \347 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \423 #define EXECUTOR_FUNCTIONAL_CREATOR0(ret) \ 424 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \ 348 425 { \ 349 426 return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \ … … 354 431 * @param type0 for internal usage: the first Argument 355 432 */ 356 #define EXECUTOR_FUNCTIONAL_CREATOR1( type0) \357 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \433 #define EXECUTOR_FUNCTIONAL_CREATOR1(ret, type0) \ 434 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 358 435 { \ 359 436 return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \ … … 365 442 * @param type1 for internal usage: the second Argument 366 443 */ 367 #define EXECUTOR_FUNCTIONAL_CREATOR2( type0, type1) \368 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \444 #define EXECUTOR_FUNCTIONAL_CREATOR2(ret, type0, type1) \ 445 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 369 446 { \ 370 447 return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \ … … 377 454 * @param type2 for internal usage: the third Argument 378 455 */ 379 #define EXECUTOR_FUNCTIONAL_CREATOR3( type0, type1, type2) \380 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \456 #define EXECUTOR_FUNCTIONAL_CREATOR3(ret, type0, type1, type2) \ 457 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 381 458 { \ 382 459 return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \ … … 390 467 * @param type3 for internal usage: the fourth Argument 391 468 */ 392 #define EXECUTOR_FUNCTIONAL_CREATOR4( type0, type1, type2, type3) \393 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \469 #define EXECUTOR_FUNCTIONAL_CREATOR4(ret, type0, type1, type2, type3) \ 470 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 394 471 { \ 395 472 return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \ … … 404 481 * @param type4 for internal usage: the fifth Argument 405 482 */ 406 #define EXECUTOR_FUNCTIONAL_CREATOR5( type0, type1, type2, type3, type4) \407 template<class T> Executor* createExecutor( void(__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \483 #define EXECUTOR_FUNCTIONAL_CREATOR5(ret, type0, type1, type2, type3, type4) \ 484 template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \ 408 485 { \ 409 486 return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \
Note: See TracChangeset
for help on using the changeset viewer.