Nemo  2.3.46
fileservices.h
Go to the documentation of this file.
1 
32 #ifndef FILESERVICES_H
33 #define FILESERVICES_H
34 
35 #include <list>
36 #include <string>
37 #include <map>
38 #include "service.h"
39 #include "param.h"
40 
41 class Metapop;
42 
43 class FileHandler;
44 class FHLogWriter;
51 class FileServices : public Service {
52 
53 private:
58 
60  list< FileHandler* > _writers;
61 
63  list< FileHandler* > _readers;
64 
66  string _rep_filename;
67 
69  string _basename;
70 
72  string _root_dir;
73 
76  list< ParamSet* > _params;
77 
79  unsigned int _mode;
80 
81 public:
82 
83  typedef std::list< FileHandler* >::const_iterator file_it;
84 
85  FileServices ( );
86 
87  virtual ~FileServices ( );
88 
89  virtual bool init ( ) {return false;}
90 
91  virtual void notify ();
97  bool init (list< ParamSet* >& params);
98 
101  virtual Metapop* get_pop_ptr ( ) {return _popPtr;}
102 
104  virtual void set_pop_ptr (Metapop* pop) {_popPtr = pop;}
105 
107  void setMode(unsigned int m) {_mode = m;}
108 
110  unsigned int getMode() {return _mode;}
111 
113  void setBasename (string name);
114 
116  void setRootDir (string name);
117 
119  void log_simparams();
120 
122  void log (string message);
123 
125  list< ParamSet* >& get_params() {return _params;};
126 
128  file_it getFirstWriter() {return _writers.begin();}
129 
131  file_it getLastWriter () {return _writers.end();}
132 
134  file_it getFirstReader() {return _readers.begin();}
135 
137  file_it getLastReader () {return _readers.end();}
138 
140  FileHandler* getReader (string& type);
141 
143  string& getBaseFileName ();
144 
146  string& getRootDir ();
147 
149  string getReplicateCounter ();
150 
152  string& getFirstReplicateFileName ();
153 
155  string& getReplicateFileName ();
156 
158  string getGenerationCounter ();
159 
162 
165  virtual void load ( SimComponent* sc );
166 
169  virtual void attach ( Handler* FH );
170 
173  virtual void attach_reader ( FileHandler* FH );
174 
176  virtual void reset ( );
177 
178 };
179 #endif //FILESERVICES_H
180 
list< FileHandler * > _writers
the list of the FileHandler's registered by the SimComponent in output mode
Definition: fileservices.h:60
void message(const char *message,...)
Definition: output.cc:40
Interface to handle file input/output for any SimComponent.
Definition: filehandler.h:53
virtual void attach(Handler *FH)
Attaches the FileHandler to the current list (_writers) of the FileServices.
Definition: fileservices.cc:57
string getReplicateCounter()
Accessor to the current replicate counter string.
Definition: fileservices.cc:240
unsigned int getMode()
Writting mode getter.
Definition: fileservices.h:110
list< ParamSet * > & get_params()
Accessor to the list of the current parameters of the simulation.
Definition: fileservices.h:125
File Handler used to save the simulation parameters to a log file.
Definition: filehandler.h:272
void setBasename(string name)
Sets the base file name of the simulation.
Definition: fileservices.cc:266
Top class of the metapopulation structure, contains the patches.
Definition: metapop.h:79
file_it getLastWriter()
Accessor to last element of the list of output FileHandlers.
Definition: fileservices.h:131
string getGenerationReplicateFileName()
Accessor to the current file name with generation and replicate counters added.
Definition: fileservices.cc:218
virtual ~FileServices()
Definition: fileservices.cc:51
list< ParamSet * > _params
the list of the parameters of the current simulation.
Definition: fileservices.h:76
unsigned int _mode
File mode, sets behavior when file must be overwritten or not.
Definition: fileservices.h:79
void log_simparams()
Saves the current simulation parameters to the default parameter logfile.
Definition: fileservices.cc:177
virtual void attach_reader(FileHandler *FH)
Attaches the FileHandler to the current list (_readers) of the FileServices.
Definition: fileservices.cc:70
string & getReplicateFileName()
Accessor to the current replicate file name.
Definition: fileservices.cc:209
file_it getLastReader()
Accessor to last element of the list of input FileHandlers.
Definition: fileservices.h:137
void setRootDir(string name)
Sets the root directory of the simulation.
Definition: fileservices.cc:273
Interface to all basic components of a simulation (traits, life cycle events, pop, etc. ).
Definition: simcomponent.h:45
Service handler (an observer).
Definition: handler.h:36
virtual void reset()
Clears the list of FileHandlers.
Definition: fileservices.cc:168
Metapop * _popPtr
a pointer to the current Metapop
Definition: fileservices.h:55
string _rep_filename
the file name associated with the current simulation replicate
Definition: fileservices.h:66
string getGenerationCounter()
Accessor to the current generation counter string.
Definition: fileservices.cc:253
string & getBaseFileName()
Accessor to the base file name of the simulation.
Definition: fileservices.cc:226
FHLogWriter * _logWriter
a FileHandler used to save the simulation parameters on disk.
Definition: fileservices.h:57
virtual bool init()
Definition: fileservices.h:89
void log(string message)
Write to the parameter logfile.
Definition: fileservices.cc:187
list< FileHandler * > _readers
the list of the FileHandler's registered by the SimComponent in input mode
Definition: fileservices.h:63
std::list< FileHandler * >::const_iterator file_it
Definition: fileservices.h:83
FileServices()
Definition: fileservices.cc:45
string _basename
the base file name of the simulation, read from the init file (param "filename")
Definition: fileservices.h:69
string & getRootDir()
Accessor to the name of the simulation's root output directory.
Definition: fileservices.cc:233
file_it getFirstWriter()
Accessor to first element of the list of output FileHandlers.
Definition: fileservices.h:128
A class to manage the files associated with each components of the simulation.
Definition: fileservices.h:51
virtual void notify()
Definition: fileservices.cc:159
file_it getFirstReader()
Accessor to first element of the list of input FileHandlers.
Definition: fileservices.h:134
string & getFirstReplicateFileName()
Accessor to the first replicate file name.
Definition: fileservices.cc:194
string _root_dir
the root directory for the simulation's results, read from the init file (param "root_dir") ...
Definition: fileservices.h:72
virtual Metapop * get_pop_ptr()
Accessor to the pointer to the main population.
Definition: fileservices.h:101
FileHandler * getReader(string &type)
Accessor to a specific file handler specified by its extension string.
Definition: fileservices.cc:284
virtual void set_pop_ptr(Metapop *pop)
Sets the Metapop reference.
Definition: fileservices.h:104
Interface for the simulation services (files and stats).
Definition: service.h:43
void setMode(unsigned int m)
Mode setter, determines if file will get overwritten or not.
Definition: fileservices.h:107
virtual void load(SimComponent *sc)
Tells the SimComponent to load its file handlers.
Definition: fileservices.cc:78

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