ReteEngine 1.0
A rules engine and builder
Loading...
Searching...
No Matches
ReteCore.TerminalNode Class Reference

Represents a terminal node in a Rete network that schedules rule activations when matching facts are asserted. More...

Inheritance diagram for ReteCore.TerminalNode:
ReteCore.IReteNode

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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ 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.

Parameters
nameThe name of the rule associated with this terminal node. Cannot be null.
actionThe action to execute when the terminal node is activated. Cannot be null.
agendaThe agenda that manages the execution order of rules. Cannot be null.
salienceThe priority of the rule. Higher values indicate higher priority. The default is 0.

Member Function Documentation

◆ AddSuccessor()

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.

Parameters
nodeThe node that would be added as a successor. This parameter is ignored.

◆ Assert()

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.

Parameters
factThe fact to assert. Must be a non-null object of type Token to be considered for activation.

Implements ReteCore.IReteNode.

◆ DebugPrint()

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.

Parameters
factThe fact object to include in the debug output. This object is converted to a string using its ToString method.
levelThe indentation level for the output. Each level increases the indentation by two spaces. The default is 0.

Implements ReteCore.IReteNode.

◆ Refresh()

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.

Parameters
factThe fact object to refresh in the working memory. Cannot be null.
propertyNameThe name of the property on the fact that has changed. Cannot be null or empty.

Implements ReteCore.IReteNode.

◆ Retract()

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.

Parameters
factThe fact object to retract. Cannot be null.

Implements ReteCore.IReteNode.


The documentation for this class was generated from the following file:
  • ReteCore/TerminalNode.cs