-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clock.hpp
85 lines (64 loc) · 2.16 KB
/
Clock.hpp
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
77
78
79
80
81
82
83
84
85
#pragma once
#include <iosfwd>
#include <map>
#include "global.hpp"
#include "WallClock.hpp"
#include "Hour.hpp"
#include "Minute.hpp"
#include "Day.hpp"
#include "Period.hpp"
namespace sleep
{
#ifdef RUN_TESTS
class TestResult;
#endif // #ifdef RUN_TESTS
struct ClockConfig
{
CompactTime m_nightStart;
CompactTime m_nightEnd;
Minute m_delayBeforeNight;
Minute m_delayAfterNight;
};
struct WeekClockConfig
{
std::map< Day, ClockConfig > m_week;
};
class Clock : public WallClock
{
public:
#ifdef RUN_TESTS
static void Test(TestResult & testResult);
#endif // #ifdef RUN_TESTS
Clock(WallClock const & clock, Day const day);
Clock(CompactTime const & compactTime, Day const day);
Clock(StrictHour const & hours, StrictMinute const & minutes, Day const day);
Clock(Minute const & totalMinutes, Day const day);
Clock(unsigned long const epoch);
Clock(Clock const & other);
Clock & operator =(Clock const & other);
Period getPeriod() const;
Day day() const;
Clock operator +(Hour const & hour) const;
Clock operator +(Minute const & minute) const;
Clock operator -(Hour const & hour) const;
Clock operator -(Minute const & minute) const;
Minute operator -(Clock const & rhs) const;
void print() const;
static Clock Get(Period const period, Day const day);
static void SetNightStart(int const hours, int const minutes);
static void SetNightEnd(int const hours, int const minutes);
static void SetDelayBeforeNight(int const minutes);
static void SetDelayAfterNight(int const minutes);
static void SetNightStart(int const hours, int const minutes, Day const day);
static void SetNightEnd(int const hours, int const minutes, Day const day);
static void SetDelayBeforeNight(int const minutes, Day const day);
static void SetDelayAfterNight(int const minutes, Day const day);
static WeekClockConfig const & GetConfig();
static void SetConfig(WeekClockConfig const & weekClockConfig);
private:
static WeekClockConfig & AccessConfig();
Day m_day;
static WeekClockConfig m_weekClockConfig;
};
std::ostream & operator <<(std::ostream & stream, Clock const& Clock);
}