Nemo  2.4.0b
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 
38 using namespace std;
39 /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
44 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
45 
47 
48 public:
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 
68 protected:
69 
71  list< SimComponent* > _components;
73  list< TraitPrototype* > _TTrait_Templates;
75  list< LifeCycleEvent* > _LCE_Templates;
76 };
77 
78 /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
88 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
90 public:
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 
131  bool param_consistency_check ( );
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 
141 protected:
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 
153 private:
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 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
168 class SimBuilder: public ParamManager {
169 public:
170  SimBuilder ( ) { }
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 
191  TraitPrototype* get_current_trait (trait_t type);
192 
197  TraitPrototype* get_current_traitWithParameter (string& param);
198 
203  LifeCycleEvent* get_current_event (string& name);
204 
209  LifeCycleEvent* get_current_eventWithParameter (string& param);
210 
214  list<ParamSet*>& get_currentParams ( ) {return _currentParams;}
215 
216  age_t getFirstRequiredAgeInLifeCycle ( );
217 
218 protected:
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
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
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
~ParamManager()
Definition: basicsimulation.h:93
list< map< string, string > > _simRecords
Sets of parameters of all the simulations to perform.
Definition: basicsimulation.h:149
int get_nbSims()
Accessor to the size of the simulations parameter list, i.e.
Definition: basicsimulation.h:139
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
list< ParamSet * > & get_allParams()
Accessor of the whole list of the parameter sets.
Definition: basicsimulation.h:108
ParamSet _paramSet
The ParamSet param set of the simulation.
Definition: basicsimulation.h:151
map< string, string > _inputParams
A map of the parameters and their arguments of the current (running) simulation.
Definition: basicsimulation.h:145
map< string, string > & get_firstRecord()
Accessor to the first element in the simulations parameter list.
Definition: basicsimulation.h:137
void add_paramset(ParamSet *paramset)
Adds a ParamSet to the list of the parameter sets of the simulation.
Definition: basicsimulation.h:95
list< map< string, string > > & get_simRecords()
Accessor to the simulations parameter list.
Definition: basicsimulation.h:135
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< 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
map< int, LifeCycleEvent * >::const_iterator LCE_ITER
Definition: basicsimulation.h:226
list< ParamSet * > & get_currentParams()
Accessor to the list of the selected parameter sets.
Definition: basicsimulation.h:214
map< trait_t, TraitPrototype * >::const_iterator TRAIT_ITER
Definition: basicsimulation.h:227
SimBuilder()
Definition: basicsimulation.h:170
map< int, LifeCycleEvent * > _LifeCycle
List of the selected life cycle events from the user defined input parameters.
Definition: basicsimulation.h:224
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.4.0b by  doxygen 1.9.1 -- Nemo is hosted on  Download Nemo

Locations of visitors to this page
Catalogued on GSR