ReteEngine 1.0
A rules engine and builder
Loading...
Searching...
No Matches
ReteCore.AlphaConditionNode< T > Class Template Reference

The AlphaConditionNode class represents a node in a Rete network that applies a simple condition (predicate) to incoming facts. More...

Inheritance diagram for ReteCore.AlphaConditionNode< T >:
ReteCore.IReteNode

Public Member Functions

 AlphaConditionNode (string propertytName, Func< T, bool > predicate, IReteNode successor)
 This constructor initializes a new instance of the AlphaConditionNode class with the specified property name, predicate, and successor node. The property name is used for selective re-evaluation when facts change, while the predicate defines the condition that facts must satisfy to be propagated to the successor. The successor node is where facts that pass the condition will be sent for further processing in the Rete network. This constructor sets up the necessary components for the AlphaConditionNode to function as a filter within the Rete algorithm, allowing it to efficiently evaluate incoming facts and manage their flow through the network based on defined conditions.
void AddSuccessor (IReteNode node)
 An AlphaConditionNode typically has one successor, which is often an AlphaMemory node that stores facts that pass the condition. The AddSuccessor method is provided for completeness, but in a typical Rete implementation, the successor is set at construction and does not change dynamically. If you want to support multiple successors, you would need to modify this class to maintain.
void Assert (object fact)
 Assert a fact into the AlphaConditionNode. The node checks if the fact is of type T and if it satisfies the predicate. If both conditions are met, the fact is passed to the successor node. This method is called when a new fact is introduced into the Rete network or when an existing fact is updated and needs to be re-evaluated.
void Retract (object fact)
 Retract a fact from the AlphaConditionNode. Similar to Assert, it checks if the fact is of type T and satisfies the predicate. If it does, it tells the successor node to retract this fact. This method is called when a fact is removed from the Rete network or when an existing fact is updated and no longer satisfies the condition, necessitating its removal from downstream nodes.
void Refresh (object fact, string changedProperty)
 Refresh a fact in the AlphaConditionNode. This method is called when a property of a fact changes, and it allows the node to re-evaluate the condition for that fact. If the changed property matches TargetProperty (or if TargetProperty is null/empty), the node will first retract the old fact from the successor and then assert the updated fact, ensuring that downstream nodes have the correct state based on the new information.
void DebugPrint (object fact, int level=0)
 This method is used for debugging purposes to print the structure of the Rete network and the evaluation results of facts at this node.

Properties

string TargetProperty [get]
 The name of the property that this AlphaConditionNode is interested in. This is used for selective re-evaluation when a fact changes. If the changed property matches TargetProperty, the node will re-evaluate the condition for that fact. If TargetProperty is null or empty, it will re-evaluate for any change, which is less efficient but necessary if the condition depends on multiple properties or the entire object state.

Detailed Description

The AlphaConditionNode class represents a node in a Rete network that applies a simple condition (predicate) to incoming facts.

Template Parameters
TThe fact is of this type.

Member Function Documentation

◆ AddSuccessor()

void ReteCore.AlphaConditionNode< T >.AddSuccessor ( IReteNode node)

An AlphaConditionNode typically has one successor, which is often an AlphaMemory node that stores facts that pass the condition. The AddSuccessor method is provided for completeness, but in a typical Rete implementation, the successor is set at construction and does not change dynamically. If you want to support multiple successors, you would need to modify this class to maintain.

Parameters
nodeThe node to add as a successor. Cannot be null.

◆ AlphaConditionNode()

ReteCore.AlphaConditionNode< T >.AlphaConditionNode ( string propertytName,
Func< T, bool > predicate,
IReteNode successor )

This constructor initializes a new instance of the AlphaConditionNode class with the specified property name, predicate, and successor node. The property name is used for selective re-evaluation when facts change, while the predicate defines the condition that facts must satisfy to be propagated to the successor. The successor node is where facts that pass the condition will be sent for further processing in the Rete network. This constructor sets up the necessary components for the AlphaConditionNode to function as a filter within the Rete algorithm, allowing it to efficiently evaluate incoming facts and manage their flow through the network based on defined conditions.

Parameters
propertytNameThe name of the fact
predicateThe filtering condition. All facts that satisfy this condition are propagated forward.
successorThe successor node to propagate the fact to.

◆ Assert()

void ReteCore.AlphaConditionNode< T >.Assert ( object fact)

Assert a fact into the AlphaConditionNode. The node checks if the fact is of type T and if it satisfies the predicate. If both conditions are met, the fact is passed to the successor node. This method is called when a new fact is introduced into the Rete network or when an existing fact is updated and needs to be re-evaluated.

Parameters
factThe fact object to be asserted and passed to successor nodes. Cannot be null.

Implements ReteCore.IReteNode.

◆ DebugPrint()

void ReteCore.AlphaConditionNode< T >.DebugPrint ( object fact,
int level = 0 )

This method is used for debugging purposes to print the structure of the Rete network and the evaluation results of facts at this node.

Parameters
factThe fact object to include in the debug output. Can be any object; its string representation will be printed.
levelThe indentation level to apply to the debug message. Each level increases indentation by spaces. Defaults to 0.

Implements ReteCore.IReteNode.

◆ Refresh()

void ReteCore.AlphaConditionNode< T >.Refresh ( object fact,
string changedProperty )

Refresh a fact in the AlphaConditionNode. This method is called when a property of a fact changes, and it allows the node to re-evaluate the condition for that fact. If the changed property matches TargetProperty (or if TargetProperty is null/empty), the node will first retract the old fact from the successor and then assert the updated fact, ensuring that downstream nodes have the correct state based on the new information.

Parameters
factThe fact object whose property is being refreshed. Cannot be null.
changedPropertyThe name of the property to refresh. Cannot be null or empty.

Implements ReteCore.IReteNode.

◆ Retract()

void ReteCore.AlphaConditionNode< T >.Retract ( object fact)

Retract a fact from the AlphaConditionNode. Similar to Assert, it checks if the fact is of type T and satisfies the predicate. If it does, it tells the successor node to retract this fact. This method is called when a fact is removed from the Rete network or when an existing fact is updated and no longer satisfies the condition, necessitating its removal from downstream nodes.

Parameters
factThe fact object to retract. Cannot be null.

Implements ReteCore.IReteNode.


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