forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIfActions.h
82 lines (68 loc) · 1.95 KB
/
IfActions.h
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
/* Copyright (C) 2013 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
#ifndef __IFACTIONS_H__
#define __IFACTIONS_H__
#include <windows.h>
#include <string>
#include <vector>
class ConfigParser;
class Measure;
class Skin;
// Helper class for IfCondition/IfMatch
class IfState
{
public:
IfState(std::wstring value, std::wstring trueAction, std::wstring falseAction) :
value(),
tAction(),
fAction(),
parseError(false),
tCommitted(false),
fCommitted(false)
{
Set(value, trueAction, falseAction);
}
inline void Set(std::wstring value, std::wstring trueAction, std::wstring falseAction)
{
this->value = value;
this->tAction = trueAction;
this->fAction = falseAction;
}
std::wstring value; // IfCondition/IfMatch
std::wstring tAction; // IfTrueAction/IfMatchAction
std::wstring fAction; // IfFalseAction/IfNotMatchAction
bool parseError;
bool tCommitted;
bool fCommitted;
};
class IfActions
{
public:
IfActions();
~IfActions();
IfActions(const IfActions& other) = delete;
IfActions& operator=(IfActions other) = delete;
void ReadOptions(ConfigParser& parser, const WCHAR* section);
void ReadConditionOptions(ConfigParser& parser, const WCHAR* section);
void DoIfActions(Measure& measure, double value);
void SetState(double& value);
private:
double m_AboveValue;
double m_BelowValue;
int64_t m_EqualValue;
std::wstring m_AboveAction;
std::wstring m_BelowAction;
std::wstring m_EqualAction;
bool m_AboveCommitted;
bool m_BelowCommitted;
bool m_EqualCommitted;
std::vector<IfState> m_Conditions;
bool m_ConditionMode;
std::vector<IfState> m_Matches;
bool m_MatchMode;
};
#endif