org.eclipse.ohf.stem.jobs.simulation
Class SimulationManager

java.lang.Object
  extended by org.eclipse.ohf.stem.jobs.simulation.SimulationManager
All Implemented Interfaces:
ISimulationListener

public class SimulationManager
extends java.lang.Object
implements ISimulationListener

This class manages the life-cycle of active simulations. There is a singleton instance of the manager that is referenced by other parts of the system to manage simulations. It creates Simulation instances from Scenario instances and can obtain Scenario instances from file URI's or from IConfigurationElement's. It maintains a collection of all of the active simulations in the system and generates SimulationEvent's whenever a simulation is added to that collection or removed.

The simulation manager maintains a sequence number and assigns successive values of that number to the Simulation instances it creates.


Field Summary
static ISimulation[] NONE
          Constant empty array.
 
Method Summary
 void addSimulationManagerListener(ISimulationManagerListener listener)
           
 void createAndRunSimulation(org.eclipse.core.runtime.IConfigurationElement configurationElement)
          Create a simulation from a Configuration Element and then start it running.
 void createAndRunSimulation(Scenario scenario)
          Create a simulation from a scenario instance and then start it running.
 void createAndStepSimulation(org.eclipse.core.runtime.IConfigurationElement configurationElement)
          Create a simulation from a Configuration Element and then start it running.
 void createAndStepSimulation(Scenario scenario)
          Create a simulation from a scenario instance and then start it running.
 ISimulation createSimulation(org.eclipse.core.runtime.IConfigurationElement configurationElement, org.eclipse.core.runtime.IProgressMonitor monitor)
          Create a Simulation that's ready to run.
 ISimulation createSimulation(Scenario scenario)
          Create a Simulation from a Scenario instance.
 ISimulation createSimulation(org.eclipse.emf.common.util.URI scenarioURI, org.eclipse.core.runtime.IProgressMonitor monitor)
          Create a Simulation that's ready to run.
 java.util.List<ISimulation> getActiveSimulations()
           
static SimulationManager getManager()
           
 void removeListener(ISimulationManagerListener listener)
           
static void resetSimulationManager()
          This is used for testing purposes to reset the state of the model.
 void simulationChanged(SimulationEvent event)
          This is where the manager hears about changes in the simulations it is managing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

public static final ISimulation[] NONE
Constant empty array.

Method Detail

getManager

public static final SimulationManager getManager()
Returns:
the singleton instance of the model

resetSimulationManager

public static final void resetSimulationManager()
This is used for testing purposes to reset the state of the model.


getActiveSimulations

public final java.util.List<ISimulation> getActiveSimulations()
Returns:
the activeSimulations

createSimulation

public ISimulation createSimulation(org.eclipse.core.runtime.IConfigurationElement configurationElement,
                                    org.eclipse.core.runtime.IProgressMonitor monitor)
Create a Simulation that's ready to run.

Parameters:
configurationElement - a configuration element that specifies the details of a serialized scenario that is in a plug-in
monitor - a progress monitor
Returns:
an ISimulation constructed from the ConfigurationElement, or null if there was a problem.

createSimulation

public ISimulation createSimulation(org.eclipse.emf.common.util.URI scenarioURI,
                                    org.eclipse.core.runtime.IProgressMonitor monitor)
Create a Simulation that's ready to run.

Parameters:
scenarioURI - the URI of a serialized Senario
monitor - a progress monitor
Returns:
an ISimulation constructed from the URI, or null if there was a problem.

createSimulation

public ISimulation createSimulation(Scenario scenario)
Create a Simulation from a Scenario instance.

Parameters:
scenario - the Scenario to simulate
Returns:
a Simulation that's ready to run.

createAndRunSimulation

public void createAndRunSimulation(org.eclipse.core.runtime.IConfigurationElement configurationElement)
Create a simulation from a Configuration Element and then start it running.

Parameters:
configurationElement - a configuration element that specifies the details of a serialized scenario that is in a plug-in

createAndRunSimulation

public void createAndRunSimulation(Scenario scenario)
Create a simulation from a scenario instance and then start it running.

Parameters:
scenario - the scenario to be simulated

createAndStepSimulation

public void createAndStepSimulation(org.eclipse.core.runtime.IConfigurationElement configurationElement)
Create a simulation from a Configuration Element and then start it running.

Parameters:
configurationElement - a configuration element that specifies the details of a serialized scenario that is in a plug-in

createAndStepSimulation

public void createAndStepSimulation(Scenario scenario)
Create a simulation from a scenario instance and then start it running.

Parameters:
scenario - the scenario to be simulated

addSimulationManagerListener

public void addSimulationManagerListener(ISimulationManagerListener listener)
Parameters:
listener - a listener wanting to be told about changes to the manager.

removeListener

public void removeListener(ISimulationManagerListener listener)
Parameters:
listener - a listener wanting NOT to be told about changes to the manager.

simulationChanged

public void simulationChanged(SimulationEvent event)
This is where the manager hears about changes in the simulations it is managing. It is really only interested in those that "stop" so it can remove them from its collection of active simulations.

Specified by:
simulationChanged in interface ISimulationListener
Parameters:
event - the event that records what happened to the simulation.
See Also:
ISimulationListener.simulationChanged(org.eclipse.ohf.stem.jobs.simulation.SimulationEvent)