sim.engine
Class TentativeStep

java.lang.Object
  extended by sim.engine.TentativeStep
All Implemented Interfaces:
java.io.Serializable, Steppable, Stoppable

public class TentativeStep
extends java.lang.Object
implements Steppable, Stoppable

A Steppable wrapper which can be stopped. This is a convenience class for those situations where you'd like to schedule an agent to get stepped once in the future, but then think better of it and would like to prevent it from happening. Wrap your agent in the TentativeStep, then schedule the TentativeStep on the Schedule. When you want to prevent the agent's step() method from being called, simply call stop() on the TentativeStep. When stop() is called on a TentativeStep, it sets its underlying agent to null and forgets about it. Note that the TentativeStep itself is still scheduled, and so at some point the Schedule's time step will advance to that point even if the underlying Steppable has been removed from the TentativeStep.

Example usage:


   double scheduleTime = ... 
   Steppable mySteppable = ...

   TentativeStep tent = new TentativeStep(mySteppable);
   state.schedule.scheduleOnce(scheduleTime,tent);
   

Now, to stop mySteppable from being called before scheduleTime has come, you'd say:


   tent.stop();
   

See Also:
Serialized Form

Field Summary
 Steppable step
           
 
Constructor Summary
TentativeStep(Steppable step)
           
 
Method Summary
 void step(SimState state)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

step

public Steppable step
Constructor Detail

TentativeStep

public TentativeStep(Steppable step)
Method Detail

step

public void step(SimState state)
Specified by:
step in interface Steppable

stop

public void stop()
Specified by:
stop in interface Stoppable