Class LifecycleController
Object
LifecycleController
Helper to manage lifecycle listeners and dispatch lifecycle notifications as
well as loading and unloading modules and models.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EvoLudoOwning engine used to query modules and dispatch events.protected List<LifecycleListener> List of listeners for module/model load/unload lifecycle events. -
Constructor Summary
ConstructorsConstructorDescriptionLifecycleController(EvoLudo engine) Create a controller bound to the supplied engine. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(LifecycleListener newListener) Add a lifecycle listener to the list of listeners that get notified when the model reaches lifecycle milestones.voidCalled whenever a new model has finished loading.voidCalled whenever a new model has finished loading.voidCalled whenever a new module has finished loading.voidCalled after the state of the model has been restored either through drag'n'drop with the GWT GUI or through the--restorecommand line argument.voidCalled whenever the current module has finished unloading.voidSet model type and loads the corresponding frameworks for individual based simulations or numerical integration of ODE/SDE/PDE models.booleanloadModule(String newModuleKey) Load new module with keynewModuleKey.voidremoveListener(LifecycleListener obsoleteListener) Remove the lifecycle listener from the list of listeners that get notified when the model reaches lifecycle milestones.voidUnload model framework.voidunloadModel(boolean quiet) Unload model framework and, if requested, notifies all registeredLifecycleListeners.voidUnload current module to free up resources.
-
Field Details
-
engine
Owning engine used to query modules and dispatch events. -
lifecycleListeners
List of listeners for module/model load/unload lifecycle events.
-
-
Constructor Details
-
LifecycleController
Create a controller bound to the supplied engine.- Parameters:
engine- EvoLudo runtime to interact with
-
-
Method Details
-
addListener
Add a lifecycle listener to the list of listeners that get notified when the model reaches lifecycle milestones.- Parameters:
newListener- the new lifecycle listener- See Also:
-
removeListener
Remove the lifecycle listener from the list of listeners that get notified when the model reaches lifecycle milestones.- Parameters:
obsoleteListener- the listener to remove from list of lifecycle listeners- See Also:
-
fireModuleLoaded
public void fireModuleLoaded()Called whenever a new module has finished loading. Notifies all registeredLifecycleListeners.- See Also:
-
fireModuleUnloaded
public void fireModuleUnloaded()Called whenever the current module has finished unloading. Notifies all registeredLifecycleListeners.- See Also:
-
fireModuleRestored
public void fireModuleRestored()Called after the state of the model has been restored either through drag'n'drop with the GWT GUI or through the--restorecommand line argument. Notifies all registeredLifecycleListeners.- See Also:
-
fireModelLoaded
public void fireModelLoaded()Called whenever a new model has finished loading. Notifies all registeredLifecycleListeners.- See Also:
-
fireModelUnloaded
public void fireModelUnloaded()Called whenever a new model has finished loading. Notifies all registeredLifecycleListeners.- See Also:
-
loadModule
Load new module with keynewModuleKey. If necessary first unload current module.- Parameters:
newModuleKey- the key of the module to load- Returns:
- false if
newModuleKeynot found and no active module present; true otherwise - See Also:
-
unloadModule
public void unloadModule()Unload current module to free up resources.Implementation note:
Called fromloadModule(String)to first unload the active module or triggered by GWT'sEvoLudoWeb.onUnload(), i.e. when unloading the GWT application.- See Also:
-
loadModel
-
unloadModel
public void unloadModel()Unload model framework. Notifies all registeredLifecycleListeners.- See Also:
-
unloadModel
public void unloadModel(boolean quiet) Unload model framework and, if requested, notifies all registeredLifecycleListeners.- Parameters:
quiet- set totrueto skip notifying listeners- See Also:
-