-
-
Notifications
You must be signed in to change notification settings - Fork 112
/
clock.h
46 lines (38 loc) · 898 Bytes
/
clock.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include "stdafx.h"
#include "extern/optional.h"
class Clock {
public:
Clock(bool neverPause = false);
milliseconds getMillis();
void pause();
void cont();
bool isPaused();
static milliseconds getRealMillis();
static microseconds getRealMicros();
static int getCurrentMonth();
static int getCurrentDayOfMonth();
private:
steady_clock::time_point getCurrent();
steady_clock::time_point pausedTime;
optional<steady_clock::time_point> lastPause;
steady_clock::time_point initTime;
bool neverPause = false;
};
class ScopeTimer {
public:
ScopeTimer(const char* msg);
~ScopeTimer();
private:
const char* message;
Clock clock;
};
class Intervalometer {
public:
Intervalometer(milliseconds frequency);
int getCount(milliseconds currentTime);
void clear();
private:
milliseconds frequency;
optional<milliseconds> lastUpdate;
};