DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
benthosstats.h
Go to the documentation of this file.
1 #ifndef BENTHOSSTATS_H
2 #define BENTHOSSTATS_H
3 
4 #include <QVector>
5 #include <mutex>
6 
8 {
9 public:
10  struct StatData {
11  double biomass = 0.0;
12  double number = 0.0;
13  double meanweight = 0.0;
14  double biomassOverK = 0.0;
15  double numberOverK = 0.0;
16 
17  StatData() {}
18  void clear() {
19  biomass = 0.0;
20  number = 0.0;
21  meanweight = 0.0;
22  biomassOverK = 0.0;
23  numberOverK = 0.0;
24  }
25  };
26 
27 private:
28  bool mDirty = false;
29  QVector<QVector<StatData>> mDataPerBenthosAndFuncId;
30  mutable std::mutex mMutex;
31 
32  StatData &get(int funcid, int benthos);
33  const StatData &get(int funcid, int benthos) const;
34 
35 public:
36  BenthosStats();
37  ~BenthosStats() noexcept = default;
38 
39  BenthosStats(const BenthosStats& b);
41 
42  BenthosStats &operator = (const BenthosStats &b);
43  BenthosStats &operator = (BenthosStats &&b);
44 
45  bool dirty() const { return mDirty; }
46  void setDirty(bool dirty = true) { mDirty = dirty; }
47  void clear();
48 
49  void collectBiomass(int step, int funcid, int benthosid, double biomass);
50  void collectNumber (int step, int funcid, int benthosid, double number);
51  void collectMeanWeight(int step, int funcid, int benthosid, double number);
52  void collectBiomassOverK(int step, int funcid, int benthosid, double biomass);
53  void collectNumberOverK(int step, int funcid, int benthosid, double number);
54 
55  double biomassForBenthosAndFuncGroup(int funcgroup, int benthos) const;
56  double numberForBenthosAndFuncGroup(int funcgroup, int benthos) const;
57  double meanweightForBenthosAndFuncGroup(int funcgroup, int benthos) const;
58  double biomassOverKForBenthosAndFuncGroup(int funcgroup, int benthos) const;
59  double numberOverKForBenthosAndFuncGroup(int funcgroup, int benthos) const;
60 
62 };
63 
64 #endif // BENTHOSSTATS_H
void collectNumberOverK(int step, int funcid, int benthosid, double number)
Definition: benthosstats.cpp:123
Definition: benthosstats.h:7
double meanweight
Definition: benthosstats.h:13
double biomassOverKForBenthosAndFuncGroup(int funcgroup, int benthos) const
Definition: benthosstats.cpp:146
void clear()
Definition: benthosstats.cpp:80
void clear()
Definition: benthosstats.h:18
double number
Definition: benthosstats.h:12
void setDirty(bool dirty=true)
Definition: benthosstats.h:46
double biomassOverK
Definition: benthosstats.h:14
double biomass
Definition: benthosstats.h:11
~BenthosStats() noexcept=default
Definition: benthosstats.h:10
double biomassForBenthosAndFuncGroup(int funcgroup, int benthos) const
Definition: benthosstats.cpp:131
double numberForBenthosAndFuncGroup(int funcgroup, int benthos) const
Definition: benthosstats.cpp:136
StatData()
Definition: benthosstats.h:17
static const BenthosStats::StatData NoData
Definition: benthosstats.h:61
void collectNumber(int step, int funcid, int benthosid, double number)
Definition: benthosstats.cpp:99
void collectBiomassOverK(int step, int funcid, int benthosid, double biomass)
Definition: benthosstats.cpp:115
bool dirty() const
Definition: benthosstats.h:45
void collectMeanWeight(int step, int funcid, int benthosid, double number)
Definition: benthosstats.cpp:107
double numberOverKForBenthosAndFuncGroup(int funcgroup, int benthos) const
Definition: benthosstats.cpp:151
double meanweightForBenthosAndFuncGroup(int funcgroup, int benthos) const
Definition: benthosstats.cpp:141
double numberOverK
Definition: benthosstats.h:15
void collectBiomass(int step, int funcid, int benthosid, double biomass)
Definition: benthosstats.cpp:91
BenthosStats()
Definition: benthosstats.cpp:6