-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.cpp
78 lines (63 loc) · 1.64 KB
/
State.cpp
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
#include "stdafx.h"
#include "State.h"
namespace NightLightLibrary
{
#pragma region State
const LPCSTR State::getRegistryKey() {
static const std::string key = Schema::metadata.attributes.find(Registry::Name::SubkeyAttribute)->second;
return key.c_str();
}
const bool State::wasManuallyTriggered() const noexcept
{
return trigger == TriggerType::Manual;
}
State& State::resume()
{
status = Status::Running;
_dirty = true;
return *this;
}
State& State::pause() noexcept
{
status.set_nothing();
_dirty = true;
return *this;
}
const bool State::isRunning() const
{
return status == Status::Running && isUsable();
}
const bool State::isUsable() const noexcept
{
return usable;
}
State& State::setUsable(const bool u) noexcept
{
usable = u;
_dirty = true;
return *this;
}
State& State::_reset()
{
if (Schema::var::status::metadata.default_value.nothing)
status.set_nothing();
else
status = static_cast<Status>(Schema::var::status::metadata.default_value.int_value);
trigger = static_cast<TriggerType>(Schema::var::trigger::metadata.default_value.int_value);
changedOn = Schema::var::changedOn::metadata.default_value.uint_value;
usable = (Schema::var::usable::metadata.default_value.uint_value == 1);
_dirty = true;
return *this;
}
State& State::save(/*const bool starsAligned*/)
{
if (_dirty == false)
return *this;
GetSystemTimeAsFileTime((LPFILETIME)&changedOn);
//if (isRunning() || (starsAligned && isUsable()))
trigger = isUsable() ? TriggerType::Manual : TriggerType::Automatic;
Record::save(*this);
return *this;
}
#pragma endregion State
} // namespace NightLightLibrary