/** * Check the consistency of the node. */ public boolean checkNodeConsistency(ReteMemory mem) { // Mark node as checked (for debugging). Object node = this; while(!(node instanceof ReteNode)) { if(node instanceof IObjectConsumerNode) { node = ((IObjectConsumerNode)node).getObjectSource(); } else if(node instanceof ITupleConsumerNode) { node = ((ITupleConsumerNode)node).getTupleSource(); } else { throw new RuntimeException("Unhandled node type: "+node); } } ((ReteNode)node).checked.add(this); // Empty default implementation. return true; } }
/** * Propagate a new tuple to all tuple consumers. * @param tuple The new tuple. */ protected void propagateAdditionToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { ITupleConsumerNode[] tcon = tconsumers; for(int i=0; tcon!=null && i<tcon.length; i++) tcon[i].addTuple(tuple, state, mem, agenda); }
/** * Do clone makes a deep clone without regarding cycles. * Method is overridden by subclasses to actually incorporate their attributes. * @param theclone The clone. */ protected void doClone(Object theclone) { InitialFactNode clone = (InitialFactNode)theclone; // Deep clone tuple consumers clone.tconsumers = new ITupleConsumerNode[tconsumers.length]; for(int i=0; i<tconsumers.length; i++) clone.tconsumers[i] = (ITupleConsumerNode)tconsumers[i].clone(); // Set the source clone.osource = (IObjectSourceNode)osource.clone(); } }
for(int i=0; i<tconsumers.length; i++) ret.tconsumers[i] = (ITupleConsumerNode)tconsumers[i].clone(); ret.tconsumers[i].setTupleSource(ret);
ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(left, state, mem, agenda); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(left, state, mem, agenda); tcs[j].modifyTuple(left, tupleindex, type, oldvalue, newvalue, state, mem, agenda); tcs[j].modifyTuple(left, tupleindex, type, oldvalue, newvalue, state, mem, agenda);
ITupleSourceNode source = consumer.getTupleSource(); consumer.setTupleSource(null); source.removeTupleConsumer(consumer); removeNodeUsage(source);
/** * Propagate a removed tuple to all tuple consumers. * @param object The new object. */ protected void propagateRemovalToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { ITupleConsumerNode[] tcon = tconsumers; for(int i=0; tcon!=null && i<tcon.length; i++) tcon[i].removeTuple(tuple, state, mem, agenda); }
/** * Get the set of relevant attribute types. */ public AttributeSet getRelevantAttributes() { if(relevants==null) { synchronized(this) { if(relevants==null) { AttributeSet relevants = new AttributeSet(); for(int i=0; tconsumers!=null && i<tconsumers.length; i++) { relevants.addAll(tconsumers[i].getRelevantAttributes()); } this.relevants = relevants; } } } return relevants; }
/** * Propagate a modified tuple to all tuple consumers. * @param tuple The new tuple. */ protected void propagateModificationToTupleConsumers(Tuple tuple, int tupleindex, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { ITupleConsumerNode[] tcon = tconsumers; for(int i=0; tcon!=null && i<tcon.length; i++) tcon[i].modifyTuple(tuple, tupleindex, type, oldvalue, newvalue, state, mem, agenda); }
ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(left, state, mem, agenda); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(left, state, mem, agenda);
c.setTupleSource(s); c.setTupleSource(lia); lia.addTupleConsumer(c);
ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(left, state, mem, agenda); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(left, state, mem, agenda); tcs[j].modifyTuple(left, tupleindex, type, oldvalue, newvalue, state, mem, agenda); tcs[j].modifyTuple(left, tupleindex, type, oldvalue, newvalue, state, mem, agenda);
ITupleSourceNode source = consumer.getTupleSource(); consumer.setTupleSource(null); source.removeTupleConsumer(consumer); removeNodeUsage(source);
/** * Propagate a removed tuple to all tuple consumers. * @param object The new object. */ protected void propagateRemovalToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { ITupleConsumerNode[] tcon = tconsumers; for(int i=0; tcon!=null && i<tcon.length; i++) tcon[i].removeTuple(tuple, state, mem, agenda); }
/** * Get the set of relevant attribute types. */ public AttributeSet getRelevantAttributes() { if(relevants==null) { synchronized(this) { if(relevants==null) { AttributeSet relevants = new AttributeSet(); for(int i=0; tconsumers!=null && i<tconsumers.length; i++) { relevants.addAll(tconsumers[i].getRelevantAttributes()); } this.relevants = relevants; } } } return relevants; }
/** * Propagate a modified object to all object consumers. * @param object The new object. */ protected void propagateModificationToTupleConsumers(Tuple tuple, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { ITupleConsumerNode[] tcon = tconsumers; for(int i=0; tcon!=null && i<tcon.length; i++) tcon[i].modifyTuple(tuple, tupleindex, type, oldvalue, newvalue, state, mem, agenda); }
for(int i=0; i<tconsumers.length; i++) ret.tconsumers[i] = (ITupleConsumerNode)tconsumers[i].clone(); ret.tconsumers[i].setTupleSource(ret);
ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(left, state, mem, agenda); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(left, state, mem, agenda);
c.setTupleSource(s); c.setTupleSource(lia); lia.addTupleConsumer(c);
/** * Propagate a new tuple to all tuple consumers. * @param object The new object. */ protected void propagateAdditionToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { ITupleConsumerNode[] tcon = tconsumers; for(int i=0; tcon!=null && i<tcon.length; i++) tcon[i].addTuple(tuple, state, mem, agenda); }