GameKit  0.0.1a
C++ gamedev tools
Timer.hpp
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: Timer.hpp
5  *
6  * Description:
7  *
8  * Created: 15/09/2014 19:31:28
9  *
10  * Author: Quentin Bazin, <gnidmoo@gmail.com>
11  *
12  * =====================================================================================
13  */
14 #ifndef GK_TIMER_HPP_
15 #define GK_TIMER_HPP_
16 
17 #include "gk/core/IntTypes.hpp"
18 
19 namespace gk {
20 
25 class Timer {
26  public:
33  Timer(bool useRealTime = false);
34 
39  void stop();
40 
45  void start();
46 
51  void reset();
52 
59  u32 time() const;
60 
67  void setTime(u32 time);
68 
75  bool isStarted() const { return m_isStarted; }
76 
77  private:
79  // Member data
81  bool m_useRealTime = false;
82 
83  bool m_isStarted = false;
84 
85  u32 m_t = 0;
86  u32 m_tick = 0;
87 };
88 
89 } // namespace gk
90 
91 #endif // GK_TIMER_HPP_
92 
void start()
Start the timer.
Definition: Timer.cpp:31
void setTime(u32 time)
Set time.
Definition: Timer.cpp:52
void stop()
Stop the timer.
Definition: Timer.cpp:24
u32 m_t
Definition: Timer.hpp:85
void reset()
Reset the timer.
Definition: Timer.cpp:38
unsigned int u32
Definition: IntTypes.hpp:23
bool m_useRealTime
The timer will use system time instead of simulated time if set to true.
Definition: Timer.hpp:81
bool m_isStarted
Is true if the timer is running.
Definition: Timer.hpp:83
u32 time() const
Get time.
Definition: Timer.cpp:44
bool isStarted() const
Check if the timer is started.
Definition: Timer.hpp:75
Very basic timer.
Definition: Timer.hpp:25
Timer(bool useRealTime=false)
Constructor.
Definition: Timer.cpp:19
u32 m_tick
Definition: Timer.hpp:86