public abstract class AbstractProtocol extends java.lang.Object implements Protocol
Modifier and Type | Field and Description |
---|---|
private java.util.Set<ProtocolListener> |
listener
The listener of this protocol.
|
private MultiAgentSystem<? extends Agent> |
multiAgentSystem
The multi-agent system this protocol operates on.
|
Constructor and Description |
---|
AbstractProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem)
Creates a new protocol for the given multi-agent system.
|
Modifier and Type | Method and Description |
---|---|
void |
addProtocolListener(ProtocolListener listener)
Adds the given listener to this protocol.
|
protected abstract java.util.Set<ActionEvent> |
doStep()
Executes one step of the protocol.
|
protected MultiAgentSystem<? extends Agent> |
getMultiAgentSystem()
Returns the multi-agent system this protocol operates on.
|
protected abstract boolean |
hasTerminated()
This method determines if this protocol has terminated,
i.e.
|
protected void |
notifyActionPerformed(ActionEvent actionEvent)
Notifies every listener about the given event.
|
protected void |
notifyTerminated()
Notifies every listener that this protocol has terminated.
|
boolean |
removeProtocolListener(ProtocolListener listener)
Removes the given protocol listener from this protocol.
|
protected void |
step()
Executes one step of the protocol.
|
private MultiAgentSystem<? extends Agent> multiAgentSystem
private java.util.Set<ProtocolListener> listener
public AbstractProtocol(MultiAgentSystem<? extends Agent> multiAgentSystem)
multiAgentSystem
- a multi-agent system.protected MultiAgentSystem<? extends Agent> getMultiAgentSystem()
protected abstract boolean hasTerminated()
protected final void step() throws ProtocolTerminatedException
ProtocolTerminatedException
- if the protocol has already terminated.protected abstract java.util.Set<ActionEvent> doStep() throws ProtocolTerminatedException
ProtocolTerminatedException
public void addProtocolListener(ProtocolListener listener)
Protocol
addProtocolListener
in interface Protocol
listener
- a protocol listener.public boolean removeProtocolListener(ProtocolListener listener)
Protocol
removeProtocolListener
in interface Protocol
listener
- a protocol listener.protected void notifyTerminated()
protected void notifyActionPerformed(ActionEvent actionEvent)
actionEvent
- an action event.