DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
outputfileparser.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
3 // AND EFFORT DISPLACEMENT
4 // Copyright (c) 2012-2019 Francois Bastardie <fba@aqua.dtu.dk>
5 
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // --------------------------------------------------------------------------
20 
21 /* --------------------------------------------------------------------------
22  * DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
23  * AND EFFORT DISPLACEMENT
24  * Copyright (c) 2012, 2013, 2014 Francois Bastardie <fba@aqua.dtu.dk>
25  *
26  * This program is free software; you can redistribute it and/or modify
27  * it under the terms of the GNU General Public License as published by
28  * the Free Software Foundation; either version 2 of the License, or
29  * (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34  * GNU General Public License for more details.
35  *
36  * You should have received a copy of the GNU General Public License along
37  * with this program; if not, write to the Free Software Foundation, Inc.,
38  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39  * --------------------------------------------------------------------------
40  */
41 #ifndef OUTPUTFILEPARSER_H
42 #define OUTPUTFILEPARSER_H
43 
44 #include <QObject>
45 #include <QString>
46 #include <QFile>
47 
48 #include <memory>
49 
50 class DisplaceModel;
51 class VesselStats;
52 
53 class OutputFileParser : public QObject
54 {
55  Q_OBJECT
56 
57  DisplaceModel *mModel;
58 
59 public:
60  explicit OutputFileParser(DisplaceModel *model, QObject *parent = 0);
61 
62 public slots:
63  void parse (QString path, int tstep, int period = -1);
64 
65 signals:
66  void error(QString);
67  void parseCompleted();
68 
69 protected:
70  [[deprecated]]
71  void parsePopStart(QFile *file, int tstep, DisplaceModel *model, int period = -1);
72  void parsePopCumftime(QFile *file, int tstep, DisplaceModel *model, int period = -1);
73  void parsePopCumsweptarea(QFile *file, int tstep, DisplaceModel *model, int period = -1);
74  void parsePopCumcatches(QFile *file, int tstep, DisplaceModel *model, int period = -1);
75  void parsePopCumcatchesWithThreshold(QFile *file, int tstep, DisplaceModel *model, int period = -1);
76  void parsePopCumdiscards(QFile *file, int tstep, DisplaceModel *model, int period = -1);
77  void parsePopCumdiscardsratio(QFile *file, int tstep, DisplaceModel *model, int period = -1);
78  void parsePopNbchoked(QFile *file, int tstep, DisplaceModel *model, int period = -1);
79  void parsePopTariffs(QFile *file, int tstep, DisplaceModel *model, int period = -1);
80  void parsePopImpact(QFile *file, int tstep, DisplaceModel *model, int period = -1);
81  void parsePopCumcatchesPerPop(QFile *file, int tstep, DisplaceModel *model, int period = -1);
82 
83  [[deprecated]]
84  void parseNodesEnvt(QFile *file, int tstep, DisplaceModel *model, int period = -1);
85  void parsePopBenthosStats(QFile *file, int tstep, DisplaceModel *model, int period = -1);
86  void parseFishfarmslogsStats(QFile *file, int tstep, DisplaceModel *model, int period = -1);
87  void parsePopStats(QFile *file, int tstep, DisplaceModel *model, int period = -1);
88  void parseVessels(QFile *file, int tstep, DisplaceModel *model, int period = -1);
89  void parseShipsStats(QFile *file, int tstep, DisplaceModel *model, int period = -1);
90 
91  static int toInt(const QString x) {
92  bool b;
93  int r = x.toInt(&b);
94  if (!b)
95  throw std::exception();
96  return r;
97  }
98 
99  static double toDouble(const QString x) {
100  bool b;
101  double r = x.toDouble(&b);
102  if (!b)
103  throw std::exception();
104  return r;
105  }
106 
107 public:
108  VesselStats parseVesselStatLine(const QStringList &fields);
109 };
110 
111 #endif // OUTPUTFILEPARSER_H
Definition: outputfileparser.h:53
void parseNodesEnvt(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:451
void parsePopImpact(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:392
void parsePopStart(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:108
void parseShipsStats(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:725
int tstep
Definition: main.cpp:205
void parsePopNbchoked(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:273
void parsePopCumcatches(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:302
Definition: vesseldata.h:152
void parsePopTariffs(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:361
void parsePopCumftime(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:157
void parsePopCumdiscardsratio(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:245
Definition: displacemodel.h:71
Definition: graphbuilder.h:68
void parsePopBenthosStats(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:496
void parsePopStats(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:606
void parseVessels(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:624
void parsePopCumdiscards(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:217
void parsePopCumsweptarea(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:185
void error(QString)
Definition: moc_outputfileparser.cpp:149
static double toDouble(const QString x)
Definition: outputfileparser.h:99
static int toInt(const QString x)
Definition: outputfileparser.h:91
void parse(QString path, int tstep, int period=-1)
Definition: outputfileparser.cpp:40
void parseCompleted()
Definition: moc_outputfileparser.cpp:156
OutputFileParser(DisplaceModel *model, QObject *parent=0)
Definition: outputfileparser.cpp:34
void parsePopCumcatchesPerPop(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:422
void parseFishfarmslogsStats(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:544
void parsePopCumcatchesWithThreshold(QFile *file, int tstep, DisplaceModel *model, int period=-1)
Definition: outputfileparser.cpp:332
VesselStats parseVesselStatLine(const QStringList &fields)
Definition: outputfileparser.cpp:654