Nemo  2.3.56
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
basicsimulation.h
Go to the documentation of this file.
1
29#ifndef BASICSIMULATION_H
30#define BASICSIMULATION_H
31
32#include <list>
33#include <map>
34#include <string>
35#include "ttrait.h"
36#include "lifecycleevent.h"
37
38using namespace std;
39/* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
44/* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
45
47
48public:
50 ~ComponentManager ( ) {/*message("ComponentManager::~ComponentManager\n");*/}
52 void build_component_list ( );
54 void add_component (SimComponent* cmpt) {_components.push_back(cmpt);}
56 void add_trait (TraitPrototype* trait) {_TTrait_Templates.push_back(trait); _components.push_back(trait);}
58 void add_LCE (LifeCycleEvent* event) {_LCE_Templates.push_back(event);_components.push_back(event);}
62 TraitPrototype* get_trait (string name);
66 LifeCycleEvent* get_LCE (string name);
67
68protected:
69
71 list< SimComponent* > _components;
73 list< TraitPrototype* > _TTrait_Templates;
75 list< LifeCycleEvent* > _LCE_Templates;
76};
77
78/* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
88/* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
90public:
92 ParamManager ( );
93 ~ParamManager ( ) {/*message("ParamManager::~ParamManager\n");*/}
95 void add_paramset (ParamSet* paramset)
96 {
97 _allParams.push_back(paramset);
98 }
102 ParamSet* get_paramset (string& name);
104 void build_allParams ( );
108 list<ParamSet*>& get_allParams ( )
109 {
110 return _allParams;
111 }
112
125 bool set_parameters (map< string,string >& simparams, bool silent);
126
133 void build_records (map< string, vector<string> >& initParams);
135 list< map< string,string > >& get_simRecords ( ) {return _simRecords;}
137 map< string,string >& get_firstRecord ( ) {return (*_simRecords.begin());}
139 int get_nbSims ( ) {return _simRecords.size();}
140
141protected:
143 list< ParamSet* > _allParams;
145 map< string, string > _inputParams;
147 map< unsigned int, list < pair< string, string> > > _temporalParams;
149 list< map< string, string > > _simRecords;
152
153private:
154
155 string setFilename (string& fstring, unsigned int sim, vector<string>& args, vector<unsigned int>& arg_no, bool check_arg_no);
156 string stripFormatString (string& str, unsigned int& index);
157 string setArgString (string& fmt, string& arg, unsigned int arg_pos);
158 string lowercase (string& input);
159
160};
161/* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
167/* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
169public:
172 SimBuilder (const SimBuilder& SB);
173 ~SimBuilder ( );
178 bool build_currentParams (map< string,string >& simparams);
182 map< trait_t,TraitPrototype* >& build_currentTraits ( );
183
185 void build_LifeCycle ( );
186
192
198
203 LifeCycleEvent* get_current_event (string& name);
204
210
214 list<ParamSet*>& get_currentParams ( ) {return _currentParams;}
215
217
218protected:
220 list< ParamSet* > _currentParams;
222 map< trait_t, TraitPrototype* > _currentTraits;
224 map< int, LifeCycleEvent* > _LifeCycle;
225
226 typedef map< int, LifeCycleEvent* >::const_iterator LCE_ITER;
227 typedef map< trait_t, TraitPrototype* >::const_iterator TRAIT_ITER;
228
229};
230#endif
231
Class to manage the simulation components and prototypes.
Definition: basicsimulation.h:46
list< LifeCycleEvent * > _LCE_Templates
List of all the life-cycle events of the simulation, a subset of _components list.
Definition: basicsimulation.h:75
void build_component_list()
Clears and builds the list of all components from the lists of trait prototype templates and life cyc...
Definition: basicsimulation.cc:40
list< TraitPrototype * > _TTrait_Templates
List of all trait prototypes of the simulation, a subset of _components list.
Definition: basicsimulation.h:73
void add_component(SimComponent *cmpt)
Push a component at the back of the component list.
Definition: basicsimulation.h:54
void add_LCE(LifeCycleEvent *event)
Add a life cycle event to the template and component lists.
Definition: basicsimulation.h:58
~ComponentManager()
Definition: basicsimulation.h:50
LifeCycleEvent * get_LCE(string name)
Search for component with "name" in the life cycle events list.
Definition: basicsimulation.cc:77
TraitPrototype * get_trait(string name)
Search for component with "name" in the trait prototype list.
Definition: basicsimulation.cc:61
list< SimComponent * > _components
List of all the simulation components.
Definition: basicsimulation.h:71
void add_trait(TraitPrototype *trait)
Add a trait prototype to the template and component lists.
Definition: basicsimulation.h:56
ComponentManager()
Definition: basicsimulation.h:49
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
Class to manage the sets of parameters of the simulation components.
Definition: basicsimulation.h:89
void build_records(map< string, vector< string > > &initParams)
Builds the list of simulation parameters from the parsed input file(s).
Definition: basicsimulation.cc:250
list< ParamSet * > & get_allParams()
Accessor of the whole list of the parameter sets.
Definition: basicsimulation.h:108
~ParamManager()
Definition: basicsimulation.h:93
map< string, string > & get_firstRecord()
Accessor to the first element in the simulations parameter list.
Definition: basicsimulation.h:137
list< map< string, string > > _simRecords
Sets of parameters of all the simulations to perform.
Definition: basicsimulation.h:149
ParamManager()
Cstor.
Definition: basicsimulation.cc:97
int get_nbSims()
Accessor to the size of the simulations parameter list, i.e.
Definition: basicsimulation.h:139
bool set_parameters(map< string, string > &simparams, bool silent)
Sets the parameters of the simulation with the argument strings given in input.
Definition: basicsimulation.cc:151
void build_allParams()
Clears and fills the _allParams list with the ParamSet's of the simulation components.
Definition: basicsimulation.cc:116
list< ParamSet * > _allParams
A list of all the parameter sets of all the simulation components loaded in the _component list of th...
Definition: basicsimulation.h:143
map< unsigned int, list< pair< string, string > > > _temporalParams
Lists of parameters to be updated during a simulation indexed by generation update time.
Definition: basicsimulation.h:147
ParamSet _paramSet
The ParamSet param set of the simulation.
Definition: basicsimulation.h:151
ParamSet * get_paramset(string &name)
Looks for paramset with "name" in the list of parameter sets.
Definition: basicsimulation.cc:232
map< string, string > _inputParams
A map of the parameters and their arguments of the current (running) simulation.
Definition: basicsimulation.h:145
list< map< string, string > > & get_simRecords()
Accessor to the simulations parameter list.
Definition: basicsimulation.h:135
string lowercase(string &input)
Definition: basicsimulation.cc:597
void add_paramset(ParamSet *paramset)
Adds a ParamSet to the list of the parameter sets of the simulation.
Definition: basicsimulation.h:95
string setFilename(string &fstring, unsigned int sim, vector< string > &args, vector< unsigned int > &arg_no, bool check_arg_no)
Definition: basicsimulation.cc:407
string setArgString(string &fmt, string &arg, unsigned int arg_pos)
Definition: basicsimulation.cc:512
string stripFormatString(string &str, unsigned int &index)
Definition: basicsimulation.cc:477
bool param_consistency_check()
Checks if all the mandatory parameters are set so that the simulation can be launched.
Definition: basicsimulation.cc:132
Parameters container, implemented in each SimComponent.
Definition: param.h:206
Provides methods to build the user's selected set of life cycle events and traits from the parameters...
Definition: basicsimulation.h:168
map< int, LifeCycleEvent * >::const_iterator LCE_ITER
Definition: basicsimulation.h:226
LifeCycleEvent * get_current_event(string &name)
Accessor to the list of current LCEs.
Definition: basicsimulation.cc:683
void build_LifeCycle()
Selects the life cycle events that have their parameters set.
Definition: basicsimulation.cc:762
age_t getFirstRequiredAgeInLifeCycle()
Definition: basicsimulation.cc:784
map< trait_t, TraitPrototype * > _currentTraits
List of the selected trait prototypes from the user defined input parameters.
Definition: basicsimulation.h:222
list< ParamSet * > _currentParams
List of the selected simulation components from the user defined input parameters.
Definition: basicsimulation.h:220
~SimBuilder()
Definition: basicsimulation.cc:628
LifeCycleEvent * get_current_eventWithParameter(string &param)
Accessor to the current LCEs conditioned on ownership of a specified parameter.
Definition: basicsimulation.cc:698
bool build_currentParams(map< string, string > &simparams)
Builds the list of parameters from user's defined input parameters.
Definition: basicsimulation.cc:715
SimBuilder()
Definition: basicsimulation.h:170
TraitPrototype * get_current_traitWithParameter(string &param)
Accessor to the current trait prototypes conditioned on ownership of a specified parameter.
Definition: basicsimulation.cc:666
map< trait_t, TraitPrototype * >::const_iterator TRAIT_ITER
Definition: basicsimulation.h:227
map< int, LifeCycleEvent * > _LifeCycle
List of the selected life cycle events from the user defined input parameters.
Definition: basicsimulation.h:224
map< trait_t, TraitPrototype * > & build_currentTraits()
Selects the trait prototypes that have their parameters set.
Definition: basicsimulation.cc:741
list< ParamSet * > & get_currentParams()
Accessor to the list of the selected parameter sets.
Definition: basicsimulation.h:214
TraitPrototype * get_current_trait(trait_t type)
Accessor to the list of current trait prototypes.
Definition: basicsimulation.cc:654
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:45
TTrait setter.
Definition: ttrait.h:125
std::string trait_t
Trait types.
Definition: types.h:63
unsigned int age_t
Age class flags.
Definition: types.h:46

Generated for Nemo v2.3.56 by  doxygen 1.9.0 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR