![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 #ifndef __SRA_SUPPORT_TIMER_H 00002 #define __SRA_SUPPORT_TIMER_H 00003 00004 #include <boost/timer.hpp> 00005 #include <boost/thread/thread.hpp> 00006 00007 namespace Support 00008 { 00015 class Timer : public boost::timer 00016 { 00017 double _targetTimeInSeconds; 00018 00019 public: 00020 Timer() : _targetTimeInSeconds(0) { } 00021 Timer(double targetTimeInSeconds) : _targetTimeInSeconds(targetTimeInSeconds) { } 00022 00026 INLINE void restart(double targetTimeInSeconds) 00027 { 00028 _targetTimeInSeconds = targetTimeInSeconds; 00029 boost::timer::restart(); 00030 } 00031 00035 INLINE void restart() 00036 { 00037 boost::timer::restart(); 00038 } 00039 00043 INLINE bool isTargetTimeElapsed() 00044 { 00045 if(elapsed() <= _targetTimeInSeconds) 00046 return false; 00047 else 00048 return true; 00049 } 00050 00054 bool operator==(const Timer& rhs) 00055 { 00056 if((_targetTimeInSeconds == rhs._targetTimeInSeconds) && (_start_time == rhs._start_time)) 00057 return true; 00058 else 00059 return false; 00060 } 00061 }; 00062 } 00063 00064 #endif 00065
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.