Changeset 1052 for code/trunk/src/orxonox/tools/Timer.cc
- Timestamp:
- Apr 14, 2008, 3:42:49 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/tools/Timer.cc
r1039 r1052 27 27 28 28 #include "OrxonoxStableHeaders.h" 29 #include "core/Executor.h" 30 #include "core/CoreIncludes.h" 31 #include "core/ConsoleCommand.h" 32 #include "core/CommandExecutor.h" 29 33 #include "Timer.h" 30 31 #include "core/CoreIncludes.h"32 34 33 35 namespace orxonox 34 36 { 37 ConsoleCommandShortcutExtern(delay, AccessLevel::None); 38 39 /** 40 @brief Calls a console command after 'delay' seconds. 41 @param delay The delay in seconds 42 @param command The console command 43 */ 44 void delay(float delay, const std::string& command) 45 { 46 StaticTimer *delaytimer = new StaticTimer(); 47 ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand)); 48 delayexecutor->setDefaultValues(delaytimer, command); 49 delaytimer->setTimer(delay, false, delayexecutor); 50 } 51 52 /** 53 @brief Executes the command. 54 @param timer The timer to destroy after the command-execution 55 @param command The command to execute 56 */ 57 void executeDelayedCommand(StaticTimer* timer, const std::string& command) 58 { 59 CommandExecutor::execute(command); 60 delete timer; 61 } 62 35 63 /** 36 64 @brief Constructor: Sets the default-values. … … 40 68 RegisterRootObject(TimerBase); 41 69 70 this->executor_ = 0; 42 71 this->interval_ = 0; 43 72 this->bLoop_ = false; … … 45 74 46 75 this->time_ = 0; 76 } 77 78 /** 79 @brief Deletes the executor. 80 */ 81 TimerBase::~TimerBase() 82 { 83 delete this->executor_; 84 } 85 86 /** 87 @brief Executes the executor. 88 */ 89 void TimerBase::run() const 90 { 91 (*this->executor_)(); 47 92 } 48 93
Note: See TracChangeset
for help on using the changeset viewer.