#include "rule.h" namespace domain { Condition::Condition(std::string function, std::vector params, bool negated) : negated(negated), function(function), params(params) {} bool Condition::evaluate(RuleContext &context) { std::vector request; for(unsigned int i=0; ivalidate(request); return negated ? !result : result; } Action::Action(ActionType type, std::string message) : type(type), message(message) {} Action::ActionType Action::getType() { return type; } std::string Action::getMessage() { return message; } IfStatement::IfStatement(Condition condition, Action action) : condition(condition), action(action) {} std::optional IfStatement::evaluate(RuleContext &context) { if(condition.evaluate(context)) { return action; } return std::nullopt; } Rule::Rule(std::vector statements) : statements(statements) {} std::optional Rule::evaluate(RuleContext &context) { for(unsigned int i=0; i