Compare the value of a number element to a target. More...
#include <indiCompRules.hpp>
Public Types | |
typedef std::variant< bool, std::string > | boolorerr_t |
In-band error reporting type. More... | |
Public Member Functions | |
numValRule () | |
Default c'tor. More... | |
void | target (const double &tgt) |
Set the target for the comparison. More... | |
const double & | target () |
Get the target. More... | |
void | tol (const double &t) |
Set the tolerance. More... | |
const double & | tol () |
Get the tolerance. More... | |
virtual bool | value () |
Get the value of this rule. More... | |
void | property (pcf::IndiProperty *property) |
Set the property pointer. More... | |
const pcf::IndiProperty * | property () |
Get the property pointer. More... | |
void | element (const std::string &el) |
Set the element name. More... | |
const std::string & | element () |
Get the element name. More... | |
virtual boolorerr_t | valid () |
Check if this rule is valid. More... | |
bool | isError (boolorerr_t rv) |
Check if returned value indicates an error. More... | |
void | priority (const rulePriority &p) |
Set priority of this rule. More... | |
const rulePriority & | priority () |
Get the rule priority. More... | |
void | message (const std::string &m) |
Set the message. More... | |
const std::string & | message () |
Get the message. More... | |
void | comparison (const ruleComparison &c) |
Set the comparison for this rule. More... | |
const ruleComparison & | comparison () |
Get the rule comparison. More... | |
boolorerr_t | compTxt (const std::string &str1, const std::string &str2) |
Compare two strings. More... | |
boolorerr_t | compSw (const pcf::IndiElement::SwitchStateType &sw1, const pcf::IndiElement::SwitchStateType &sw2) |
Compare two switches. More... | |
boolorerr_t | compNum (const double &num1, const double &num2, const double &tol) |
Compare two numbers. More... | |
boolorerr_t | compBool (const bool &b1, const bool &b2) |
Compare two booleans. More... | |
Static Public Attributes | |
static constexpr char | name [] = "numVal" |
Name of this rule, used by config system. More... | |
Protected Attributes | |
double | m_target {0} |
The target value for comparison. More... | |
double | m_tol {1e-6} |
The tolerance for the comparison. More... | |
int | m_type |
The property type, from pcf::IndiProperty::Type. More... | |
pcf::IndiProperty * | m_property {nullptr} |
Pointer to the property. More... | |
std::string | m_element |
The element name within the property. More... | |
rulePriority | m_priority {rulePriority::none} |
The reporting priority for this rule. More... | |
std::string | m_message |
The message used for notifications. More... | |
ruleComparison | m_comparison {ruleComparison::Eq} |
The comparison for this rule. More... | |
Compare the value of a number element to a target.
Definition at line 614 of file indiCompRules.hpp.
|
inherited |
In-band error reporting type.
Definition at line 142 of file indiCompRules.hpp.
|
inline |
Default c'tor.
Definition at line 630 of file indiCompRules.hpp.
|
inlineinherited |
Get the rule comparison.
Definition at line 208 of file indiCompRules.hpp.
Referenced by ruleCompRule::ruleCompRule().
|
inlineinherited |
Set the comparison for this rule.
[in] | c | the new comparison |
Definition at line 198 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inlineinherited |
Compare two booleans.
[in] | b1 | the first bool to compare |
[in] | b2 | the second bool to compare |
Definition at line 331 of file indiCompRules.hpp.
Referenced by ruleCompRule::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 289 of file indiCompRules.hpp.
Referenced by 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 260 of file indiCompRules.hpp.
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 232 of file indiCompRules.hpp.
Referenced by txtValRule::value(), and elCompTxtRule::value().
|
inlineinherited |
Get the element name.
Definition at line 425 of file indiCompRules.hpp.
|
inlineinherited |
Set the element name.
[in] | el | the new element name |
Definition at line 416 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inlineinherited |
Check if returned value indicates an error.
[in] | rv | the return value to check |
Definition at line 145 of file indiCompRules.hpp.
Referenced by ruleCompRule::valid(), value(), txtValRule::value(), swValRule::value(), elCompNumRule::value(), elCompTxtRule::value(), elCompSwRule::value(), and ruleCompRule::value().
|
inlineinherited |
|
inlineinherited |
Set the message.
[in] | m | the new message |
Definition at line 183 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inlineinherited |
Get the rule priority.
Definition at line 177 of file indiCompRules.hpp.
|
inlineinherited |
Set priority of this rule.
[in] | p | the new priority |
Definition at line 168 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inlineinherited |
Get the property pointer.
Definition at line 410 of file indiCompRules.hpp.
Referenced by onePropRule::property().
|
inlineinherited |
Set the property pointer.
mx::err::invalidarg | if property is nullptr |
mx::err::invalidconfig | if the supplied property has the wrong type |
[in] | property | the new property pointer |
Definition at line 391 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inline |
Get the target.
Definition at line 643 of file indiCompRules.hpp.
|
inline |
Set the target for the comparison.
[in] | tgt | The new target |
Definition at line 634 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inline |
Get the tolerance.
Definition at line 668 of file indiCompRules.hpp.
|
inline |
Set the tolerance.
This is used for equality comparison to allow for floating point precision and text conversions in INDI. Set to 0 for strict comparison.
mx::err:invalidarg | if the new value is negative |
[in] | t | the new tolerance |
Definition at line 654 of file indiCompRules.hpp.
Referenced by loadRuleConfig().
|
inlinevirtualinherited |
Check if this rule is valid.
The rule is valid if the property pointer is not null, and the element is contained within the property.
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 437 of file indiCompRules.hpp.
Referenced by value(), txtValRule::value(), and swValRule::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 682 of file indiCompRules.hpp.
Referenced by audibleAlerts.personality.Operation::__str__(), and audibleAlerts.personality.Transition::compare().
|
protectedinherited |
The comparison for this rule.
Definition at line 159 of file indiCompRules.hpp.
Referenced by indiCompRule::comparison(), indiCompRule::compBool(), indiCompRule::compNum(), indiCompRule::compSw(), and indiCompRule::compTxt().
|
protectedinherited |
The element name within the property.
Definition at line 375 of file indiCompRules.hpp.
Referenced by onePropRule::element(), onePropRule::valid(), value(), txtValRule::value(), and swValRule::value().
|
protectedinherited |
The message used for notifications.
Definition at line 156 of file indiCompRules.hpp.
Referenced by indiCompRule::message().
|
protectedinherited |
The reporting priority for this rule.
Definition at line 153 of file indiCompRules.hpp.
Referenced by indiCompRule::priority().
|
protectedinherited |
Pointer to the property.
Definition at line 373 of file indiCompRules.hpp.
Referenced by onePropRule::property(), onePropRule::valid(), txtValRule::value(), and swValRule::value().
|
protected |
The target value for comparison.
Definition at line 624 of file indiCompRules.hpp.
|
protected |
The tolerance for the comparison.
Definition at line 625 of file indiCompRules.hpp.
|
protectedinherited |
The property type, from pcf::IndiProperty::Type.
Definition at line 371 of file indiCompRules.hpp.
Referenced by onePropRule::property().
|
staticconstexpr |
Name of this rule, used by config system.
Definition at line 620 of file indiCompRules.hpp.
Referenced by loadRuleConfig().