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

A rule that evaluates a combination of other rules based on logical operators (AND/OR). More...

#include <Rules.hpp>

Inheritance diagram for CorrelationRule:
Inheritance graph
Collaboration diagram for CorrelationRule:
Collaboration graph

Public Member Functions

 CorrelationRule (const RuleConfig &cfg)
 Constructs a CorrelationRule from a configuration object.
 
std::string whoAmI () override
 Returns the rule type name.
 
int evaluate (const ResultMap &results) override
 Evaluates the rule based on the outcomes of its dependency conditions.
 
const std::vector< std::string > & getConditions () const
 
- 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 std::variant< double, std::string > &v)
 Evaluates the rule based on a sensor measurement or error state.
 
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 logic
 The logical operator ("AND" or "OR").
 
std::vector< std::string > conditions
 The rule IDs that this rule depends on.
 

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 rule that evaluates a combination of other rules based on logical operators (AND/OR).

Constructor & Destructor Documentation

◆ CorrelationRule()

CorrelationRule::CorrelationRule ( const RuleConfig &  cfg)
inlineexplicit

Constructs a CorrelationRule from a configuration object.

Parameters
cfgThe configuration containing the logical operator (AND/OR) and a list of condition IDs.

Member Function Documentation

◆ evaluate()

int CorrelationRule::evaluate ( const ResultMap &  results)
inlineoverridevirtual

Evaluates the rule based on the outcomes of its dependency conditions.

Parameters
resultsA map containing the evaluation results of other rules.
Returns
int 1 if the combined logical condition is met, 0 otherwise.

Reimplemented from RuleStrategy.

Here is the caller graph for this function:

◆ getConditions()

const std::vector< std::string > & CorrelationRule::getConditions ( ) const
inline

◆ whoAmI()

std::string CorrelationRule::whoAmI ( )
inlineoverridevirtual

Returns the rule type name.

Returns
The string "CorrelationRule".

Implements RuleStrategy.

Member Data Documentation

◆ conditions

std::vector<std::string> CorrelationRule::conditions
private

The rule IDs that this rule depends on.

◆ logic

std::string CorrelationRule::logic
private

The logical operator ("AND" or "OR").


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