moving to core/
[debian/openrocket] / core / src / net / sf / openrocket / simulation / listeners / SimulationListener.java
1 package net.sf.openrocket.simulation.listeners;
2
3 import net.sf.openrocket.simulation.SimulationStatus;
4 import net.sf.openrocket.simulation.exception.SimulationException;
5
6
7
8 public interface SimulationListener {
9         
10         /**
11          * Called when starting a simulation.
12          * 
13          * @param status        the simulation status.
14          */
15         public void startSimulation(SimulationStatus status) throws SimulationException;
16         
17         
18         /**
19          * Called when ending a simulation.  This is called either when the simulation ends normally
20          * (due to an end simulation event) or when a SimulationException is thrown.
21          * <p>
22          * This method cannot throw a SimulationException, since the simulation is already being ended.
23          * 
24          * @param status        the simulation status.
25          * @param exception     the exception that caused ending the simulation, or <code>null</code> if ending normally.
26          */
27         public void endSimulation(SimulationStatus status, SimulationException exception);
28         
29         
30         /**
31          * Called before a simulation step is taken.  This method may also prevent the normal
32          * stepping method from being called.
33          * 
34          * @param status        the simulation status.
35          * @return                      <code>true</code> to continue normally, <code>false</code> to skip taking the step
36          */
37         public boolean preStep(SimulationStatus status) throws SimulationException;
38         
39         
40         /**
41          * Called immediately after a simulation step has been taken.  This method is called whether the
42          * {@link #preStep(SimulationStatus)} aborted the step or not.
43          * 
44          * @param status        the simulation status.
45          */
46         public void postStep(SimulationStatus status) throws SimulationException;
47         
48         
49         /**
50          * Return whether this is a system listener.  System listeners are used internally for various
51          * purposes by OpenRocket.  User-written listeners should always return <code>false</code>.
52          * <p>
53          * System listeners do not cause warnings to be added to the simulation results when they affect
54          * the simulation.
55          * 
56          * @return              whether this is a system listener
57          */
58         public boolean isSystemListener();
59         
60 }