net.sourceforge.jabm.strategy
Class AbstractStrategy

java.lang.Object
  extended by net.sourceforge.jabm.strategy.AbstractStrategy
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, EventListener, Strategy
Direct Known Subclasses:
AbstractRlStrategy

public abstract class AbstractStrategy
extends java.lang.Object
implements Strategy, java.lang.Cloneable, java.io.Serializable

See Also:
Serialized Form
 

Field Summary
protected  Agent agent
           
protected  EventScheduler scheduler
           
 
Constructor Summary
AbstractStrategy()
           
AbstractStrategy(Agent agent)
           
AbstractStrategy(EventScheduler scheduler, Agent agent)
           
 
Method Summary
 java.lang.Object clone()
           
 void eventOccurred(SimEvent event)
           
 void execute(java.util.List<Agent> otherAgents)
          Execute the behaviour defined by this strategy.
 void fireEvent(SimEvent event)
           
 Agent getAgent()
           
 EventScheduler getScheduler()
           
 void onSimulationFinished()
           
 void setAgent(Agent agent)
          Configure the agent associated with this strategy.
 void setScheduler(EventScheduler scheduler)
           
 void subscribeToEvents()
           
 void subscribeToEvents(EventScheduler scheduler)
          A Strategy should subscribe to any events it wants to receive by calling the addListener method in the EventScheduler class.
 void unsubscribeFromEvents()
          The strategy should call EventScheduler.removeListener() to unsubscribe from events when this method is called.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agent

protected Agent agent

scheduler

protected EventScheduler scheduler
Constructor Detail

AbstractStrategy

public AbstractStrategy()

AbstractStrategy

public AbstractStrategy(Agent agent)

AbstractStrategy

public AbstractStrategy(EventScheduler scheduler,
                        Agent agent)
Method Detail

getAgent

public Agent getAgent()
Specified by:
getAgent in interface Strategy

setAgent

public void setAgent(Agent agent)
Description copied from interface: Strategy
Configure the agent associated with this strategy.

Specified by:
setAgent in interface Strategy

subscribeToEvents

public void subscribeToEvents(EventScheduler scheduler)
Description copied from interface: Strategy
A Strategy should subscribe to any events it wants to receive by calling the addListener method in the EventScheduler class.

Specified by:
subscribeToEvents in interface Strategy
Parameters:
scheduler - The EventScheduler on which to listen.

subscribeToEvents

public void subscribeToEvents()

setScheduler

public void setScheduler(EventScheduler scheduler)

getScheduler

public EventScheduler getScheduler()

unsubscribeFromEvents

public void unsubscribeFromEvents()
Description copied from interface: Strategy
The strategy should call EventScheduler.removeListener() to unsubscribe from events when this method is called. This hook is used to clean-up, for example when the strategy is disposed of.

Specified by:
unsubscribeFromEvents in interface Strategy

eventOccurred

public void eventOccurred(SimEvent event)
Specified by:
eventOccurred in interface EventListener

onSimulationFinished

public void onSimulationFinished()

execute

public void execute(java.util.List<Agent> otherAgents)
Description copied from interface: Strategy
Execute the behaviour defined by this strategy.

Specified by:
execute in interface Strategy
Parameters:
otherAgents - The other agents with which the agent associated with this strategy is interacting.

fireEvent

public void fireEvent(SimEvent event)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Specified by:
clone in interface Strategy
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException