AstraLog-HPC
Loading...
Searching...
No Matches
SimpleRule Class Reference

A straightforward rule that compares a single sensor measurement against a threshold. More...

#include <Rules.hpp>

Inheritance diagram for SimpleRule:
Inheritance graph
Collaboration diagram for SimpleRule:
Collaboration graph

Public Member Functions

 SimpleRule (const RuleConfig &cfg)
 Constructs a SimpleRule from a configuration object.
 
std::string whoAmI () override
 Returns the rule type name.
 
int evaluate (const std::variant< double, std::string > &v) override
 Evaluates the sensor value against the configured threshold.
 
- Public Member Functions inherited from RuleStrategy
virtual int getConsecutive () const
 
virtual double getLastValue ()
 
virtual void setConsecutive (int)
 
virtual void setLastValue (double)
 
virtual bool hasPrevious () const
 
virtual int evaluate (const ResultMap &results)
 Evaluates correlation rules based on the results of other primary rules.
 
virtual ~RuleStrategy ()=default
 Virtual destructor for safe polymorphic deletion.
 
const std::string & id () const
 Gets the unique identifier of the rule.
 
const std::string & priority () const
 Gets the priority level of the rule.
 

Private Attributes

std::string sensor_id
 The ID of the sensor this rule applies to.
 
std::string op
 The comparison operator (e.g., ">", "<", "==").
 
double threshold
 The threshold value to compare against.
 

Additional Inherited Members

- Static Protected Member Functions inherited from RuleStrategy
static bool compare (double left, double right, const std::string &op)
 A static helper function to perform logical comparisons.
 
- Protected Attributes inherited from RuleStrategy
std::string rule_id
 The unique identifier for this rule instance.
 
std::string rule_priority
 The execution priority of this rule.
 

Detailed Description

A straightforward rule that compares a single sensor measurement against a threshold.

Constructor & Destructor Documentation

◆ SimpleRule()

SimpleRule::SimpleRule ( const RuleConfig &  cfg)
inlineexplicit

Constructs a SimpleRule from a configuration object.

Parameters
cfgThe configuration containing sensor_id, operator (op), threshold (value), rule_id, and priority.

Member Function Documentation

◆ evaluate()

int SimpleRule::evaluate ( const std::variant< double, std::string > &  v)
inlineoverridevirtual

Evaluates the sensor value against the configured threshold.

Parameters
vA variant containing either a valid double reading or a string representing an error state ("E").
Returns
int 1 if the rule condition is triggered, 0 otherwise (including error cases).

Reimplemented from RuleStrategy.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ whoAmI()

std::string SimpleRule::whoAmI ( )
inlineoverridevirtual

Returns the rule type name.

Returns
The string "SimpleRule".

Implements RuleStrategy.

Member Data Documentation

◆ op

std::string SimpleRule::op
private

The comparison operator (e.g., ">", "<", "==").

◆ sensor_id

std::string SimpleRule::sensor_id
private

The ID of the sensor this rule applies to.

◆ threshold

double SimpleRule::threshold
private

The threshold value to compare against.


The documentation for this class was generated from the following file: