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

The IndexedExistsNode class represents a node in a Rete network that efficiently implements the "exists" condition by maintaining indexed collections of tokens and facts. The left side of the node (tokens) is indexed by a key extracted from the tokens, while the right side (facts) is indexed by a key extracted from the facts. More...

Inheritance diagram for ReteCore.IndexedExistsNode:
ReteCore.IReteNode

Public Member Functions

 IndexedExistsNode (string name, Func< Token, object > leftKey, Func< object, object > rightKey)
 The constructor for the IndexedExistsNode takes a name for identification, and two selector functions that extract the join key from tokens and facts.
void AddSuccessor (IReteNode node)
 Adds a successor node to this IndexedExistsNode. Successors will receive propagated assertions and retractions when matches are found or lost.
void Assert (object factOrToken)
 The Assert method takes either a Token (from the left side) or a fact (from the right side) and updates the internal indexes accordingly. It then propagates assertions to successors if matches are found.
void AssertLeft (Token token)
 Asserts a token on the left side of the node. It updates the left index and checks for matches on the right side using the extracted key. If matches are found, it propagates assertions to successors.
void AssertRight (object fact)
 Asserts a fact on the right side of the node. It updates the right index and checks for matches on the left side using the extracted key. If matches are found, it propagates assertions to successors.
void Retract (object factOrToken)
 The Retract method takes either a Token (from the left side) or a fact (from the right side) and updates the internal indexes accordingly. It then propagates retractions to successors if matches are lost.
void RetractLeft (Token token)
 Retracts a token from the left side of the node. It updates the left index and checks for matches on the right side using the extracted key. If matches are lost, it propagates retractions to successors.
void RetractRight (object fact)
 Retracts a fact from the right side of the node. It updates the right index and checks for matches on the left side using the extracted key. If matches are lost, it propagates retractions to successors.
void Refresh (object fact, string propertyName)
 The Refresh method is used to update the state of a fact or token in the node without changing its presence. For simplicity, we will treat Refresh as a Retract followed by an Assert, which will trigger the necessary updates to successor nodes based on the current state of matches.
void DebugPrint (object fact, int level=0)
 Prints the internal state of the node for debugging purposes. It shows the current tokens and facts in the indexes, as well as the matches for each token. This can be useful for understanding how the node is processing assertions and retractions.

Detailed Description

The IndexedExistsNode class represents a node in a Rete network that efficiently implements the "exists" condition by maintaining indexed collections of tokens and facts. The left side of the node (tokens) is indexed by a key extracted from the tokens, while the right side (facts) is indexed by a key extracted from the facts.

Constructor & Destructor Documentation

◆ IndexedExistsNode()

ReteCore.IndexedExistsNode.IndexedExistsNode ( string name,
Func< Token, object > leftKey,
Func< object, object > rightKey )

The constructor for the IndexedExistsNode takes a name for identification, and two selector functions that extract the join key from tokens and facts.

Parameters
nameThe name of this node as identification.
leftKeyThe left token selector function.
rightKeyThe right fact selector function.

Member Function Documentation

◆ AddSuccessor()

void ReteCore.IndexedExistsNode.AddSuccessor ( IReteNode node)

Adds a successor node to this IndexedExistsNode. Successors will receive propagated assertions and retractions when matches are found or lost.

Parameters
nodeThe node to add this node to as a successor.

◆ Assert()

void ReteCore.IndexedExistsNode.Assert ( object factOrToken)

The Assert method takes either a Token (from the left side) or a fact (from the right side) and updates the internal indexes accordingly. It then propagates assertions to successors if matches are found.

Parameters
factOrTokenThe fact or token this operation is acting upon.

Implements ReteCore.IReteNode.

◆ AssertLeft()

void ReteCore.IndexedExistsNode.AssertLeft ( Token token)

Asserts a token on the left side of the node. It updates the left index and checks for matches on the right side using the extracted key. If matches are found, it propagates assertions to successors.

Parameters
tokenThe token this operation is acting upon.

◆ AssertRight()

void ReteCore.IndexedExistsNode.AssertRight ( object fact)

Asserts a fact on the right side of the node. It updates the right index and checks for matches on the left side using the extracted key. If matches are found, it propagates assertions to successors.

Parameters
factThe fact this operation is acting upon.

◆ DebugPrint()

void ReteCore.IndexedExistsNode.DebugPrint ( object fact,
int level = 0 )

Prints the internal state of the node for debugging purposes. It shows the current tokens and facts in the indexes, as well as the matches for each token. This can be useful for understanding how the node is processing assertions and retractions.

Parameters
factThe fact whose information is to be output.
levelA level of indentation.

Implements ReteCore.IReteNode.

◆ Refresh()

void ReteCore.IndexedExistsNode.Refresh ( object fact,
string propertyName )

The Refresh method is used to update the state of a fact or token in the node without changing its presence. For simplicity, we will treat Refresh as a Retract followed by an Assert, which will trigger the necessary updates to successor nodes based on the current state of matches.

Parameters
factOrTokenThe fact or token this operation is acting upon.
propertyNameThe name of the property in the fact cell that is being updated.

Implements ReteCore.IReteNode.

◆ Retract()

void ReteCore.IndexedExistsNode.Retract ( object factOrToken)

The Retract method takes either a Token (from the left side) or a fact (from the right side) and updates the internal indexes accordingly. It then propagates retractions to successors if matches are lost.

Parameters
factOrTokenThe fact or token this operation is acting upon.

Implements ReteCore.IReteNode.

◆ RetractLeft()

void ReteCore.IndexedExistsNode.RetractLeft ( Token token)

Retracts a token from the left side of the node. It updates the left index and checks for matches on the right side using the extracted key. If matches are lost, it propagates retractions to successors.

Parameters
tokenThe token this operation is acting upon.

◆ RetractRight()

void ReteCore.IndexedExistsNode.RetractRight ( object fact)

Retracts a fact from the right side of the node. It updates the right index and checks for matches on the left side using the extracted key. If matches are lost, it propagates retractions to successors.

Parameters
factThe fact this operation is acting upon.

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