- Timestamp:
- May 19, 2006, 1:48:12 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/orxonox.cc
r7714 r7715 444 444 template<class T> class Executor0Params : public Executor 445 445 { 446 447 448 449 450 451 : Executor()452 453 454 455 456 457 458 459 460 461 446 private: 447 void (T::*functionPointer)(); 448 449 public: 450 Executor0Params (void (T::*functionPointer)()) 451 : Executor() 452 { 453 this->functorType = Executor_Objective; 454 this->functionPointer = functionPointer; 455 } 456 virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const 457 { 458 (dynamic_cast<T*>(object)->*functionPointer)(); 459 }; 460 461 Executor* clone() const {}; 462 462 }; 463 463 … … 512 512 }; 513 513 514 515 template<class T> Executor* createExecutor(void (T::*functionPointer)()) 516 { 517 return new Executor0Params<T>(functionPointer); 518 } 519 template<class T> Executor* createExecutor(void (T::*functionPointer)(bool)) 520 { 521 return new Executor1Params<T, bool>(functionPointer); 522 } 523 template<class T> Executor* createExecutor(void (T::*functionPointer)(int)) 524 { 525 return new Executor1Params<T, int>(functionPointer); 526 } 527 template<class T> Executor* createExecutor(void (T::*functionPointer)(bool, int)) 528 { 529 return new Executor2Params<T, bool, int>(functionPointer); 530 } 531 532 514 533 class TestClass : public BaseObject 515 534 { … … 527 546 TestClass test; 528 547 SubString testStrings("1, 2, 3", ",", SubString::WhiteSpaces, false); 529 ( Executor0Params<TestClass>(&TestClass::printTest))(&test, testStrings);530 ( Executor1Params<TestClass,int>(&TestClass::printTestInt))(&test, testStrings);531 ( Executor1Params<TestClass,bool>(&TestClass::printTestBool))(&test, testStrings);532 ( Executor2Params<TestClass,bool, int>(&TestClass::printTwoVals))(&test, testStrings);548 (*createExecutor(&TestClass::printTest))(&test, testStrings); 549 (*createExecutor(&TestClass::printTestInt))(&test, testStrings); 550 (*createExecutor(&TestClass::printTestBool))(&test, testStrings); 551 (*createExecutor(&TestClass::printTwoVals))(&test, testStrings); 533 552 534 553 }
Note: See TracChangeset
for help on using the changeset viewer.