summaryrefslogtreecommitdiffhomepage
path: root/Timer.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-04 11:28:20 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-04 11:28:20 +0100
commitb2c35cdf69a9084806ac7930cf4475980d596cf6 (patch)
treeb74b8f2ee2c66c59f7385407cfc34c2a0a16961f /Timer.h
parentaaafcea7e26791acbf5b9612e3fb396edcdfcc8f (diff)
Separate out implementation from headers
Diffstat (limited to 'Timer.h')
-rw-r--r--Timer.h37
1 files changed, 8 insertions, 29 deletions
diff --git a/Timer.h b/Timer.h
index 81192d6..c42db78 100644
--- a/Timer.h
+++ b/Timer.h
@@ -11,39 +11,18 @@ using clock_type = std::chrono::high_resolution_clock;
class Timer
{
public:
- Timer(std::chrono::milliseconds interval, bool cyclic) : m_start_time(clock_type::now()), m_interval(interval), m_running(false), m_cyclic(cyclic)
- {}
+ Timer(std::chrono::milliseconds interval, bool cyclic);
// connect to this signal
boost::signals2::signal<void()> elapsed;
- void start()
- {
- m_running = true;
- m_start_time = clock_type::now();
- }
-
- void stop()
- {
- m_running = false;
- }
-
- bool is_elapsed()
- {
- return m_start_time + m_interval < clock_type::now();
- }
-
- void update()
- {
- if (m_running && is_elapsed()) {
- elapsed();
- if (m_cyclic) {
- start();
- } else {
- stop();
- }
- }
- }
+ void start();
+
+ void stop();
+
+ bool is_elapsed() const;
+
+ void update();
private:
std::chrono::time_point<clock_type> m_start_time;