Nemo  2.4.0b
Simulate forward-in-time genetic evolution in a spatially explicit, individual-based stochastic simulator
servicenotifiers.h
Go to the documentation of this file.
1 
29 #include "types.h"
30 #include "lifecycleevent.h"
31 #include "fileservices.h"
32 #include "statservices.h"
33 #include "updaterservices.h"
34 #include "filehandler.h"
35 #include "stathandler.h"
36 #include <map>
37 
38 //LCE_ParamUpdaterNotifier
39 //
42 
43 private:
45 
46 public:
47 
48  LCE_ParamUpdaterNotifier () : LifeCycleEvent("param_updater",""), _manager(0) { }
50 
51  void setManager (UpdaterServices* mng) {_manager = mng;}
52  virtual void execute ();
53  virtual bool setParameters () {return true;}
54 
55  virtual LifeCycleEvent* clone ( ) {return new LCE_ParamUpdaterNotifier();}
56 
57  //SimComponent overrides:
58  virtual void loadFileServices ( FileServices* loader ) {}
59  virtual void loadStatServices ( StatServices* loader ) {}
60  virtual void loadUpdaters ( UpdaterServices* loader) {_manager = loader;}
61  virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
62  virtual age_t removeAgeClass ( ) {return 0;}
63  virtual age_t addAgeClass ( ) {return 0;}
64  virtual age_t requiredAgeClass () {return 0;}
65 };
66 
67 // LCE_FileServicesNotifier
68 //
69 // forward decl
70 class GenotyperFH;
73 {
74 
76  unsigned int _sample_size;
78 
80 
81 public:
82  LCE_FileServicesNotifier(); //: LifeCycleEvent("save_files",""), _service(0) { }
83  virtual ~LCE_FileServicesNotifier( );
84 
85  virtual void execute ();
86  virtual bool setParameters (); // {return true;}
87 
88  virtual LifeCycleEvent* clone ( ) {return new LCE_FileServicesNotifier();}
89 
90  //SimComponent implementation
91  virtual void loadFileServices ( FileServices* loader );
92  virtual void loadStatServices ( StatServices* loader ) {}
93  virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
94  virtual age_t removeAgeClass ( ) {return 0;}
95  virtual age_t addAgeClass ( ) {return 0;}
96  virtual age_t requiredAgeClass () {return 0;}
97 };
98 
99 // GenotyperFH
100 
101 class GenotyperFH : public EventFileHandler < LCE_FileServicesNotifier > {
102 
103  vector< trait_t > _traits; // which traits are selected
104  vector< unsigned int> _map_index; // index in trait table of the genetic map
105  multimap< unsigned int, TraitPrototype* > _locposition_map; // holds the mapping of map position to trait
106 
107  unsigned int _ntrait;
108 
109  string _format;
110  string _logtime;
111 
112 public:
114  EventFileHandler(event, ""), _ntrait(0) {}
115 
116  virtual ~GenotyperFH() {}
117 
118  virtual void FHwrite();
119  virtual void FHread (string& filename) {}
120 
121  void setTraits(vector< trait_t >& traits);
122 
123  void setFormat(string format) {_format = format;}
124 
125  void setLogtime(string logtime) {_logtime = logtime;}
126 
127 };
128 
129 // LCE_StatFH
130 //
132 class LCE_StatFH : public FileHandler {
133 
135 
136 public:
137 
139 : FileHandler(".txt"), _statService(0)
140 {
141  FileHandler::set(false,false,0,0,0,"");
142  set_isMasterExec(true);
143 }
144 
145  ~LCE_StatFH() { };
146 
147  virtual vector< string > ifExist();
148 
150 
151  virtual void FHwrite();
152  virtual void FHread (string& filename) {}
153 
154  void PrintStat_byGen ( );
155 };
156 
157 
158 // LCE_StatServiceNotifier
159 //
163 {
164 
166 
167  unsigned int _occurrence;
168 
169  string _arg, _dir;
170 
172 
173 public:
174 
176 
177  virtual ~LCE_StatServiceNotifier ( ) { }
178 
180  bool setOccurence ();
181  bool dummyUpdate (){return true;}
182 
183  virtual bool setParameters ();
184  virtual void execute ();
185 
187 
188  //SimComponent overrides:
189  virtual void loadFileServices ( FileServices* loader ) {loader->attach(&_fileHandler);}
190  virtual void loadStatServices ( StatServices* loader );
191  virtual bool resetParameterFromSource (std::string param, SimComponent* cmpt) {return false;}
192  virtual age_t removeAgeClass ( ) {return 0;}
193  virtual age_t addAgeClass ( ) {return 0;}
194  virtual age_t requiredAgeClass () {return 0;}
195 
196 };
Template class for the LCEs StatHandler classes.
Definition: filehandler.h:254
Interface to handle file input/output for any SimComponent.
Definition: filehandler.h:53
void set_isMasterExec(bool is)
Definition: filehandler.h:182
virtual void set(bool rpl_per, bool gen_per, int rpl_occ, int gen_occ, int rank, string path)
Sets the hanlder parameters.
Definition: filehandler.h:193
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:52
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:61
Definition: servicenotifiers.h:101
GenotyperFH(LCE_FileServicesNotifier *event)
Definition: servicenotifiers.h:113
virtual ~GenotyperFH()
Definition: servicenotifiers.h:116
virtual void FHwrite()
Definition: servicenotifiers.cc:199
void setLogtime(string logtime)
Definition: servicenotifiers.h:125
string _format
Definition: servicenotifiers.h:109
void setTraits(vector< trait_t > &traits)
Definition: servicenotifiers.cc:175
unsigned int _ntrait
Definition: servicenotifiers.h:107
void setFormat(string format)
Definition: servicenotifiers.h:123
virtual void FHread(string &filename)
Definition: servicenotifiers.h:119
vector< trait_t > _traits
Definition: servicenotifiers.h:103
multimap< unsigned int, TraitPrototype * > _locposition_map
Definition: servicenotifiers.h:105
string _logtime
Definition: servicenotifiers.h:110
vector< unsigned int > _map_index
Definition: servicenotifiers.h:104
Event used to notify all file handlers to update their state through the FileServices::notify() inter...
Definition: servicenotifiers.h:73
GenotyperFH * _genotyper
Definition: servicenotifiers.h:79
virtual void loadStatServices(StatServices *loader)
Definition: servicenotifiers.h:92
LCE_FileServicesNotifier()
Definition: servicenotifiers.cc:62
age_t _sample_age
Definition: servicenotifiers.h:77
virtual void loadFileServices(FileServices *loader)
Definition: servicenotifiers.cc:110
virtual bool setParameters()
Definition: servicenotifiers.cc:83
virtual age_t removeAgeClass()
Definition: servicenotifiers.h:94
FileServices * _service
Definition: servicenotifiers.h:75
virtual ~LCE_FileServicesNotifier()
Definition: servicenotifiers.cc:76
virtual void execute()
Definition: servicenotifiers.cc:164
virtual age_t requiredAgeClass()
Definition: servicenotifiers.h:96
virtual age_t addAgeClass()
Definition: servicenotifiers.h:95
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: servicenotifiers.h:93
virtual LifeCycleEvent * clone()
Definition: servicenotifiers.h:88
unsigned int _sample_size
Definition: servicenotifiers.h:76
Calls the UpdaterServices to notify its components of a generation change.
Definition: servicenotifiers.h:41
void setManager(UpdaterServices *mng)
Definition: servicenotifiers.h:51
virtual LifeCycleEvent * clone()
Definition: servicenotifiers.h:55
virtual ~LCE_ParamUpdaterNotifier()
Definition: servicenotifiers.h:49
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: servicenotifiers.h:61
LCE_ParamUpdaterNotifier()
Definition: servicenotifiers.h:48
virtual void loadFileServices(FileServices *loader)
Definition: servicenotifiers.h:58
virtual bool setParameters()
Definition: servicenotifiers.h:53
virtual void loadUpdaters(UpdaterServices *loader)
Definition: servicenotifiers.h:60
UpdaterServices * _manager
Definition: servicenotifiers.h:44
virtual age_t requiredAgeClass()
Definition: servicenotifiers.h:64
virtual age_t removeAgeClass()
Definition: servicenotifiers.h:62
virtual void loadStatServices(StatServices *loader)
Definition: servicenotifiers.h:59
virtual void execute()
Definition: servicenotifiers.cc:45
virtual age_t addAgeClass()
Definition: servicenotifiers.h:63
FileHandler of the LCE_StatServiceNotifier class, writes the recorded stats to txt files.
Definition: servicenotifiers.h:132
virtual void FHread(string &filename)
Definition: servicenotifiers.h:152
virtual vector< string > ifExist()
Definition: servicenotifiers.cc:370
~LCE_StatFH()
Definition: servicenotifiers.h:145
LCE_StatFH()
Definition: servicenotifiers.h:138
StatServices * _statService
Definition: servicenotifiers.h:134
virtual void FHwrite()
Definition: servicenotifiers.cc:405
void PrintStat_byGen()
Definition: servicenotifiers.cc:442
void set_statService(StatServices *srv)
Definition: servicenotifiers.h:149
Initiates the StatServices' parameters (log time) when registering, calls StatServices::notify() when...
Definition: servicenotifiers.h:163
virtual age_t addAgeClass()
Definition: servicenotifiers.h:193
virtual age_t requiredAgeClass()
Definition: servicenotifiers.h:194
FileHandler & getFH()
Definition: servicenotifiers.h:179
virtual void execute()
Definition: servicenotifiers.cc:355
string _dir
Definition: servicenotifiers.h:169
virtual void loadStatServices(StatServices *loader)
Definition: servicenotifiers.cc:335
LCE_StatFH _fileHandler
Definition: servicenotifiers.h:171
LCE_StatServiceNotifier()
Definition: servicenotifiers.cc:210
virtual void loadFileServices(FileServices *loader)
Definition: servicenotifiers.h:189
bool setOccurence()
Definition: servicenotifiers.cc:282
virtual bool resetParameterFromSource(std::string param, SimComponent *cmpt)
Definition: servicenotifiers.h:191
unsigned int _occurrence
Definition: servicenotifiers.h:167
string _arg
Definition: servicenotifiers.h:169
virtual bool setParameters()
Definition: servicenotifiers.cc:238
virtual age_t removeAgeClass()
Definition: servicenotifiers.h:192
StatServices * _service
Definition: servicenotifiers.h:165
bool dummyUpdate()
Definition: servicenotifiers.h:181
virtual ~LCE_StatServiceNotifier()
Definition: servicenotifiers.h:177
virtual LCE_StatServiceNotifier * clone()
Definition: servicenotifiers.h:186
Base class of the Life Cycle Events, declares the LCE interface.
Definition: lifecycleevent.h:73
Interface to all basic components of a simulation (traits, life cycle events, pop,...
Definition: simcomponent.h:45
The Service class used to manage the StatHandler objects.
Definition: statservices.h:50
Class to update the simulation components' state during a simulation.
Definition: updaterservices.h:64
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