A rule to compare two rules. More...
#include <indiCompRules.hpp>


Public Types | |
| typedef std::variant< bool, std::string > | boolorerr_t |
| In-band error reporting type. | |
Public Member Functions | |
| ruleCompRule () | |
| Default c'tor. | |
| void | rule1 (indiCompRule *r) |
| Set the pointer to the first rule. | |
| const indiCompRule * | rule1 () |
| Get the pointer to the first rule. | |
| void | rule2 (indiCompRule *r) |
| Set the pointer to the second rule. | |
| const indiCompRule * | rule2 () |
| Get the pointer to the first rule. | |
| virtual boolorerr_t | valid () |
| Check if this rule is valid. | |
| virtual bool | value () |
| Get the value of this rule. | |
| bool | isError (boolorerr_t rv) |
| Check if returned value indicates an error. | |
| void | priority (const rulePriority &p) |
| Set priority of this rule. | |
| const rulePriority & | priority () |
| Get the rule priority. | |
| void | message (const std::string &m) |
| Set the message. | |
| const std::string & | message () |
| Get the message. | |
| void | comparison (const ruleComparison &c) |
| Set the comparison for this rule. | |
| const ruleComparison & | comparison () |
| Get the rule comparison. | |
| boolorerr_t | compTxt (const std::string &str1, const std::string &str2) |
| Compare two strings. | |
| boolorerr_t | compSw (const pcf::IndiElement::SwitchStateType &sw1, const pcf::IndiElement::SwitchStateType &sw2) |
| Compare two switches. | |
| boolorerr_t | compNum (const double &num1, const double &num2, const double &tol) |
| Compare two numbers. | |
| boolorerr_t | compBool (const bool &b1, const bool &b2) |
| Compare two booleans. | |
Static Public Attributes | |
| static constexpr char | name [] = "ruleComp" |
| Name of this rule, used by config system. | |
Protected Attributes | |
| indiCompRule * | m_rule1 {nullptr} |
| rule one | |
| indiCompRule * | m_rule2 {nullptr} |
| rule two | |
| rulePriority | m_priority {rulePriority::none} |
| The reporting priority for this rule. | |
| std::string | m_message |
| The message used for notifications. | |
| ruleComparison | m_comparison {ruleComparison::Eq} |
| The comparison for this rule. | |
A rule to compare two rules.
Definition at line 1018 of file indiCompRules.hpp.
|
inherited |
In-band error reporting type.
Definition at line 152 of file indiCompRules.hpp.
|
inline |
Default c'tor.
Changes default comparison to And for ruleCompRule
Definition at line 1035 of file indiCompRules.hpp.
References And, and indiCompRule::comparison().
|
inlineinherited |
Get the rule comparison.
Definition at line 218 of file indiCompRules.hpp.
References indiCompRule::m_comparison.
Referenced by ruleCompRule().
|
inlineinherited |
Set the comparison for this rule.
| [in] | c | the new comparison |
Definition at line 208 of file indiCompRules.hpp.
References indiCompRule::m_comparison.
Referenced by loadRuleConfig(), SCENARIO(), SCENARIO(), SCENARIO(), and SCENARIO().
|
inlineinherited |
Compare two booleans.
| [in] | b1 | the first bool to compare |
| [in] | b2 | the second bool to compare |
Definition at line 341 of file indiCompRules.hpp.
References And, Eq, Imply, indiCompRule::m_comparison, Nand, Neq, Nimply, Nor, and Or.
Referenced by value().
|
inlineinherited |
Compare two numbers.
The comparison is (num1 comp num2), e.g. (num1 < num2). A tolerance is included for floating point equality.
| [in] | num1 | the first number to compare |
| [in] | num2 | the second number to compare |
| [in] | tol | the tolerance for the comparison |
Definition at line 299 of file indiCompRules.hpp.
References Eq, Gt, GtEq, Lt, LtEq, indiCompRule::m_comparison, and Neq.
Referenced by numValRule::value(), and elCompNumRule::value().
|
inlineinherited |
Compare two switches.
Switch comparison can only be Eq or Neq.
| [in] | sw1 | the first switch to compare |
| [in] | sw2 | the first switch to compare |
Definition at line 270 of file indiCompRules.hpp.
References Eq, indiCompRule::m_comparison, and Neq.
Referenced by swValRule::value(), and elCompSwRule::value().
|
inlineinherited |
Compare two strings.
String comparison can only be Eq or Neq.
| [in] | str1 | the first string to compare |
| [in] | str2 | the second string to compare |
Definition at line 242 of file indiCompRules.hpp.
References Eq, indiCompRule::m_comparison, and Neq.
Referenced by txtValRule::value(), and elCompTxtRule::value().
|
inlineinherited |
Check if returned value indicates an error.
| [in] | rv | the return value to check |
Definition at line 155 of file indiCompRules.hpp.
Referenced by valid(), numValRule::value(), txtValRule::value(), swValRule::value(), elCompNumRule::value(), elCompTxtRule::value(), elCompSwRule::value(), and value().
|
inlineinherited |
Get the message.
Definition at line 202 of file indiCompRules.hpp.
References indiCompRule::m_message.
|
inlineinherited |
Set the message.
| [in] | m | the new message |
Definition at line 193 of file indiCompRules.hpp.
References indiCompRule::m_message.
Referenced by loadRuleConfig().
|
inlineinherited |
Get the rule priority.
Definition at line 187 of file indiCompRules.hpp.
References indiCompRule::m_priority.
|
inlineinherited |
Set priority of this rule.
| [in] | p | the new priority |
Definition at line 178 of file indiCompRules.hpp.
References indiCompRule::m_priority.
Referenced by loadRuleConfig().
|
inline |
Get the pointer to the first rule.
Definition at line 1050 of file indiCompRules.hpp.
References m_rule1.
|
inline |
Set the pointer to the first rule.
| [in] | r | the new pointer to rule1 |
Definition at line 1041 of file indiCompRules.hpp.
References m_rule1.
Referenced by finalizeRuleValRules(), SCENARIO(), and SCENARIO().
|
inline |
Get the pointer to the first rule.
Definition at line 1065 of file indiCompRules.hpp.
References m_rule2.
|
inline |
Set the pointer to the second rule.
| [in] | r | the new pointer to rule2 |
Definition at line 1056 of file indiCompRules.hpp.
References m_rule2.
Referenced by finalizeRuleValRules(), SCENARIO(), and SCENARIO().
|
inlinevirtual |
Check if this rule is valid.
The rule is valid if the rule pointers are not nullptr, and if each rule is itself valid.
If not valid, the return value is a std::string with the reason. If valid, the return value is a bool set to true.
Implements indiCompRule.
Definition at line 1076 of file indiCompRules.hpp.
References indiCompRule::isError(), m_rule1, m_rule2, and indiCompRule::valid().
Referenced by value().
|
inlinevirtual |
Get the value of this rule.
First checks if the rule is currently valid. The performs the comparison and returns the result.
| mx::err::invalidconfig | if the rule is not currently valid |
| mx::err::invalidconfig | on an error from the comparison |
Implements indiCompRule.
Definition at line 1116 of file indiCompRules.hpp.
References indiCompRule::compBool(), indiCompRule::isError(), m_rule1, m_rule2, valid(), and indiCompRule::value().
Referenced by audibleAlerts.personality.Operation::__str__(), audibleAlerts.personality.Transition::compare(), SCENARIO(), and SCENARIO().
|
protectedinherited |
The comparison for this rule.
Definition at line 169 of file indiCompRules.hpp.
Referenced by indiCompRule::comparison(), indiCompRule::comparison(), indiCompRule::compBool(), indiCompRule::compNum(), indiCompRule::compSw(), and indiCompRule::compTxt().
|
protectedinherited |
The message used for notifications.
Definition at line 166 of file indiCompRules.hpp.
Referenced by indiCompRule::message(), and indiCompRule::message().
|
protectedinherited |
The reporting priority for this rule.
Definition at line 163 of file indiCompRules.hpp.
Referenced by indiCompRule::priority(), and indiCompRule::priority().
|
protected |
|
protected |
|
staticconstexpr |
Name of this rule, used by config system.
Definition at line 1024 of file indiCompRules.hpp.
Referenced by loadRuleConfig().