AstraLog-HPC
Loading...
Searching...
No Matches
RuleStrategy Class Referenceabstract

Abstract base class that defines the interface for all rule evaluation strategies. More...

#include <Strategy.hpp>

Inheritance diagram for RuleStrategy:
Inheritance graph
Collaboration diagram for RuleStrategy:
Collaboration graph

Public Member Functions

virtual std::string whoAmI ()=0
 Returns the rule type name (e.g. "SimpleRule").
 
virtual int getConsecutive () const
 
virtual double getLastValue ()
 
virtual void setConsecutive (int)
 
virtual void setLastValue (double)
 
virtual bool hasPrevious () const
 
virtual int evaluate (const std::variant< double, std::string > &v)
 Evaluates the rule based on a sensor measurement or error state.
 
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.
 

Static Protected Member Functions

static bool compare (double left, double right, const std::string &op)
 A static helper function to perform logical comparisons.
 

Protected Attributes

std::string rule_id
 The unique identifier for this rule instance.
 
std::string rule_priority
 The execution priority of this rule.
 

Detailed Description

Abstract base class that defines the interface for all rule evaluation strategies.

Constructor & Destructor Documentation

◆ ~RuleStrategy()

virtual RuleStrategy::~RuleStrategy ( )
virtualdefault

Virtual destructor for safe polymorphic deletion.

Member Function Documentation

◆ compare()

static bool RuleStrategy::compare ( double  left,
double  right,
const std::string &  op 
)
inlinestaticprotected

A static helper function to perform logical comparisons.

Uses a static map shared by all rule instances for operator lookup.

Parameters
leftThe left operand (e.g., the sensor measurement).
rightThe right operand (e.g., the threshold value).
opThe comparison operator as a string (e.g., ">", "<", "==").
Returns
true if the comparison evaluates to true, false otherwise (or if operator is unknown).
Here is the caller graph for this function:

◆ evaluate() [1/2]

virtual int RuleStrategy::evaluate ( const ResultMap &  results)
inlinevirtual

Evaluates correlation rules based on the results of other primary rules.

Parameters
resultsA map containing the boolean results of other evaluated rules.
Returns
int 1 if the correlation rule is satisfied, 0 otherwise.

Reimplemented in CorrelationRule.

◆ evaluate() [2/2]

virtual int RuleStrategy::evaluate ( const std::variant< double, std::string > &  v)
inlinevirtual

Evaluates the rule based on a sensor measurement or error state.

Parameters
vA variant containing either a valid double reading or a string representing an error state.
Returns
int 1 if the rule is satisfied, 0 otherwise.

Reimplemented in SimpleRule, StatefulRule, and StepDifferenceRule.

◆ getConsecutive()

virtual int RuleStrategy::getConsecutive ( ) const
inlinevirtual

Reimplemented in StatefulRule.

◆ getLastValue()

virtual double RuleStrategy::getLastValue ( )
inlinevirtual

Reimplemented in StepDifferenceRule.

◆ hasPrevious()

virtual bool RuleStrategy::hasPrevious ( ) const
inlinevirtual

Reimplemented in StepDifferenceRule.

◆ id()

const std::string & RuleStrategy::id ( ) const
inline

Gets the unique identifier of the rule.

Returns
const std::string& The rule ID.

◆ priority()

const std::string & RuleStrategy::priority ( ) const
inline

Gets the priority level of the rule.

Returns
const std::string& The rule priority (e.g., "HIGH", "MEDIUM", "LOW").

◆ setConsecutive()

virtual void RuleStrategy::setConsecutive ( int  )
inlinevirtual

Reimplemented in StatefulRule.

◆ setLastValue()

virtual void RuleStrategy::setLastValue ( double  )
inlinevirtual

Reimplemented in StepDifferenceRule.

◆ whoAmI()

virtual std::string RuleStrategy::whoAmI ( )
pure virtual

Returns the rule type name (e.g. "SimpleRule").

Returns
The concrete rule type as a string.

Implemented in SimpleRule, StatefulRule, CorrelationRule, and StepDifferenceRule.

Member Data Documentation

◆ rule_id

std::string RuleStrategy::rule_id
protected

The unique identifier for this rule instance.

◆ rule_priority

std::string RuleStrategy::rule_priority
protected

The execution priority of this rule.


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