Nemo
2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
|
Class to update the simulation components' state during a simulation. More...
#include <updaterservices.h>
Public Member Functions | |
UpdaterServices () | |
virtual | ~UpdaterServices () |
virtual bool | init () |
virtual void | notify () |
virtual void | notify (unsigned int generation) |
The generation time is passed to the updaters. More... | |
virtual void | load (SimComponent *sc) |
Loads the updaters in case a component's parameter has temporal arguments. More... | |
virtual void | attach (Handler *H) |
Attach the updater to the stack. More... | |
virtual void | reset () |
Clears the containers. More... | |
void | update_params (unsigned int generation) |
Calls the parameters updating procedure. More... | |
void | update_components (unsigned int generation) |
Update the components using the functions stored in the updaters. More... | |
bool | hasTemporals () |
Checks if any updater has been uploaded. More... | |
![]() | |
Service () | |
virtual | ~Service () |
virtual bool | init ()=0 |
Inits internals. More... | |
virtual void | notify ()=0 |
Notifies all observers to update their state. More... | |
virtual void | load (SimComponent *sc)=0 |
Interface used by a simulation component to load its obervers onto a service provider. More... | |
virtual void | attach (Handler *h)=0 |
Adds an observer to the list. More... | |
virtual void | reset ()=0 |
Clears the observers list. More... | |
Private Attributes | |
map< unsigned int, list< Param * > > | _paramUpdater |
map< unsigned int, list< ParamUpdaterBase * > > | _componentUpdater |
list< ParamUpdaterBase * > | _updaters |
Class to update the simulation components' state during a simulation.
It stores the ParamUpdater objects. Each ParamUpdater stores a list of parameters from a SimComponent that use a single updating function from that component. That updating function is called to update the state of the SimComponent that declares it at a given generation during a simulation. When attaching an updater to the UpdaterServices, it is added to the _componentUpdater map and the list of its parameters is stored to the _paramUpdater map. Each map has the generation number at which the parameter/component must be updated as a key. The updaters are attached during the simulation setup (SimRunner::register_component). Each parameter set/simulation component is scanned for the presence of temporal parameters and is asked to add its updaters to the stack. The updaters will appear only once in the _updaters list as they store a single updating function although several parameters may upload the same updater. This allows several parameters to be attached to a single updater and use a single updating function from their simulation component.
The updating procedure is as follows: the parameters are first updated with their temporal argument value at the right generation. The components are then updated by using the function pointers stored in the updaters that will fetch the parameters values and update its state. Those updating functions must be implemented seperately for each component and set of parameters. The default SimComponent::setParameters function may suffice most of the time. That function is called only once and thus will update the component's state at the generations given in input by by the user.
|
inline |
|
virtual |
Attach the updater to the stack.
Implements Service.
References _componentUpdater, _paramUpdater, _updaters, and ParamUpdaterBase::getParams().
Referenced by SimComponent::loadUpdaters().
|
inline |
Checks if any updater has been uploaded.
References _paramUpdater.
Referenced by SimRunner::init_components().
|
virtual |
Implements Service.
References _componentUpdater, _paramUpdater, and _updaters.
Referenced by SimRunner::init_components().
|
virtual |
Loads the updaters in case a component's parameter has temporal arguments.
Implements Service.
References SimComponent::loadUpdaters().
Referenced by SimRunner::register_component().
|
inlinevirtual |
Implements Service.
Referenced by LCE_ParamUpdaterNotifier::execute(), and SimRunner::setForFirstGeneration().
|
virtual |
The generation time is passed to the updaters.
References update_components(), and update_params().
|
virtual |
Clears the containers.
Implements Service.
References _componentUpdater, _paramUpdater, and _updaters.
Referenced by SimRunner::reset_services(), and ~UpdaterServices().
void UpdaterServices::update_components | ( | unsigned int | generation | ) |
Update the components using the functions stored in the updaters.
References _componentUpdater, and warning().
Referenced by notify().
void UpdaterServices::update_params | ( | unsigned int | generation | ) |
Calls the parameters updating procedure.
The map is searched for the occurence of the generation.
References _paramUpdater.
Referenced by notify().
|
private |
Referenced by attach(), init(), reset(), and update_components().
Referenced by attach(), hasTemporals(), init(), reset(), and update_params().
|
private |