The Engine that evaluates Rules and finds Actions to be executed. More...
Header: | #include <RuleEngine> |
Inherits: |
enum | RemovePolicy { RemovePolicyCascade, RemovePolicyUpdate } |
enum | RuleError { RuleErrorNoError, RuleErrorInvalidRuleId, RuleErrorRuleNotFound, RuleErrorDeviceNotFound, ..., RuleErrorInterfaceNotFound } |
RuleEngine(QObject * parent = nullptr) | |
~RuleEngine() | |
RuleError | addRule(const Rule & rule, bool fromEdit = false) |
QList<DeviceId> | devicesInRules() const |
RuleError | disableRule(const RuleId & ruleId) |
RuleError | editRule(const Rule & rule) |
RuleError | enableRule(const RuleId & ruleId) |
QList<Rule> | evaluateEvent(const Event & event) |
QList<Rule> | evaluateTime(const QDateTime & dateTime) |
RuleError | executeActions(const RuleId & ruleId) |
RuleError | executeExitActions(const RuleId & ruleId) |
Rule | findRule(const RuleId & ruleId) |
QList<RuleId> | findRules(const DeviceId & deviceId) const |
void | init() |
void | removeDeviceFromRule(const RuleId & id, const DeviceId & deviceId) |
RuleError | removeRule(const RuleId & ruleId, bool fromEdit = false) |
QList<RuleId> | ruleIds() const |
QList<Rule> | rules() const |
void | ruleAdded(const Rule & rule) |
void | ruleConfigurationChanged(const Rule & rule) |
void | ruleRemoved(const RuleId & ruleId) |
The Engine that evaluates Rules and finds Actions to be executed.
You can add, remove and update rules and query the engine for actions to be executed for a given Event described by an EventDescriptor.
See also Event, EventDescriptor, Rule, and RuleAction.
Constant | Value | Description |
---|---|---|
nymeaserver::RuleEngine::RemovePolicyCascade | 0 | Remove the whole Rule. |
nymeaserver::RuleEngine::RemovePolicyUpdate | 1 | Remove a Device from a rule. |
Constant | Value | Description |
---|---|---|
nymeaserver::RuleEngine::RuleErrorNoError | 0 | No error happened. Everything is fine. |
nymeaserver::RuleEngine::RuleErrorInvalidRuleId | 1 | The given RuleId is not valid. |
nymeaserver::RuleEngine::RuleErrorRuleNotFound | 2 | Couldn't find a Rule with the given id. |
nymeaserver::RuleEngine::RuleErrorDeviceNotFound | 3 | Couldn't find a Device with the given id. |
nymeaserver::RuleEngine::RuleErrorEventTypeNotFound | 4 | Couldn't find a EventType with the given id. |
nymeaserver::RuleEngine::RuleErrorStateTypeNotFound | 5 | Couldn't find a StateType with the given id. |
nymeaserver::RuleEngine::RuleErrorActionTypeNotFound | 6 | Couldn't find a ActionType with the given id. |
nymeaserver::RuleEngine::RuleErrorInvalidParameter | 7 | The given Param is not valid. |
nymeaserver::RuleEngine::RuleErrorInvalidRuleFormat | 8 | The format of the rule is not valid. (i.e. add Rule with exitActions and eventDescriptors) |
nymeaserver::RuleEngine::RuleErrorMissingParameter | 9 | One of the given Params is missing. |
nymeaserver::RuleEngine::RuleErrorInvalidRuleActionParameter | 10 | One of the given RuleActionParams is not valid. |
nymeaserver::RuleEngine::RuleErrorInvalidStateEvaluatorValue | 11 | One of the given StateEvaluators has an invalid State value. |
nymeaserver::RuleEngine::RuleErrorTypesNotMatching | 12 | The types of the RuleActionParam and the corresponding Event Param do not match. |
nymeaserver::RuleEngine::RuleErrorNotExecutable | 13 | This rule is not executable. |
nymeaserver::RuleEngine::RuleErrorInvalidRepeatingOption | 15 | One of the given RepeatingOption is not valid. |
nymeaserver::RuleEngine::RuleErrorInvalidCalendarItem | 16 | One of the given CalendarItems is not valid. |
nymeaserver::RuleEngine::RuleErrorInvalidTimeDescriptor | 14 | One of the given TimeDescriptors is not valid. |
nymeaserver::RuleEngine::RuleErrorInvalidTimeEventItem | 17 | One of the given TimeEventItems is not valid. |
nymeaserver::RuleEngine::RuleErrorContainsEventBasesAction | 18 | This rule contains an Action which depends on an Event value. This Rule cannot execute the Actions without the Event value. |
nymeaserver::RuleEngine::RuleErrorNoExitActions | 19 | This rule does not have any ExitActions which means they cannot be executed. |
nymeaserver::RuleEngine::RuleErrorInterfaceNotFound | 20 | There is no interface for the given string. |
Constructs the RuleEngine with the given parent. Although it wouldn't harm to have multiple RuleEngines, there is one instance available from NymeaCore. This one should be used instead of creating multiple ones.
Destructor of the RuleEngine.
Add the given rule to the system. If the rule will be added from an edit request, the parameter fromEdit will be true.
Returns all devices that are somehow contained in a rule
Disables the rule with the given ruleId. Disabled rules won't be triggered.
See also enableRule().
Edit the given rule in the system. The rule with the RuleId from the given rule will be removed from the system and readded with the new parameters in the given rule.
Enables the rule with the given ruleId that has been previously disabled.
See also disableRule().
Ask the Engine to evaluate all the rules for the given event. This will search all the Rules triggered by the given event and evaluate their states in the system. It will return a list of all Rules that are triggered or change its active state because of this event.
Ask the Engine to evaluate all the rules for the given dateTime. This will search all the Rules triggered by the given dateTime and evaluate their CalendarItems and TimeEventItems. It will return a list of all Rules that are triggered or change its active state.
Executes the list of Actions of the rule with the given ruleId. Returns the corresponding RuleEngine::RuleError to inform about the result.
See also executeExitActions().
Executes the list of ExitActions of the rule with the given ruleId. Returns the corresponding RuleEngine::RuleError to inform about the result.
See also executeActions().
Returns the Rule with the given ruleId. If the Rule does not exist, it will return Rule::Rule()
Returns a list of all Rules loaded in this Engine, which contains a Device with the given deviceId.
Removes a Device from a Rule with the given id and deviceId.
Removes the Rule with the given ruleId from the Engine. Returns RuleError which describes whether the operation was successful or not. If fromEdit is true, the notification Rules.RuleRemoved will not be emitted.
[signal]
void RuleEngine::ruleAdded(const Rule & rule)Will be emitted whenever a new Rule is added to this Engine. The rule parameter holds the entire new rule.
[signal]
void RuleEngine::ruleConfigurationChanged(const Rule & rule)Will be emitted whenever a Rule changed his enable/disable status. The parameter rule holds the changed rule.
Returns a list of all ruleIds loaded in this Engine.
[signal]
void RuleEngine::ruleRemoved(const RuleId & ruleId)Will be emitted whenever a Rule is removed from this Engine. ruleId holds the id of the removed rule. You should remove any references or copies you hold for this rule.
Returns a list of all Rules loaded in this Engine. Be aware that this does not necessarily reflect the order of the rules in the engine. Use ruleIds() if you need the correct order.