Changeset 11690 for code/branches/Presentation_HS17/src/libraries
- Timestamp:
- Dec 18, 2017, 12:40:00 PM (7 years ago)
- Location:
- code/branches/Presentation_HS17
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17
- Property svn:mergeinfo changed
/code/branches/Waypoints_HS17 reverse-merged: 11496,11523,11539,11559,11582,11603,11633,11655,11657,11659,11661,11687 /code/branches/ScriptableController_HS17 removed
- Property svn:mergeinfo changed
-
code/branches/Presentation_HS17/src/libraries/core/BaseObject.h
r11686 r11690 58 58 class Gametype; 59 59 class Level; 60 class ScriptableController;61 60 62 61 /// The BaseObject is the parent of all classes representing an instance in the game. … … 192 191 193 192 static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier); 194 195 193 196 194 protected: -
code/branches/Presentation_HS17/src/libraries/tools/Timer.cc
r11686 r11690 158 158 } 159 159 160 Timer::Timer(float interval, bool bLoop, std::function<void ()> func, bool bKillAfterCall)161 {162 this->init();163 RegisterObject(Timer);164 165 this->setTimer(interval, bLoop, func, bKillAfterCall);166 }167 168 160 /** 169 161 @brief Initializes the Timer … … 201 193 this->executor_ = executor; 202 194 this->bActive_ = true; 203 this->isStdFunction_ = false;204 195 205 196 this->time_ = this->interval_; 206 197 this->bKillAfterCall_ = bKillAfterCall; 207 198 208 if(executor != nullptr) 209 executor->getFunctor()->setSafeMode(true); 210 } 211 212 void Timer::setTimer(float interval, bool bLoop, std::function<void ()> func, bool bKillAfterCall) 213 { 214 // Without the cast, the call would be ambiguous, because nullptr is castable to 215 // both, ExecutorPtr and std::function. 216 this->setTimer(interval, bLoop, static_cast<ExecutorPtr>(nullptr), bKillAfterCall); 217 this->function_ = func; 218 this->isStdFunction_ = true; 199 executor->getFunctor()->setSafeMode(true); 219 200 } 220 201 … … 226 207 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer 227 208 228 if(this->isStdFunction_) 229 this->function_(); 230 else 231 (*this->executor_)(); 209 (*this->executor_)(); 232 210 233 211 if (temp) -
code/branches/Presentation_HS17/src/libraries/tools/Timer.h
r11686 r11690 108 108 109 109 Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 110 Timer(float interval, bool bLoop, std::function<void (void)> func, bool bKillAfterCall = false);111 110 112 111 void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 113 void setTimer(float interval, bool bLoop, std::function<void (void)> func, bool bKillAfterCall = false);114 112 115 113 void run(); … … 155 153 156 154 ExecutorPtr executor_; //!< The executor of the function that will be called when the time expires 157 std::function<void (void)> function_;158 155 159 bool isStdFunction_;160 156 long long interval_; //!< The time-interval in micro seconds 161 157 bool bLoop_; //!< If true, the executor gets called every @a interval seconds
Note: See TracChangeset
for help on using the changeset viewer.