SGL
gtimer.h
1 /*
2  * File: gtimer.h
3  * --------------
4  * This file defines the <code>GTimer</code> class, which implements a
5  * general interval timer.
6  *
7  * @version 2021/04/09
8  * - added sgl namespace
9  * @version 2019/01/23
10  * - added destructor
11  * @version 2018/09/09
12  * - updated to use new Qt GUI timer interface
13  * - added doc comments for new documentation generation
14  */
15 
16 
17 #ifndef _gtimer_h
18 #define _gtimer_h
19 
20 #include <string>
21 
22 namespace sgl {
23 
28 class GTimer {
29 public:
41  GTimer(double milliseconds);
42 
46  ~GTimer();
47 
51  double getDelay() const;
52 
61  bool isStarted() const;
62 
66  void restart();
67 
75  void setDelay(double ms);
76 
83  void start();
84 
88  void stop();
89 
90 private:
91  double _ms;
92  int _id;
93 };
94 
95 } // namespace sgl
96 
97 #endif // _gtimer_h
Definition: console.h:45
GTimer(double milliseconds)
Creates a timer object that generates a GTimerEvent each time the specified number of milliseconds ha...
Definition: gtimer.cpp:28
This class implements a simple interval timer that generates a GTimerEvent with a specified frequency...
Definition: gtimer.h:28
void start()
Starts the timer.
Definition: gtimer.cpp:59
bool isStarted() const
Method: isStarted Usage: if (timer.isStarted()) { ...
Definition: gtimer.cpp:42
double getDelay() const
Returns the delay in milliseconds between each tick of this timer.
Definition: gtimer.cpp:38
void setDelay(double ms)
Changes the delay in milliseconds between each tick of this timer.
Definition: gtimer.cpp:51
void restart()
Stops the timer (if it was started) and then starts it again.
Definition: gtimer.cpp:46
void stop()
Stops the timer so that it stops generating events until it is restarted.
Definition: gtimer.cpp:70
~GTimer()
Destroys the timer, stopping it if it&#39;s currently running.
Definition: gtimer.cpp:34