public class ReteNode extends AbstractNode implements IObjectSourceNode
Modifier and Type | Field and Description |
---|---|
protected ReteBuilder |
builder
The rete builder.
|
protected int |
changecnt |
protected boolean |
check
Do a consistency check after each state change (requires asserts).
|
protected java.util.List |
checked |
protected java.util.Map |
indirectnodesets
Indirectly affected nodes for an attribute type (cached for speed).
|
protected boolean |
inited
For debugging: node is inited and network must not be changed anymore.
|
protected InitialFactNode |
initialfact
The initial fact node (if any).
|
protected int |
nodecounter
The node counter in this network.
|
protected AttributeSet |
relevants
The set of relevant attributes.
|
protected java.util.Map |
terminalnodes
The terminal nodes (IRule -> Node).
|
protected java.util.Map |
typenodes
The type nodes.
|
protected java.util.Map |
typenodesets
Matching nodes for each (sub)type (cached for speed).
|
clones, nodeid
Constructor and Description |
---|
ReteNode()
Create a new rete system.
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(java.lang.Object id,
OAVObjectType type,
IOAVState state,
ReteMemory mem,
AbstractAgenda agenda)
Tell the condition system about a
new object in the state.
|
void |
addObjectConsumer(IObjectConsumerNode node)
Add an object consumer node.
|
void |
addRule(IRule rule)
Add a rule to the network.
|
protected boolean |
checkConsistency(ReteMemory mem)
Check consistency of Rete network/memory.
|
java.lang.Object |
createNodeMemory(IOAVState state)
Create the node memory.
|
protected void |
doClone(java.lang.Object theclone)
Do clone makes a deep clone without regarding cycles.
|
ReteBuilder |
getBuilder()
Get the builder.
|
AttributeSet |
getIndirectAttributes()
Get the set of indirect attribute types.
|
protected java.util.Set |
getIndirectNodes(OAVAttributeType attrtype,
OAVTypeModel tmodel)
Get the set of indirectly affected nodes for an attribute type.
|
InitialFactNode |
getInitialFactNode()
Get the initial fact node (if any).
|
int |
getNextNodeId()
Get the next nodecounter.
|
int |
getNodeCount()
Get the number of nodes in the network.
|
java.util.Collection |
getNodeMemory(ReteMemory mem)
Get the memory for this node.
|
IObjectConsumerNode[] |
getObjectConsumers()
Get all object consumer nodes.
|
AttributeSet |
getRelevantAttributes()
Get the set of relevant attribute types.
|
TerminalNode |
getTerminalNode(IRule rule)
Set the terminal node for a rule.
|
TypeNode |
getTypeNode(OAVObjectType type)
Get the node for a type.
|
protected java.util.Set |
getTypeNodes(OAVObjectType type)
Get the set of matching type nodes for a (sub)type.
|
void |
modifyIndirectObject(java.lang.Object object,
OAVAttributeType type,
java.lang.Object oldvalue,
java.lang.Object newvalue,
IOAVState state,
ReteMemory mem,
AbstractAgenda agenda)
Propagate an indirect object change to this node.
|
void |
modifyObject(java.lang.Object id,
OAVObjectType type,
OAVAttributeType attr,
java.lang.Object oldvalue,
java.lang.Object newvalue,
IOAVState state,
ReteMemory mem,
AbstractAgenda agenda)
Tell the condition system about a
modified object in the state.
|
void |
putTerminalNode(TerminalNode node)
Set the terminal node for a rule.
|
void |
removeObject(java.lang.Object id,
OAVObjectType type,
IOAVState state,
ReteMemory mem,
AbstractAgenda agenda)
Tell the condition system about a
removed object in the state.
|
void |
removeObjectConsumer(IObjectConsumerNode node)
Remove an object consumer.
|
void |
removeRule(IRule rule)
Remove a rule from the network.
|
void |
setInited(boolean inited)
Set the inited state.
|
checkNodeConsistency, clone, equals, getNodeId, hashCode, toString, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
checkNodeConsistency, clone, getNodeId
protected java.util.Map typenodes
protected java.util.Map typenodesets
protected volatile java.util.Map indirectnodesets
protected InitialFactNode initialfact
protected java.util.Map terminalnodes
protected ReteBuilder builder
protected volatile AttributeSet relevants
protected boolean check
protected int nodecounter
protected boolean inited
protected int changecnt
protected java.util.List checked
public ReteNode()
state
- The state.public void addObject(java.lang.Object id, OAVObjectType type, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
object
- The new object.public void removeObject(java.lang.Object id, OAVObjectType type, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
object
- The removed object.public void modifyObject(java.lang.Object id, OAVObjectType type, OAVAttributeType attr, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
object
- The new object.public void modifyIndirectObject(java.lang.Object object, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
modifyIndirectObject
in interface INode
object
- The changed object.public void addRule(IRule rule)
rule
- The rule to add.public void removeRule(IRule rule)
rule
- The rule to remove.public void putTerminalNode(TerminalNode node)
rule
- The rule.node
- The node.public TerminalNode getTerminalNode(IRule rule)
rule
- The rule.node
- The node.public int getNodeCount()
public void addObjectConsumer(IObjectConsumerNode node)
addObjectConsumer
in interface IObjectSourceNode
node
- A new consumer node.public void removeObjectConsumer(IObjectConsumerNode node)
removeObjectConsumer
in interface IObjectSourceNode
node
- The consumer node.public java.util.Collection getNodeMemory(ReteMemory mem)
getNodeMemory
in interface INode
getNodeMemory
in interface IObjectSourceNode
public IObjectConsumerNode[] getObjectConsumers()
getObjectConsumers
in interface IObjectSourceNode
public TypeNode getTypeNode(OAVObjectType type)
type
- The type.public InitialFactNode getInitialFactNode()
public java.lang.Object createNodeMemory(IOAVState state)
createNodeMemory
in interface INode
state
- The state.public AttributeSet getRelevantAttributes()
getRelevantAttributes
in interface INode
public AttributeSet getIndirectAttributes()
getIndirectAttributes
in interface INode
public ReteBuilder getBuilder()
protected java.util.Set getTypeNodes(OAVObjectType type)
type
- The object type.protected java.util.Set getIndirectNodes(OAVAttributeType attrtype, OAVTypeModel tmodel)
attrtype
- The attribute type.tmodel
- The OAV type model.protected void doClone(java.lang.Object theclone)
doClone
in class AbstractNode
clone
- The clone.protected boolean checkConsistency(ReteMemory mem)
public int getNextNodeId()
public void setInited(boolean inited)