/** * Notification when an object has been removed from state. * @param id The object id. * @param type The object type. */ public void objectRemoved(Object id, OAVObjectType type) { assert !running; running = true; state.getProfiler().start(IProfiler.TYPE_OBJECT, type); state.getProfiler().start(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_REMOVED); node.removeObject(id, type, state, retemem, agenda); state.getProfiler().stop(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_REMOVED); state.getProfiler().stop(IProfiler.TYPE_OBJECT, type); running = false; }
/** * Notification when an object has been removed from state. * @param id The object id. * @param type The object type. */ public void objectRemoved(Object id, OAVObjectType type) { assert !running; running = true; state.getProfiler().start(IProfiler.TYPE_OBJECT, type); state.getProfiler().start(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_REMOVED); node.removeObject(id, type, state, retemem, agenda); state.getProfiler().stop(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_REMOVED); state.getProfiler().stop(IProfiler.TYPE_OBJECT, type); running = false; }
/** * Notification when an object has been added to the state. * @param id The object id. * @param type The object type. */ public void objectAdded(Object id, OAVObjectType type, boolean root) { assert !running; running = true; state.getProfiler().start(IProfiler.TYPE_OBJECT, type); state.getProfiler().start(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_ADDED); node.addObject(id, type, state, retemem, agenda); state.getProfiler().stop(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_ADDED); state.getProfiler().stop(IProfiler.TYPE_OBJECT, type); running = false; }
/** * Notification when an object has been added to the state. * @param id The object id. * @param type The object type. */ public void objectAdded(Object id, OAVObjectType type, boolean root) { assert !running; running = true; state.getProfiler().start(IProfiler.TYPE_OBJECT, type); state.getProfiler().start(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_ADDED); node.addObject(id, type, state, retemem, agenda); state.getProfiler().stop(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_ADDED); state.getProfiler().stop(IProfiler.TYPE_OBJECT, type); running = false; }
/** * Notification when an attribute value of an object has been set. * @param id The object id. * @param type The object type. * @param attr The attribute type. * @param oldvalue The oldvalue. * @param newvalue The newvalue. */ public void objectModified(Object id, OAVObjectType type, OAVAttributeType attr, Object oldvalue, Object newvalue) { assert !running; running = true; state.getProfiler().start(IProfiler.TYPE_OBJECT, type); state.getProfiler().start(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_MODIFIED); node.modifyObject(id, type, attr, oldvalue, newvalue, state, retemem, agenda); state.getProfiler().stop(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_MODIFIED); state.getProfiler().stop(IProfiler.TYPE_OBJECT, type); running = false; }
/** * Notification when an attribute value of an object has been set. * @param id The object id. * @param type The object type. * @param attr The attribute type. * @param oldvalue The oldvalue. * @param newvalue The newvalue. */ public void objectModified(Object id, OAVObjectType type, OAVAttributeType attr, Object oldvalue, Object newvalue) { assert !running; running = true; state.getProfiler().start(IProfiler.TYPE_OBJECT, type); state.getProfiler().start(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_MODIFIED); node.modifyObject(id, type, attr, oldvalue, newvalue, state, retemem, agenda); state.getProfiler().stop(IProfiler.TYPE_OBJECTEVENT, IProfiler.OBJECTEVENT_MODIFIED); state.getProfiler().stop(IProfiler.TYPE_OBJECT, type); running = false; }
/** * Send a removed object to this node. * @param object The object. */ public void removeObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); if(mem.hasNodeMemory(this) && ((Collection)mem.getNodeMemory(this)).remove(object)) { //System.out.println("Object passed constraint check: "+this+" "+object); propagateRemovalToObjectConsumers(object, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // System.out.println("Remove Tuple: "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); // Get old assignments. Map nodemem = (Map)mem.getNodeMemory(this); ReteVariableAssignments assignments = (ReteVariableAssignments)nodemem.remove(tuple); // Activation act = new Activation(rule, new ReteVariableAssignments(state, tuple, extractors)); Activation act = new Activation(rule, assignments, state); agenda.removeActivation(act); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send an object to this node. * @param object The object. */ public void addObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); amem.add(tuple); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(tuple, state, mem, agenda); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send a removed object to this node. * @param object The object. */ public void removeObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); if(mem.hasNodeMemory(this) && ((Collection)mem.getNodeMemory(this)).remove(object)) { //System.out.println("Object passed constraint check: "+this+" "+object); propagateRemovalToObjectConsumers(object, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Add a new tuple to this node. * @param tuple The tuple. */ public void addTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add tuple called: "+this+" "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); Collection tmem = (Collection)mem.getNodeMemory(this); if(!tmem.contains(tuple) && evaluator.evaluate(null, tuple, state)) { tmem.add(tuple); //System.out.println("Tuple passed constraint check: "+this+" "+object); propagateAdditionToTupleConsumers(tuple, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send an object to this node. * @param object The object. */ public void addObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); amem.add(tuple); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].addTuple(tuple, state, mem, agenda); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove tuple called: "+this+" "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); if(mem.hasNodeMemory(this)) { if(((Collection)mem.getNodeMemory(this)).remove(tuple)) { propagateRemovalToTupleConsumers(tuple, state, mem, agenda); } } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove tuple called: "+this+" "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); if(mem.hasNodeMemory(this)) { if(((Collection)mem.getNodeMemory(this)).remove(tuple)) { propagateRemovalToTupleConsumers(tuple, state, mem, agenda); } } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Add a new tuple to this node. * @param tuple The tuple. */ public void addTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add tuple called: "+this+" "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); Collection tmem = (Collection)mem.getNodeMemory(this); if(!tmem.contains(tuple) && evaluator.evaluate(null, tuple, state)) { tmem.add(tuple); //System.out.println("Tuple passed constraint check: "+this+" "+object); propagateAdditionToTupleConsumers(tuple, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // System.out.println("Remove Tuple: "+tuple); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); // Get old assignments. Map nodemem = (Map)mem.getNodeMemory(this); ReteVariableAssignments assignments = (ReteVariableAssignments)nodemem.remove(tuple); // Activation act = new Activation(rule, new ReteVariableAssignments(state, tuple, extractors)); Activation act = new Activation(rule, assignments, state); agenda.removeActivation(act); state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_TUPLEREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Propagate an object change to this node. * @param object The new object. */ public void modifyObject(Object object, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); if(getRelevantAttributes().contains(type)) { // Check if modification changes node memory. Tuple tuple = mem.getTuple(state, null, object); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].modifyTuple(tuple, 0, type, oldvalue, newvalue, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send a removed object to this node. * @param object The object. */ public void removeObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Remove object called: "+this+" "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); if(mem.hasNodeMemory(this)) { Collection amem = (Collection)mem.getNodeMemory(this); Tuple tuple = mem.getTuple(state, null, object); if(amem.remove(tuple)) { ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].removeTuple(tuple, state, mem, agenda); } } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTREMOVED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Send a new object to this node. * @param object The object. */ public void addObject(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { //System.out.println("Add object called: "+this+" "+object); // if(object.getClass().toString().indexOf("Order")!=-1) // System.out.println("here: "+object); // if(state.getType(object).getName().indexOf("goal")!=-1) // System.out.println("here: "+object); state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); assert !mem.hasNodeMemory(this) || !((Collection)mem.getNodeMemory(this)).contains(object) : "New objects shouldn't be contained."; if(checkConstraints(object, state)) { ((Collection)mem.getNodeMemory(this)).add(object); //System.out.println("Object passed constraint check: "+this+" "+object); propagateAdditionToObjectConsumers(object, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTADDED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }
/** * Propagate an object change to this node. * @param object The new object. */ public void modifyObject(Object object, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { state.getProfiler().start(IProfiler.TYPE_NODE, this); state.getProfiler().start(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); if(getRelevantAttributes().contains(type)) { // Check if modification changes node memory. Tuple tuple = mem.getTuple(state, null, object); ITupleConsumerNode[] tcs = tconsumers; for(int j=0; tcs!=null && j<tcs.length; j++) tcs[j].modifyTuple(tuple, 0, type, oldvalue, newvalue, state, mem, agenda); } state.getProfiler().stop(IProfiler.TYPE_NODEEVENT, IProfiler.NODEEVENT_OBJECTMODIFIED); state.getProfiler().stop(IProfiler.TYPE_NODE, this); }