Nemo  2.3.46
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) {_allParams.push_back(paramset);}
99  ParamSet* get_paramset (string& name);
101  void build_allParams ( );
105  list<ParamSet*>& get_allParams ( ) {return _allParams;}
106 
119  bool set_parameters (map< string,string >& simparams, bool silent);
120 
125  bool param_consistency_check ( );
127  void build_records (map< string, vector<string> >& initParams);
129  list< map< string,string > >& get_simRecords ( ) {return _simRecords;}
131  map< string,string >& get_firstRecord ( ) {return (*_simRecords.begin());}
133  int get_nbSims ( ) {return _simRecords.size();}
134 
135 protected:
137  list< ParamSet* > _allParams;
139  map< string, string > _inputParams;
141  map< unsigned int, list < pair< string, string> > > _temporalParams;
143  list< map< string, string > > _simRecords;
146 
147 private:
148 
149  string setFilename (string& fstring, unsigned int sim, vector<string>& args, vector<unsigned int>& arg_no, bool check_arg_no);
150  string stripFormatString (string& str, unsigned int& index);
151  string setArgString (string& fmt, string& arg, unsigned int arg_pos);
152  string lowercase (string& input);
153 
154 };
155 /* /_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ */
161 /* \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\ */
162 class SimBuilder: public ParamManager {
163 public:
164  SimBuilder ( ) { }
166  SimBuilder (const SimBuilder& SB);
167  ~SimBuilder ( );
172  bool build_currentParams (map< string,string >& simparams);
176  map< trait_t,TraitPrototype* >& build_currentTraits ( );
177 
179  void build_LifeCycle ( );
180 
185  TraitPrototype* get_current_trait (trait_t type);
190  LifeCycleEvent* get_current_event (string& name);
194  list<ParamSet*>& get_currentParams ( ) {return _currentParams;}
195 
196  age_t getFirstRequiredAgeInLifeCycle ( );
197 
198 protected:
200  list< ParamSet* > _currentParams;
202  map< trait_t, TraitPrototype* > _currentTraits;
204  map< int, LifeCycleEvent* > _LifeCycle;
205 
206  typedef map< int, LifeCycleEvent* >::const_iterator LCE_ITER;
207  typedef map< trait_t, TraitPrototype* >::const_iterator TRAIT_ITER;
208 
209 };
210 #endif
211 
Provides methods to build the user's selected set of life cycle events and traits from the parameters...
Definition: basicsimulation.h:162
~ComponentManager()
Definition: basicsimulation.h:50
list< map< string, string > > & get_simRecords()
Accessor to the simulations parameter list.
Definition: basicsimulation.h:129
ParamSet _paramSet
The ParamSet param set of the simulation.
Definition: basicsimulation.h:145
void add_component(SimComponent *cmpt)
Push a component at the back of the component list.
Definition: basicsimulation.h:54
std::string trait_t
Trait types.
Definition: types.h:63
list< ParamSet * > & get_currentParams()
Accessor to the list of the selected parameter sets.
Definition: basicsimulation.h:194
map< string, string > & get_firstRecord()
Accessor to the first element in the simulations parameter list.
Definition: basicsimulation.h:131
~ParamManager()
Definition: basicsimulation.h:93
list< LifeCycleEvent * > _LCE_Templates
List of all the life-cycle events of the simulation, a subset of _components list.
Definition: basicsimulation.h:75
map< trait_t, TraitPrototype * > _currentTraits
List of the selected trait prototypes from the user defined input parameters.
Definition: basicsimulation.h:202
void add_LCE(LifeCycleEvent *event)
Add a life cycle event to the template and component lists.
Definition: basicsimulation.h:58
unsigned int age_t
Age class flags.
Definition: types.h:46
Class to manage the sets of parameters of the simulation components.
Definition: basicsimulation.h:89
list< map< string, string > > _simRecords
Sets of parameters of all the simulations to perform.
Definition: basicsimulation.h:143
map< trait_t, TraitPrototype * >::const_iterator TRAIT_ITER
Definition: basicsimulation.h:207
Interface to all basic components of a simulation (traits, life cycle events, pop, etc. ).
Definition: simcomponent.h:45
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:137
map< string, string > _inputParams
A map of the parameters and their arguments of the current (running) simulation.
Definition: basicsimulation.h:139
ComponentManager()
Definition: basicsimulation.h:49
TTrait setter.
Definition: ttrait.h:125
Class to manage the simulation components and prototypes.
Definition: basicsimulation.h:46
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:141
list< SimComponent * > _components
List of all the simulation components.
Definition: basicsimulation.h:71
list< ParamSet * > _currentParams
List of the selected simulation components from the user defined input parameters.
Definition: basicsimulation.h:200
map< int, LifeCycleEvent * >::const_iterator LCE_ITER
Definition: basicsimulation.h:206
void add_trait(TraitPrototype *trait)
Add a trait prototype to the template and component lists.
Definition: basicsimulation.h:56
Parameters container, implemented in each SimComponent.
Definition: param.h:203
map< int, LifeCycleEvent * > _LifeCycle
List of the selected life cycle events from the user defined input parameters.
Definition: basicsimulation.h:204
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:72
list< ParamSet * > & get_allParams()
Accessor of the whole list of the parameter sets.
Definition: basicsimulation.h:105
list< TraitPrototype * > _TTrait_Templates
List of all trait prototypes of the simulation, a subset of _components list.
Definition: basicsimulation.h:73
void add_paramset(ParamSet *paramset)
Adds a ParamSet to the list of the parameter sets of the simulation.
Definition: basicsimulation.h:95
int get_nbSims()
Accessor to the size of the simulations parameter list, i.e.
Definition: basicsimulation.h:133
SimBuilder()
Definition: basicsimulation.h:164

Generated for Nemo v2.3.0 by  doxygen 1.8.8 --
Catalogued on GSR