-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTimer.h
More file actions
76 lines (51 loc) · 1.34 KB
/
Timer.h
File metadata and controls
76 lines (51 loc) · 1.34 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/// Copyright (C) 2012 - All Rights Reserved
/// All rights reserved. http://www.equals-forty-two.com
///
/// @brief Timer interface
#pragma once
#include <iomanip>
#include <iostream>
#include <Windows.h>
namespace eh
{
class Timer
{
public:
// 'running' is initially false. A timer needs to be explicitly started
// using 'start' or 'restart'
Timer();
/// Check if the timer is running
bool isRunning() const { return mRunning; }
/// Return the elapsed seconds
double getTime() const;
/// Get the elapsed time on the last batch (start/stop)
double getElapsedTime() const;
/// Init the timer
void reset();
/// Start the timer
void start();
/// Restart the timer
void restart();
/// Stop the timer
void stop();
/// Display the timer state.
void check(std::ostream& os = std::cout);
private:
friend std::ostream& operator<<(std::ostream& os, const Timer& t);
// Data members
bool mRunning;
double mAccumulatedTime; ///> Accumulated time in seconds
LARGE_INTEGER mFrequency;
LARGE_INTEGER mStartTime; ///< Start time of the timer.
};
class DelayTimer : private Timer
{
public:
DelayTimer();
DelayTimer(double delay);
void set(double delay);
bool check() const;
private:
double mDelay;
};
}