Changeset 5935 for code/branches/pickup/src/libraries/tools/Timer.cc
- Timestamp:
- Oct 13, 2009, 5:05:17 PM (15 years ago)
- Location:
- code/branches/pickup
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup
- Property svn:mergeinfo changed
-
code/branches/pickup/src/libraries/tools/Timer.cc
r5781 r5935 31 31 #include <set> 32 32 33 #include "util/Clock.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/ConsoleCommand.h" 35 36 #include "core/CommandExecutor.h" 36 #include "core/Clock.h"37 37 #include "core/Functor.h" 38 38 … … 42 42 SetConsoleCommandShortcutExtern(killdelays); 43 43 44 static std::set< StaticTimer*> delaytimerset;44 static std::set<Timer*> delaytimerset; 45 45 46 46 /** … … 51 51 void delay(float delay, const std::string& command) 52 52 { 53 StaticTimer *delaytimer = new StaticTimer();53 Timer* delaytimer = new Timer(); 54 54 delaytimerset.insert(delaytimer); 55 55 … … 64 64 @param command The command to execute 65 65 */ 66 void executeDelayedCommand( StaticTimer* timer, const std::string& command)66 void executeDelayedCommand(Timer* timer, const std::string& command) 67 67 { 68 68 CommandExecutor::execute(command); 69 delete timer;69 timer->destroy(); 70 70 delaytimerset.erase(timer); 71 71 } … … 76 76 void killdelays() 77 77 { 78 for (std::set< StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)79 delete (*it);78 for (std::set<Timer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it) 79 (*it)->destroy(); 80 80 81 81 delaytimerset.clear(); … … 85 85 @brief Constructor: Sets the default-values. 86 86 */ 87 TimerBase::TimerBase() 87 Timer::Timer() 88 { 89 this->init(); 90 RegisterObject(Timer); 91 } 92 93 /** 94 @brief Constructor: Initializes the Timer with given values. 95 @param interval The timer-interval in seconds 96 @param bLoop If true, the function gets called every 'interval' seconds 97 @param exeuctor A executor of the function to call 98 */ 99 Timer::Timer(float interval, bool bLoop, Executor* executor, bool bKillAfterCall) 100 { 101 this->init(); 102 RegisterObject(Timer); 103 104 this->setTimer(interval, bLoop, executor, bKillAfterCall); 105 } 106 107 /** 108 @brief Deletes the executor. 109 */ 110 Timer::~Timer() 111 { 112 this->deleteExecutor(); 113 } 114 115 /** 116 @brief Initializes the Timer 117 */ 118 void Timer::init() 88 119 { 89 120 this->executor_ = 0; … … 94 125 95 126 this->time_ = 0; 96 97 RegisterObject(TimerBase);98 }99 100 /**101 @brief Deletes the executor.102 */103 TimerBase::~TimerBase()104 {105 this->deleteExecutor();106 127 } 107 128 … … 109 130 @brief Executes the executor. 110 131 */ 111 void Timer Base::run() const132 void Timer::run() 112 133 { 113 134 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer … … 116 137 117 138 if (temp) 118 delete this;139 this->destroy(); 119 140 } 120 141 … … 122 143 @brief Deletes the executor. 123 144 */ 124 void Timer Base::deleteExecutor()145 void Timer::deleteExecutor() 125 146 { 126 147 if (this->executor_) … … 131 152 @brief Updates the timer before the frames are rendered. 132 153 */ 133 void Timer Base::tick(const Clock& time)154 void Timer::tick(const Clock& time) 134 155 { 135 156 if (this->bActive_)
Note: See TracChangeset
for help on using the changeset viewer.