Changeset 8894 in orxonox.OLD for trunk/src/lib/util/executor
- Timestamp:
- Jun 29, 2006, 12:19:48 AM (18 years ago)
- Location:
- trunk/src/lib/util/executor
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/executor/executor.cc
r7742 r8894 31 31 const MultiType& param2, 32 32 const MultiType& param3, 33 const MultiType& param4) 33 const MultiType& param4, 34 const MultiType& param5, 35 const MultiType& param6) 34 36 { 35 37 this->setClassID(CL_EXECUTOR, "Executor"); … … 41 43 this->defaultValue[3] = param3; 42 44 this->defaultValue[4] = param4; 45 this->defaultValue[5] = param5; 46 this->defaultValue[6] = param6; 43 47 44 48 this->paramCount = 0; … … 83 87 const MultiType& value2, 84 88 const MultiType& value3, 85 const MultiType& value4) 89 const MultiType& value4, 90 const MultiType& value5, 91 const MultiType& value6) 86 92 { 87 93 if (this == NULL) … … 94 100 value[3] = &value3; 95 101 value[4] = &value4; 96 102 value[5] = &value5; 103 value[6] = &value6; 97 104 for (unsigned int i = 0; i < this->paramCount; i++) 98 105 { -
trunk/src/lib/util/executor/executor.h
r8408 r8894 47 47 Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL, 48 48 const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL, 49 const MultiType& value4 = MT_NULL); 49 const MultiType& value4 = MT_NULL, const MultiType& param5 = MT_NULL, 50 const MultiType& param6 = MT_NULL); 50 51 /** @param i the i'th defaultValue, @returns reference to the MultiType */ 51 52 inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; }; … … 68 69 Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL, 69 70 const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL, 70 const MultiType& param4 = MT_NULL); 71 const MultiType& param4 = MT_NULL, const MultiType& param5 = MT_NULL, 72 const MultiType& param6 = MT_NULL); 71 73 72 74 void cloning(Executor* executor) const; … … 75 77 short functorType; //!< The type of Function we've got (either static or objective). 76 78 unsigned int paramCount; //!< the count of parameters. 77 MultiType defaultValue[ 5]; //!< Default Values.79 MultiType defaultValue[7]; //!< Default Values. 78 80 }; 79 81 -
trunk/src/lib/util/executor/executor_functional.cc
r8408 r8894 15 15 16 16 #include "executor.h" 17 std::string ExecutorFunctional_returningString_from[ 5];17 std::string ExecutorFunctional_returningString_from[7]; 18 18 19 19 -
trunk/src/lib/util/executor/executor_lua.cc
r8527 r8894 20 20 #include "lunar.h" 21 21 22 std::string temp[ 5];22 std::string temp[7]; 23 23 24 24 template<typename type> type fromLua(lua_State* state, int index) { type *obj = Lunar<type>::check(state, 1); lua_remove(state, 1); return obj;}; -
trunk/src/lib/util/executor/executor_lua.h
r8711 r8894 233 233 234 234 235 /////////// 236 //// 4 //// 237 /////////// 238 //! Executes a Function with a lua_State* parameter. 239 template<class T, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4 : public Executor 240 { 241 public: 242 /** 243 * @brief Constructor of a ExecutorXML 244 * @param function a Function to call 245 */ 246 ExecutorLua4(void(T::*function)(type0, type1, type2, type3)) 247 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 248 { 249 this->functionPointer = function; 250 this->functorType = Executor_Objective | Executor_NoLoadString; 251 } 252 253 /** 254 * @brief executes the Command on BaseObject 255 * @param object the BaseObject to execute this Executor on 256 * @param loadString ignored in this case 257 */ 258 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 259 { 260 PRINTF(1)("no usefull executor\n"); 261 } 262 263 virtual void operator()(BaseObject* object, int& count, void* values) const 264 { 265 lua_State* state = (lua_State*)values; 266 count = 0; 267 268 (dynamic_cast<T*>(object)->*(functionPointer))( 269 fromLua<type0>(state, 1), 270 fromLua<type1>(state, 2), 271 fromLua<type2>(state, 3), 272 fromLua<type3>(state, 4) ); 273 } 274 275 /** 276 * @returns a _new_ Copy of this Executor 277 */ 278 virtual Executor* clone () const 279 { 280 return new ExecutorLua4<T, type0, type1, type2, type3>(this->functionPointer); 281 } 282 private: 283 void (T::*functionPointer)(type0, type1, type2, type3); 284 }; 235 285 236 286 … … 388 438 }; 389 439 440 441 /////////// 442 //// 3 //// 443 /////////// 444 //! Executes a Function with a lua_State* parameter. 445 template<class T, typename ret, typename type0, typename type1, typename type2> class ExecutorLua3ret : public Executor 446 { 447 public: 448 /** 449 * @brief Constructor of a ExecutorXML 450 * @param function a Function to call 451 */ 452 ExecutorLua3ret(ret (T::*function)(type0, type1, type2)) 453 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>()) 454 { 455 this->functionPointer = function; 456 this->functorType = Executor_Objective | Executor_NoLoadString; 457 } 458 459 /** 460 * @brief executes the Command on BaseObject 461 * @param object the BaseObject to execute this Executor on 462 * @param loadString ignored in this case 463 */ 464 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 465 { 466 PRINTF(1)("no usefull executor\n"); 467 } 468 469 virtual void operator()(BaseObject* object, int& count, void* values) const 470 { 471 lua_State* state = (lua_State*)values; 472 count = 1; 473 474 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 475 fromLua<type0>(state, 1), 476 fromLua<type1>(state, 2), 477 fromLua<type2>(state, 3) )); 478 } 479 480 /** 481 * @returns a _new_ Copy of this Executor 482 */ 483 virtual Executor* clone () const 484 { 485 return new ExecutorLua3ret<T, ret, type0, type1, type2>(this->functionPointer); 486 } 487 private: 488 ret (T::*functionPointer)(type0, type1, type2); 489 }; 490 491 492 /////////// 493 //// 4 //// 494 /////////// 495 //! Executes a Function with a lua_State* parameter. 496 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3> class ExecutorLua4ret : public Executor 497 { 498 public: 499 /** 500 * @brief Constructor of a ExecutorXML 501 * @param function a Function to call 502 */ 503 ExecutorLua4ret(ret (T::*function)(type0, type1, type2, type3)) 504 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>()) 505 { 506 this->functionPointer = function; 507 this->functorType = Executor_Objective | Executor_NoLoadString; 508 } 509 510 /** 511 * @brief executes the Command on BaseObject 512 * @param object the BaseObject to execute this Executor on 513 * @param loadString ignored in this case 514 */ 515 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 516 { 517 PRINTF(1)("no usefull executor\n"); 518 } 519 520 virtual void operator()(BaseObject* object, int& count, void* values) const 521 { 522 lua_State* state = (lua_State*)values; 523 count = 1; 524 525 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 526 fromLua<type0>(state, 1), 527 fromLua<type1>(state, 2), 528 fromLua<type2>(state, 3), 529 fromLua<type3>(state, 4) )); 530 } 531 532 /** 533 * @returns a _new_ Copy of this Executor 534 */ 535 virtual Executor* clone () const 536 { 537 return new ExecutorLua4ret<T, ret, type0, type1, type2, type3>(this->functionPointer); 538 } 539 private: 540 ret (T::*functionPointer)(type0, type1, type2, type3); 541 }; 542 543 /////////// 544 //// 5 //// 545 /////////// 546 //! Executes a Function with a lua_State* parameter. 547 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4> class ExecutorLua5ret : public Executor 548 { 549 public: 550 /** 551 * @brief Constructor of a ExecutorXML 552 * @param function a Function to call 553 */ 554 ExecutorLua5ret(ret (T::*function)(type0, type1, type2, type3, type4)) 555 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), ExecutorParamType<type2>(), ExecutorParamType<type3>(), ExecutorParamType<type4>()) 556 { 557 this->functionPointer = function; 558 this->functorType = Executor_Objective | Executor_NoLoadString; 559 } 560 561 /** 562 * @brief executes the Command on BaseObject 563 * @param object the BaseObject to execute this Executor on 564 * @param loadString ignored in this case 565 */ 566 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 567 { 568 PRINTF(1)("no usefull executor\n"); 569 } 570 571 virtual void operator()(BaseObject* object, int& count, void* values) const 572 { 573 lua_State* state = (lua_State*)values; 574 count = 1; 575 576 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 577 fromLua<type0>(state, 1), 578 fromLua<type1>(state, 2), 579 fromLua<type2>(state, 3), 580 fromLua<type3>(state, 4), 581 fromLua<type4>(state, 5) )); 582 } 583 584 /** 585 * @returns a _new_ Copy of this Executor 586 */ 587 virtual Executor* clone () const 588 { 589 return new ExecutorLua5ret<T, ret, type0, type1, type2, type3, type4>(this->functionPointer); 590 } 591 private: 592 ret (T::*functionPointer)(type0, type1, type2, type3, type4); 593 }; 594 595 /////////// 596 //// 6 //// 597 /////////// 598 //! Executes a Function with a lua_State* parameter. 599 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5> class ExecutorLua6ret : public Executor 600 { 601 public: 602 /** 603 * @brief Constructor of a ExecutorXML 604 * @param function a Function to call 605 */ 606 ExecutorLua6ret(ret (T::*function)(type0, type1, type2, type3, type4, type5)) 607 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), 608 ExecutorParamType<type2>(), ExecutorParamType<type3>(), 609 ExecutorParamType<type4>(), ExecutorParamType<type5>()) 610 { 611 this->functionPointer = function; 612 this->functorType = Executor_Objective | Executor_NoLoadString; 613 } 614 615 /** 616 * @brief executes the Command on BaseObject 617 * @param object the BaseObject to execute this Executor on 618 * @param loadString ignored in this case 619 */ 620 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 621 { 622 PRINTF(1)("no usefull executor\n"); 623 } 624 625 virtual void operator()(BaseObject* object, int& count, void* values) const 626 { 627 lua_State* state = (lua_State*)values; 628 count = 1; 629 630 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 631 fromLua<type0>(state, 1), 632 fromLua<type1>(state, 2), 633 fromLua<type2>(state, 3), 634 fromLua<type3>(state, 4), 635 fromLua<type4>(state, 5), 636 fromLua<type5>(state, 6) )); 637 } 638 639 /** 640 * @returns a _new_ Copy of this Executor 641 */ 642 virtual Executor* clone () const 643 { 644 return new ExecutorLua6ret<T, ret, type0, type1, type2, type3, type4, type5>(this->functionPointer); 645 } 646 private: 647 ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5); 648 }; 649 650 /////////// 651 //// 7 //// 652 /////////// 653 //! Executes a Function with a lua_State* parameter. 654 template<class T, typename ret, typename type0, typename type1, typename type2, typename type3, typename type4, typename type5, typename type6> class ExecutorLua7ret : public Executor 655 { 656 public: 657 /** 658 * @brief Constructor of a ExecutorXML 659 * @param function a Function to call 660 */ 661 ExecutorLua7ret(ret (T::*function)(type0, type1, type2, type3, type4, type5, type6)) 662 : Executor(ExecutorParamType<type0>(), ExecutorParamType<type1>(), 663 ExecutorParamType<type2>(), ExecutorParamType<type3>(), 664 ExecutorParamType<type4>(), ExecutorParamType<type5>(), 665 ExecutorParamType<type6>()) 666 { 667 this->functionPointer = function; 668 this->functorType = Executor_Objective | Executor_NoLoadString; 669 } 670 671 /** 672 * @brief executes the Command on BaseObject 673 * @param object the BaseObject to execute this Executor on 674 * @param loadString ignored in this case 675 */ 676 virtual void operator()(BaseObject* object, const SubString& = SubString()) const 677 { 678 PRINTF(1)("no usefull executor\n"); 679 } 680 681 virtual void operator()(BaseObject* object, int& count, void* values) const 682 { 683 lua_State* state = (lua_State*)values; 684 count = 1; 685 686 toLua<ret>(state, (dynamic_cast<T*>(object)->*(functionPointer))( 687 fromLua<type0>(state, 1), 688 fromLua<type1>(state, 2), 689 fromLua<type2>(state, 3), 690 fromLua<type3>(state, 4), 691 fromLua<type4>(state, 5), 692 fromLua<type5>(state, 6), 693 fromLua<type6>(state, 7) )); 694 } 695 696 /** 697 * @returns a _new_ Copy of this Executor 698 */ 699 virtual Executor* clone () const 700 { 701 return new ExecutorLua7ret<T, ret, type0, type1, type2, type3, type4, type5, type6>(this->functionPointer); 702 } 703 private: 704 ret (T::*functionPointer)(type0, type1, type2, type3, type4, type5, type6); 705 }; 706 707 390 708 #endif /* _EXECUTOR_LUA_H */ -
trunk/src/lib/util/executor/functor_list.h
r8619 r8894 29 29 30 30 //! defines the maximum count of arguments function pointers might have 31 #define FUNCTOR_MAX_ARGUMENTS 531 #define FUNCTOR_MAX_ARGUMENTS 7 32 32 #include "multi_type.h" 33 33
Note: See TracChangeset
for help on using the changeset viewer.