-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturn_timer.hpp
More file actions
51 lines (40 loc) · 833 Bytes
/
turn_timer.hpp
File metadata and controls
51 lines (40 loc) · 833 Bytes
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
#ifndef INSULA_TURN_TIMER_HPP_INCLUDED
#define INSULA_TURN_TIMER_HPP_INCLUDED
#include <fcppt/string.hpp>
#include <chrono>
namespace insula
{
/**
This class is (obviously) used to time one game iteration, but it
can be used for different purposes, too.
Note that this class is copyable. I don't see a reason why not.
*/
class turn_timer
{
public:
explicit
turn_timer(
std::chrono::milliseconds const &remaining_time);
void
add_to_remaining(
std::chrono::milliseconds const &);
std::chrono::milliseconds const
milliseconds_total() const;
std::chrono::milliseconds const
milliseconds_remaining() const;
bool
expired() const;
private:
typedef
std::chrono::high_resolution_clock
clock;
typedef
clock::time_point
time_point;
typedef
clock::duration
duration;
time_point start_,end_;
};
}
#endif