|
ReteEngine 1.0
A rules engine and builder
|
Represents a terminal node in a Rete network that schedules rule activations when matching facts are asserted. More...
Public Member Functions | |
| TerminalNode (string name, Action< Token > action, Agenda agenda, int salience=0) | |
| Initializes a new instance of the TerminalNode class with the specified rule name, action, agenda, and optional salience. | |
| void | AddSuccessor (IReteNode node) |
| Prevents adding a successor node to this terminal node. | |
| void | Assert (object fact) |
| Asserts a fact into the rule engine, creating an activation if the fact has not already been processed. | |
| void | Retract (object fact) |
| Retracts the specified fact from the rule engine, removing any associated activations or tokens. | |
| void | Refresh (object fact, string propertyName) |
| Updates the specified fact in the working memory, re-evaluating any rules that depend on the given property. | |
| void | DebugPrint (object fact, int level=0) |
| Writes a formatted debug message to the console that includes the rule name and the specified fact, indented according to the given level. | |
Represents a terminal node in a Rete network that schedules rule activations when matching facts are asserted.
A TerminalNode is the endpoint of a Rete rule network. When a fact matching the rule conditions reaches this node, it creates an activation and adds it to the agenda for later execution. TerminalNode instances are typically associated with a specific rule and action. No successor nodes should be added after a TerminalNode.
| ReteCore.TerminalNode.TerminalNode | ( | string | name, |
| Action< Token > | action, | ||
| Agenda | agenda, | ||
| int | salience = 0 ) |
Initializes a new instance of the TerminalNode class with the specified rule name, action, agenda, and optional salience.
| name | The name of the rule associated with this terminal node. Cannot be null. |
| action | The action to execute when the terminal node is activated. Cannot be null. |
| agenda | The agenda that manages the execution order of rules. Cannot be null. |
| salience | The priority of the rule. Higher values indicate higher priority. The default is 0. |
| void ReteCore.TerminalNode.AddSuccessor | ( | IReteNode | node | ) |
Prevents adding a successor node to this terminal node.
Terminal nodes do not support successors. Calling this method has no effect other than logging a message.
| node | The node that would be added as a successor. This parameter is ignored. |
| void ReteCore.TerminalNode.Assert | ( | object | fact | ) |
Asserts a fact into the rule engine, creating an activation if the fact has not already been processed.
If the specified fact is a Token that has not previously triggered an activation for this rule, an activation is added to the agenda. Duplicate assertions of the same Token are ignored. This method is typically used to introduce new facts for rule evaluation.
| fact | The fact to assert. Must be a non-null object of type Token to be considered for activation. |
Implements ReteCore.IReteNode.
| void ReteCore.TerminalNode.DebugPrint | ( | object | fact, |
| int | level = 0 ) |
Writes a formatted debug message to the console that includes the rule name and the specified fact, indented according to the given level.
| fact | The fact object to include in the debug output. This object is converted to a string using its ToString method. |
| level | The indentation level for the output. Each level increases the indentation by two spaces. The default is 0. |
Implements ReteCore.IReteNode.
| void ReteCore.TerminalNode.Refresh | ( | object | fact, |
| string | propertyName ) |
Updates the specified fact in the working memory, re-evaluating any rules that depend on the given property.
Call this method after modifying a property of a fact to ensure that the rule engine reconsiders any rules affected by the change. This method removes and re-inserts the fact, triggering rule re-evaluation as appropriate.
| fact | The fact object to refresh in the working memory. Cannot be null. |
| propertyName | The name of the property on the fact that has changed. Cannot be null or empty. |
Implements ReteCore.IReteNode.
| void ReteCore.TerminalNode.Retract | ( | object | fact | ) |
Retracts the specified fact from the rule engine, removing any associated activations or tokens.
If the specified fact is currently part of any pending activations or has previously fired tokens, those will be removed from the agenda and internal state. This operation cancels any pending rule activations related to the fact.
| fact | The fact object to retract. Cannot be null. |
Implements ReteCore.IReteNode.