Nemo  2.4.2
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
basicsimulation.h
Go to the documentation of this file.
1 
27 #ifndef BASICSIMULATION_H
28 #define BASICSIMULATION_H
29 
30 #include <list>
31 #include <map>
32 #include <string>
33 #include "ttrait.h"
34 #include "lifecycleevent.h"
35 
36 using namespace std;
37 /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
42 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
43 
45 
46 public:
48  ~ComponentManager ( ) {/*message("ComponentManager::~ComponentManager\n");*/}
50  void build_component_list ( );
52  void add_component (SimComponent* cmpt) {_components.push_back(cmpt);}
54  void add_trait (TraitPrototype* trait) {_TTrait_Templates.push_back(trait); _components.push_back(trait);}
56  void add_LCE (LifeCycleEvent* event) {_LCE_Templates.push_back(event);_components.push_back(event);}
60  TraitPrototype* get_trait (string name);
64  LifeCycleEvent* get_LCE (string name);
65 
66 protected:
67 
69  list< SimComponent* > _components;
71  list< TraitPrototype* > _TTrait_Templates;
73  list< LifeCycleEvent* > _LCE_Templates;
74 };
75 
76 /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
86 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
88 public:
90  ParamManager ( );
91  ~ParamManager ( ) {/*message("ParamManager::~ParamManager\n");*/}
93  void add_paramset (ParamSet* paramset)
94  {
95  _allParams.push_back(paramset);
96  }
100  ParamSet* get_paramset (string& name);
102  void build_allParams ( );
106  list<ParamSet*>& get_allParams ( )
107  {
108  return _allParams;
109  }
110 
123  bool set_parameters (map< string,string >& simparams, bool silent);
124 
129  bool param_consistency_check ( );
131  void build_records (map< string, vector<string> >& initParams);
133  list< map< string,string > >& get_simRecords ( ) {return _simRecords;}
135  map< string,string >& get_firstRecord ( ) {return (*_simRecords.begin());}
137  int get_nbSims ( ) {return _simRecords.size();}
138 
139 protected:
141  list< ParamSet* > _allParams;
143  map< string, string > _inputParams;
145  map< unsigned int, list < pair< string, string> > > _temporalParams;
147  list< map< string, string > > _simRecords;
150 
151 private:
152 
153  string setFilename (string& fstring, unsigned int sim, vector<string>& args, vector<unsigned int>& arg_no, vector<bool>& is_linked, vector<string>& names, bool check_arg_no);
154  string stripFormatString (string& str, unsigned int& index);
155  string setArgString (string& fmt, string& arg, unsigned int arg_pos);
156  string lowercase (string& input);
157 
158 };
159 /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
165 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
166 class SimBuilder: public ParamManager {
167 public:
168  SimBuilder ( ) { }
170  SimBuilder (const SimBuilder& SB);
171  ~SimBuilder ( );
176  bool build_currentParams (map< string,string >& simparams);
180  map< trait_t,TraitPrototype* >& build_currentTraits ( );
181 
183  void build_LifeCycle ( );
184 
189  TraitPrototype* get_current_trait (trait_t type);
190 
195  TraitPrototype* get_current_traitWithParameter (string& param);
196 
201  LifeCycleEvent* get_current_event (string& name);
202 
207  LifeCycleEvent* get_current_eventWithParameter (string& param);
208 
212  list<ParamSet*>& get_currentParams ( ) {return _currentParams;}
213 
214  age_t getFirstRequiredAgeInLifeCycle ( );
215 
216 protected:
218  list< ParamSet* > _currentParams;
220  map< trait_t, TraitPrototype* > _currentTraits;
222  map< int, LifeCycleEvent* > _LifeCycle;
223 
224  typedef map< int, LifeCycleEvent* >::const_iterator LCE_ITER;
225  typedef map< trait_t, TraitPrototype* >::const_iterator TRAIT_ITER;
226 
227 };
228 #endif
229 
Class to manage the simulation components and prototypes.
Definition: basicsimulation.h:44
list< LifeCycleEvent * > _LCE_Templates
List of all the life-cycle events of the simulation, a subset of _components list.
Definition: basicsimulation.h:73
list< TraitPrototype * > _TTrait_Templates
List of all trait prototypes of the simulation, a subset of _components list.
Definition: basicsimulation.h:71
void add_component(SimComponent *cmpt)
Push a component at the back of the component list.
Definition: basicsimulation.h:52
void add_LCE(LifeCycleEvent *event)
Add a life cycle event to the template and component lists.
Definition: basicsimulation.h:56
~ComponentManager()
Definition: basicsimulation.h:48
list< SimComponent * > _components
List of all the simulation components.
Definition: basicsimulation.h:69
void add_trait(TraitPrototype *trait)
Add a trait prototype to the template and component lists.
Definition: basicsimulation.h:54
ComponentManager()
Definition: basicsimulation.h:47
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:71
Class to manage the sets of parameters of the simulation components.
Definition: basicsimulation.h:87
~ParamManager()
Definition: basicsimulation.h:91
list< map< string, string > > _simRecords
Sets of parameters of all the simulations to perform.
Definition: basicsimulation.h:147
int get_nbSims()
Accessor to the size of the simulations parameter list, i.e.
Definition: basicsimulation.h:137
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:141
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:145
list< ParamSet * > & get_allParams()
Accessor of the whole list of the parameter sets.
Definition: basicsimulation.h:106
ParamSet _paramSet
The ParamSet param set of the simulation.
Definition: basicsimulation.h:149
map< string, string > _inputParams
A map of the parameters and their arguments of the current (running) simulation.
Definition: basicsimulation.h:143
map< string, string > & get_firstRecord()
Accessor to the first element in the simulations parameter list.
Definition: basicsimulation.h:135
void add_paramset(ParamSet *paramset)
Adds a ParamSet to the list of the parameter sets of the simulation.
Definition: basicsimulation.h:93
list< map< string, string > > & get_simRecords()
Accessor to the simulations parameter list.
Definition: basicsimulation.h:133
Parameters container, implemented in each SimComponent.
Definition: param.h:214
Provides methods to build the user's selected set of life cycle events and traits from the parameters...
Definition: basicsimulation.h:166
map< trait_t, TraitPrototype * > _currentTraits
List of the selected trait prototypes from the user defined input parameters.
Definition: basicsimulation.h:220
list< ParamSet * > _currentParams
List of the selected simulation components from the user defined input parameters.
Definition: basicsimulation.h:218
map< int, LifeCycleEvent * >::const_iterator LCE_ITER
Definition: basicsimulation.h:224
list< ParamSet * > & get_currentParams()
Accessor to the list of the selected parameter sets.
Definition: basicsimulation.h:212
map< trait_t, TraitPrototype * >::const_iterator TRAIT_ITER
Definition: basicsimulation.h:225
SimBuilder()
Definition: basicsimulation.h:168
map< int, LifeCycleEvent * > _LifeCycle
List of the selected life cycle events from the user defined input parameters.
Definition: basicsimulation.h:222
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:43
TTrait setter.
Definition: ttrait.h:129
Nemo2.
std::string trait_t
Trait types.
Definition: types.h:61
unsigned int age_t
Age class flags.
Definition: types.h:44

Generated for Nemo v2.4.2 by  doxygen 1.9.1

Catalogued on GSR