alice.tuplemedium
Class TupleCentreVMImpl

java.lang.Object
  |
  +--alice.tuplemedium.TupleCentreVM
        |
        +--alice.tuplemedium.TupleCentreVMImpl
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
TupleCentreVM

public class TupleCentreVMImpl
extends TupleCentreVM

This class extends base virtual machine core in order to make the tuple centre reachable with a proper interface and specifying a way to dispatch output events.The concept of VMListener is introduced to identify targets of output communication events.

See Also:
TupleCentreVM, VMListener

Fields inherited from class alice.tuplemedium.TupleCentreVM
bootTime, inputEvents, outputEventSet, reactionSpec, reactor, tSet, wnSet, wpSet, wsSet, zSet
 
Constructor Summary
protected TupleCentreVMImpl()
           
 
Method Summary
 TupleCentreId getId()
          Gets the identifier of the tuple centre
 Event getSpec(TupleTemplate t, AgentId aid, VMListener receiver)
          Sends a getSpec message to the tuple centre virtual machine (the getSpec gets current behaviour specification of the tuple centre)
 Event in(TupleTemplate t, AgentId aid, VMListener receiver)
          Sends an in message to the tuple centre virtual machine (the in gets a matching tuple from tuple centre)
 Event inp(TupleTemplate t, AgentId aid, VMListener receiver)
          Sends an inp message to the tuple centre virtual machine (the inp gets if present a matching tuple from tuple centre)
protected  void notifyOutputEvents()
          Dispatches output events to receivers
 Event out(Tuple t, AgentId aid, VMListener receiver)
          Sends an out message to the tuple centre virtual machine (the out puts a tuple in tuple centre)
 Event rd(TupleTemplate t, AgentId aid, VMListener receiver)
          Sends a rd message to the tuple centre virtual machine (the rd gets without removing a matching tuple from tuple centre)
 Event rdp(TupleTemplate t, AgentId aid, VMListener receiver)
          Sends a rdp message to the tuple centre virtual machine (the rdp gets without removing if present a matching tuple from tuple centre)
 void removeAgentEvents(AgentId id)
          removes all pending events of an agent
 void setArgument(java.lang.Object obj)
          Specifies auxiliary information used to initialize tuple centre virtual machine, which depends on the specific tuple centre model
protected  void setId(TupleCentreId id_)
          Specifies the identifier of the tuple centre
 Event setSpec(Tuple t, AgentId aid, VMListener receiver)
          Sends a setSpec message to the tuple centre virtual machine (the setSpec sets a new behaviour of the tuple centre)
 
Methods inherited from class alice.tuplemedium.TupleCentreVM
acceptEvent, addObservableEventListener, fetchTriggeredReactions, getBootTime, getCurrentTime, getReactor, getTRSet, getTSet, getWnSet, notifyObservableEvent, removeEventsOf, removeObservableEventListener, reset, run, spy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TupleCentreVMImpl

protected TupleCentreVMImpl()
Method Detail

setId

protected void setId(TupleCentreId id_)
Specifies the identifier of the tuple centre
Parameters:
id_ - the identifier

getId

public TupleCentreId getId()
Gets the identifier of the tuple centre
Returns:
the identifier

setArgument

public void setArgument(java.lang.Object obj)
Specifies auxiliary information used to initialize tuple centre virtual machine, which depends on the specific tuple centre model
Parameters:
obj - generic argument

notifyOutputEvents

protected final void notifyOutputEvents()
Dispatches output events to receivers
Overrides:
notifyOutputEvents in class TupleCentreVM

out

public final Event out(Tuple t,
                       AgentId aid,
                       VMListener receiver)
Sends an out message to the tuple centre virtual machine (the out puts a tuple in tuple centre)
Parameters:
t - the tuple argument of the out operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

in

public final Event in(TupleTemplate t,
                      AgentId aid,
                      VMListener receiver)
Sends an in message to the tuple centre virtual machine (the in gets a matching tuple from tuple centre)
Parameters:
t - the tuple argument of the in operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

rd

public final Event rd(TupleTemplate t,
                      AgentId aid,
                      VMListener receiver)
Sends a rd message to the tuple centre virtual machine (the rd gets without removing a matching tuple from tuple centre)
Parameters:
t - the tuple argument of the rd operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

inp

public final Event inp(TupleTemplate t,
                       AgentId aid,
                       VMListener receiver)
Sends an inp message to the tuple centre virtual machine (the inp gets if present a matching tuple from tuple centre)
Parameters:
t - the tuple argument of the inp operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

rdp

public final Event rdp(TupleTemplate t,
                       AgentId aid,
                       VMListener receiver)
Sends a rdp message to the tuple centre virtual machine (the rdp gets without removing if present a matching tuple from tuple centre)
Parameters:
t - the tuple argument of the rdp operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

setSpec

public final Event setSpec(Tuple t,
                           AgentId aid,
                           VMListener receiver)
Sends a setSpec message to the tuple centre virtual machine (the setSpec sets a new behaviour of the tuple centre)
Parameters:
t - the tuple argument of the out operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

getSpec

public final Event getSpec(TupleTemplate t,
                           AgentId aid,
                           VMListener receiver)
Sends a getSpec message to the tuple centre virtual machine (the getSpec gets current behaviour specification of the tuple centre)
Parameters:
t - the tuple argument of the getSpec operation
aid - the identifier of the agent invoking the operation
receiver - the target receiver of output event generated by the virtual machine
Returns:
the communication event generated by the invocation

removeAgentEvents

public final void removeAgentEvents(AgentId id)
removes all pending events of an agent
Parameters:
id - identifier of the agent whose events must be removed