2013-11-05 17:07:42 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2013 Brian Ferguson
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __IFACTIONS_H__
|
|
|
|
#define __IFACTIONS_H__
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class ConfigParser;
|
|
|
|
class Measure;
|
|
|
|
class MeterWindow;
|
|
|
|
|
2014-01-04 06:24:56 +00:00
|
|
|
// Helper class for IfCondition/IfMatch
|
|
|
|
class IfState
|
2013-11-05 17:07:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-01-04 06:24:56 +00:00
|
|
|
IfState(std::wstring value, std::wstring trueAction, std::wstring falseAction) :
|
|
|
|
value(),
|
2013-11-05 17:07:42 +00:00
|
|
|
tAction(),
|
|
|
|
fAction(),
|
2013-11-08 15:36:43 +00:00
|
|
|
parseError(false),
|
|
|
|
tCommitted(false),
|
|
|
|
fCommitted(false)
|
2013-11-05 17:07:42 +00:00
|
|
|
{
|
|
|
|
Set(value, trueAction, falseAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Set(std::wstring value, std::wstring trueAction, std::wstring falseAction)
|
|
|
|
{
|
2014-01-04 06:24:56 +00:00
|
|
|
this->value = value;
|
2013-11-05 17:07:42 +00:00
|
|
|
this->tAction = trueAction;
|
|
|
|
this->fAction = falseAction;
|
|
|
|
}
|
|
|
|
|
2014-01-04 06:24:56 +00:00
|
|
|
std::wstring value; // IfCondition/IfMatch
|
|
|
|
std::wstring tAction; // IfTrueAction/IfMatchAction
|
|
|
|
std::wstring fAction; // IfFalseAction/IfNotMatchAction
|
2013-11-05 17:07:42 +00:00
|
|
|
bool parseError;
|
2013-11-08 15:36:43 +00:00
|
|
|
bool tCommitted;
|
|
|
|
bool fCommitted;
|
2013-11-05 17:07:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IfActions
|
|
|
|
{
|
|
|
|
public:
|
2013-11-05 19:09:54 +00:00
|
|
|
IfActions();
|
2013-11-05 17:07:42 +00:00
|
|
|
~IfActions();
|
|
|
|
|
|
|
|
void ReadOptions(ConfigParser& parser, const WCHAR* section);
|
2013-11-05 18:43:04 +00:00
|
|
|
void ReadConditionOptions(ConfigParser& parser, const WCHAR* section);
|
2013-11-05 19:09:54 +00:00
|
|
|
void DoIfActions(Measure& measure, double value);
|
2013-11-08 15:40:14 +00:00
|
|
|
void SetState(double& value);
|
2013-11-05 17:07:42 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2014-01-04 06:24:56 +00:00
|
|
|
std::vector<IfState> m_Conditions;
|
2013-11-08 15:36:43 +00:00
|
|
|
bool m_ConditionMode;
|
2014-01-04 06:24:56 +00:00
|
|
|
|
|
|
|
std::vector<IfState> m_Matches;
|
|
|
|
bool m_MatchMode;
|
2013-11-05 17:07:42 +00:00
|
|
|
};
|
|
|
|
#endif
|