-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspclock.h
More file actions
64 lines (48 loc) · 1.44 KB
/
spclock.h
File metadata and controls
64 lines (48 loc) · 1.44 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
#ifndef SPTIME_H
#define SPTIME_H
#include <iostream>
#include <future>
#include "date/tz.h"
namespace spclock {
using std::chrono::seconds;
class local_time {
date::zoned_time<seconds> zoned_tp_;
public:
local_time(); // construct current time
// constructing an arbitrary time of the current day
local_time(const seconds&);
const date::time_zone* zone() const;
std::string format(const std::string&) const;
// no + operation defined same as std::chrono::time_point
friend seconds operator-(const local_time&, const local_time&);
friend bool operator>(const local_time&, const local_time&);
friend bool operator<(const local_time&, const local_time&);
friend local_time operator+(const local_time&, const seconds&);
friend std::ostream& operator<<(std::ostream&, const local_time&);
};
local_time now();
// classes related to alarm and timer constructs
enum class b_type {
alarm,
timer
};
enum class b_state {
running,
finished,
cancelled
};
struct buzzer {
local_time end_time;
std::string message;
b_type buzzer_type;
b_state state;
std::promise<void> stop;
explicit buzzer(seconds,const std::string&, std::string);
buzzer(const buzzer&) = delete; //no copy - it has promise
buzzer(buzzer&&);
};
void make_sound();
} // namespace spclock
// outputs duration in a very verbose way
std::ostream& operator<<(std::ostream&, const std::chrono::seconds&);
#endif