DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
outputexporter.h
Go to the documentation of this file.
1 #ifndef OUTPUTEXPORTER_H
2 #define OUTPUTEXPORTER_H
3 
4 #include <memory>
5 #include <fstream>
6 #include <vector>
7 
8 class Vessel;
9 class Population;
11 
13 {
14  static std::shared_ptr <OutputExporter> mInstance;
15 
16  std::string mBasePath;
17  std::ofstream mVmsLike;
18  std::ofstream mVmsLikeFPingsOnly;
19  std::ofstream mLogLike;
20  std::ofstream mTripCatchesPerSzgroup;
21 
22  bool useSql = true;
23  bool usePlainText = true;
24  std::shared_ptr<SQLiteOutputStorage> mSqlDb;
25 public:
26  OutputExporter(const std::string &basepath, const std::string &namesimu);
27 
28  void exportVmsLike(unsigned int tstep, Vessel *vessel);
29  void exportVmsLikeFPingsOnly (unsigned int tstep, Vessel *vessel, const std::vector<Population *> &populations, std::vector<int> &implicit_pops);
30  void exportLogLike(unsigned int tstep, Vessel *vessel, const std::vector<Population* >& populations, std::vector<int> &implicit_pops);
31  void exportTripCatchPopPerSzgroup(unsigned int tstep, Vessel *vessel, const std::vector<Population* >& populations, std::vector<int> &implicit_pops);
32 
33  void close();
34 
35  void setUseSqlite(bool sql) { useSql = sql; }
36  void setUsePlainText(bool pt) { usePlainText = pt; }
37  void setSQLiteDb(std::shared_ptr<SQLiteOutputStorage> db) { mSqlDb = db; }
38 
39  /* --- Statics --- */
40  static bool instantiate(const std::string &basepath, const std::string &namesimu);
41  static OutputExporter &instance() { return *mInstance; }
42 
43 private:
44  void exportLogLikePlaintext(unsigned int tstep, Vessel *v, const std::vector<Population *> &populations, std::vector<int> &implicit_pops);
45  void exportLogLikeSQLite(unsigned int tstep, Vessel *v, const std::vector<Population *> &populations, std::vector<int> &implicit_pops);
46 
47  void exportVmsLikePlaintext(unsigned int tstep, Vessel *vessel);
48  void exportVmsLikeSQLite(unsigned int tstep, Vessel *vessel);
49 
50  void exportVmsLikeFPingsOnlyPlaintext(unsigned int tstep, Vessel *vessel, const std::vector<Population *> &populations, std::vector<int> &implicit_pops);
51  void exportVmsLikeFPingsOnlySQLite(unsigned int tstep, Vessel *vessel, const std::vector<Population *> &populations, std::vector<int> &implicit_pops);
52 
53 };
54 
55 #endif // OUTPUTEXPORTER_H
vector< int > implicit_pops
Definition: main.cpp:238
void setSQLiteDb(std::shared_ptr< SQLiteOutputStorage > db)
Definition: outputexporter.h:37
OutputExporter(const std::string &basepath, const std::string &namesimu)
Definition: outputexporter.cpp:18
void exportVmsLikeFPingsOnly(unsigned int tstep, Vessel *vessel, const std::vector< Population * > &populations, std::vector< int > &implicit_pops)
Definition: outputexporter.cpp:78
int tstep
Definition: main.cpp:205
Definition: outputexporter.h:12
void exportVmsLike(unsigned int tstep, Vessel *vessel)
Definition: outputexporter.cpp:34
void exportLogLike(unsigned int tstep, Vessel *vessel, const std::vector< Population * > &populations, std::vector< int > &implicit_pops)
Definition: outputexporter.cpp:174
Definition: Population.h:34
void exportTripCatchPopPerSzgroup(unsigned int tstep, Vessel *vessel, const std::vector< Population * > &populations, std::vector< int > &implicit_pops)
Definition: outputexporter.cpp:399
void setUsePlainText(bool pt)
Definition: outputexporter.h:36
static OutputExporter & instance()
Definition: outputexporter.h:41
vector< Population * > populations
Definition: main.cpp:202
string namesimu
Definition: main.cpp:430
void setUseSqlite(bool sql)
Definition: outputexporter.h:35
Definition: sqliteoutputstorage.h:37
static bool instantiate(const std::string &basepath, const std::string &namesimu)
Definition: outputexporter.cpp:451
void close()
Definition: outputexporter.cpp:445