GCBM
flatrecord.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_FLATRECORD_H_
2 #define MOJA_MODULES_CBM_FLATRECORD_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
5 #include "moja/types.h"
6 #include "moja/flint/record.h"
7 
8 #include <vector>
9 #include <optional>
10 
11 namespace moja {
12 namespace modules {
13 namespace cbm {
14 
15  class CBM_API FlatRecordHelper {
16  public:
17  static const std::string BuildClassifierNamesString(const std::vector<std::string>& classifierNames, const std::string& suffix = "");
18  static const std::string BuildClassifierValueString(const std::vector<Poco::Nullable<std::string>>& classifierValues);
19  };
20 
21  class CBM_API FlatFluxRecord {
22  public:
23  FlatFluxRecord(int year, const std::vector<Poco::Nullable<std::string>>& classifierValues, const std::string& landClass,
24  const std::string& ageClass, const std::vector<Poco::Nullable<std::string>>& previousClassifierValues,
25  const std::string& previousLandClass, const std::string& previousAgeClass,
26  const Poco::Nullable<std::string>& disturbanceType, const Poco::Nullable<int>& disturbanceCode,
27  const std::string& srcPool, const std::string& dstPool, double flux);
28 
30 
31  bool operator==(const FlatFluxRecord& other) const;
32  size_t hash() const;
33  std::string header(const std::vector<std::string>& classifierNames) const;
34  std::string asPersistable() const;
35  std::vector<std::optional<std::string>> asVector() const;
36  void merge(const FlatFluxRecord& other);
37  void setId(Int64 id) { _id = id; }
38  Int64 getId() const { return _id; }
39  int getYear() const { return _year; }
40 
41  private:
42  mutable size_t _hash = -1;
43  Int64 _id;
44 
45  // Data
46  int _year;
47  std::vector<Poco::Nullable<std::string>> _classifierValues;
48  std::string _landClass;
49  std::string _ageClass;
50  std::vector<Poco::Nullable<std::string>> _previousClassifierValues;
51  std::string _previousLandClass;
52  std::string _previousAgeClass;
53  Poco::Nullable<std::string> _disturbanceType;
54  Poco::Nullable<int> _disturbanceCode;
55  std::string _srcPool;
56  std::string _dstPool;
57  double _flux;
58  };
59 
60  class CBM_API FlatPoolRecord {
61  public:
62  FlatPoolRecord(int year, const std::vector<Poco::Nullable<std::string>>& classifierValues, const std::string& landClass,
63  const std::string& ageClass, const std::string& pool, double value);
64 
66 
67  bool operator==(const FlatPoolRecord& other) const;
68  size_t hash() const;
69  std::string header(const std::vector<std::string>& classifierNames) const;
70  std::string asPersistable() const;
71  std::vector<std::optional<std::string>> asVector() const;
72  void merge(const FlatPoolRecord& other);
73  void setId(Int64 id) { _id = id; }
74  Int64 getId() const { return _id; }
75  int getYear() const { return _year; }
76 
77  private:
78  mutable size_t _hash = -1;
79  Int64 _id;
80 
81  // Data
82  int _year;
83  std::vector<Poco::Nullable<std::string>> _classifierValues;
84  std::string _landClass;
85  std::string _ageClass;
86  std::string _pool;
87  double _value;
88  };
89 
90  class CBM_API FlatErrorRecord {
91  public:
92  FlatErrorRecord(int year, const std::vector<Poco::Nullable<std::string>>& classifierValues,
93  const std::string& module, const std::string& error, double area);
94 
96 
97  bool operator==(const FlatErrorRecord& other) const;
98  size_t hash() const;
99  std::string header(const std::vector<std::string>& classifierNames) const;
100  std::string asPersistable() const;
101  std::vector<std::optional<std::string>> asVector() const;
102  void merge(const FlatErrorRecord& other);
103  void setId(Int64 id) { _id = id; }
104  Int64 getId() const { return _id; }
105  int getYear() const { return _year; }
106 
107  private:
108  mutable size_t _hash = -1;
109  Int64 _id;
110 
111  // Data
112  int _year;
113  std::vector<Poco::Nullable<std::string>> _classifierValues;
114  std::string _module;
115  std::string _error;
116  double _area;
117  };
118 
119  class CBM_API FlatAgeAreaRecord {
120  public:
121  FlatAgeAreaRecord(int year, std::vector<Poco::Nullable<std::string>>& classifierValues,
122  std::string& landClass, std::string& ageClass, double area);
123 
125 
126  bool operator==(const FlatAgeAreaRecord& other) const;
127  size_t hash() const;
128  std::string header(const std::vector<std::string>& classifierNames) const;
129  std::string asPersistable() const;
130  std::vector<std::optional<std::string>> asVector() const;
131  void merge(const FlatAgeAreaRecord& other);
132  void setId(Int64 id) { _id = id; }
133  Int64 getId() const { return _id; }
134  int getYear() const { return _year; }
135  const std::vector<Poco::Nullable<std::string>>& getClassifierValues() const { return _classifierValues; }
136  const std::string& getLandClass() const { return _landClass; }
137  const std::string& getAgeClass() const { return _ageClass; }
138 
139  private:
140  mutable size_t _hash = -1;
141  Int64 _id;
142 
143  // Data
144  int _year;
145  std::vector<Poco::Nullable<std::string>> _classifierValues;
146  std::string _landClass;
147  std::string _ageClass;
148  double _area;
149  };
150 
151  class CBM_API FlatDisturbanceRecord {
152  public:
153  FlatDisturbanceRecord(int year, const std::vector<Poco::Nullable<std::string>>& classifierValues, const std::string& landClass,
154  const std::string& ageClass, const std::vector<Poco::Nullable<std::string>>& previousClassifierValues,
155  const std::string& previousLandClass, const std::string& previousAgeClass,
156  const std::string& disturbanceType, int disturbanceCode, double area);
157 
159 
160  bool operator==(const FlatDisturbanceRecord& other) const;
161  size_t hash() const;
162  std::string header(const std::vector<std::string>& classifierNames) const;
163  std::string asPersistable() const;
164  std::vector<std::optional<std::string>> asVector() const;
165  void merge(const FlatDisturbanceRecord& other);
166  void setId(Int64 id) { _id = id; }
167  Int64 getId() const { return _id; }
168  int getYear() const { return _year; }
169 
170  private:
171  mutable size_t _hash = -1;
172  Int64 _id;
173 
174  // Data
175  int _year;
176  std::vector<Poco::Nullable<std::string>> _classifierValues;
177  std::string _landClass;
178  std::string _ageClass;
179  std::vector<Poco::Nullable<std::string>> _previousClassifierValues;
180  std::string _previousLandClass;
181  std::string _previousAgeClass;
182  std::string _disturbanceType;
184  double _area;
185  };
186 
187 }}} // namespace moja::modules::cbm
188 
189 #endif // MOJA_MODULES_CBM_FLATRECORD_H_
moja::modules::cbm::FlatFluxRecord::_previousLandClass
std::string _previousLandClass
Definition: flatrecord.h:51
moja::modules::cbm::FlatDisturbanceRecord::_ageClass
std::string _ageClass
Definition: flatrecord.h:178
moja::modules::cbm::FlatPoolRecord::setId
void setId(Int64 id)
Definition: flatrecord.h:73
moja::modules::cbm::FlatErrorRecord::getYear
int getYear() const
Definition: flatrecord.h:105
moja::modules::cbm::FlatFluxRecord::_year
int _year
Definition: flatrecord.h:46
moja::modules::cbm::FlatFluxRecord::_disturbanceType
Poco::Nullable< std::string > _disturbanceType
Definition: flatrecord.h:53
moja::modules::cbm::FlatAgeAreaRecord
Definition: flatrecord.h:119
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::FlatFluxRecord
Definition: flatrecord.h:21
moja::modules::cbm::FlatAgeAreaRecord::setId
void setId(Int64 id)
Definition: flatrecord.h:132
moja::modules::cbm::FlatAgeAreaRecord::getClassifierValues
const std::vector< Poco::Nullable< std::string > > & getClassifierValues() const
Definition: flatrecord.h:135
moja::modules::cbm::FlatErrorRecord::getId
Int64 getId() const
Definition: flatrecord.h:104
moja::modules::cbm::FlatAgeAreaRecord::getAgeClass
const std::string & getAgeClass() const
Definition: flatrecord.h:137
moja::modules::cbm::FlatErrorRecord::_year
int _year
Definition: flatrecord.h:112
moja::modules::cbm::FlatErrorRecord::_error
std::string _error
Definition: flatrecord.h:115
moja::modules::cbm::FlatPoolRecord
Definition: flatrecord.h:60
moja::modules::cbm::FlatDisturbanceRecord
Definition: flatrecord.h:151
moja::modules::cbm::FlatFluxRecord::~FlatFluxRecord
~FlatFluxRecord()
Definition: flatrecord.h:29
moja::modules::cbm::FlatFluxRecord::getYear
int getYear() const
Definition: flatrecord.h:39
moja::modules::cbm::FlatDisturbanceRecord::getId
Int64 getId() const
Definition: flatrecord.h:167
moja::modules::cbm::FlatDisturbanceRecord::getYear
int getYear() const
Definition: flatrecord.h:168
moja::modules::cbm::FlatErrorRecord::setId
void setId(Int64 id)
Definition: flatrecord.h:103
moja::modules::cbm::FlatFluxRecord::_classifierValues
std::vector< Poco::Nullable< std::string > > _classifierValues
Definition: flatrecord.h:47
moja::modules::cbm::FlatErrorRecord
Definition: flatrecord.h:90
moja::modules::cbm::FlatFluxRecord::_dstPool
std::string _dstPool
Definition: flatrecord.h:56
moja::modules::cbm::FlatPoolRecord::_year
int _year
Definition: flatrecord.h:82
moja::modules::cbm::FlatPoolRecord::_ageClass
std::string _ageClass
Definition: flatrecord.h:85
moja::modules::cbm::FlatAgeAreaRecord::_landClass
std::string _landClass
Definition: flatrecord.h:146
moja::modules::cbm::FlatDisturbanceRecord::_classifierValues
std::vector< Poco::Nullable< std::string > > _classifierValues
Definition: flatrecord.h:176
moja::modules::cbm::FlatFluxRecord::_previousClassifierValues
std::vector< Poco::Nullable< std::string > > _previousClassifierValues
Definition: flatrecord.h:50
moja::modules::cbm::FlatAgeAreaRecord::_area
double _area
Definition: flatrecord.h:148
moja::modules::cbm::FlatFluxRecord::_id
Int64 _id
Definition: flatrecord.h:43
moja::modules::cbm::FlatAgeAreaRecord::_classifierValues
std::vector< Poco::Nullable< std::string > > _classifierValues
Definition: flatrecord.h:145
moja::modules::cbm::FlatFluxRecord::_ageClass
std::string _ageClass
Definition: flatrecord.h:49
moja::modules::cbm::FlatDisturbanceRecord::_area
double _area
Definition: flatrecord.h:184
moja::modules::cbm::FlatDisturbanceRecord::_landClass
std::string _landClass
Definition: flatrecord.h:177
moja::modules::cbm::FlatErrorRecord::_module
std::string _module
Definition: flatrecord.h:114
moja::modules::cbm::FlatAgeAreaRecord::getId
Int64 getId() const
Definition: flatrecord.h:133
moja::modules::cbm::FlatDisturbanceRecord::_disturbanceType
std::string _disturbanceType
Definition: flatrecord.h:182
moja::modules::cbm::FlatAgeAreaRecord::getYear
int getYear() const
Definition: flatrecord.h:134
moja::modules::cbm::FlatFluxRecord::_previousAgeClass
std::string _previousAgeClass
Definition: flatrecord.h:52
moja::modules::cbm::FlatErrorRecord::_area
double _area
Definition: flatrecord.h:116
moja::modules::cbm::FlatErrorRecord::_classifierValues
std::vector< Poco::Nullable< std::string > > _classifierValues
Definition: flatrecord.h:113
moja::modules::cbm::FlatFluxRecord::_flux
double _flux
Definition: flatrecord.h:57
moja::modules::cbm::FlatErrorRecord::_id
Int64 _id
Definition: flatrecord.h:109
moja::modules::cbm::FlatDisturbanceRecord::_previousClassifierValues
std::vector< Poco::Nullable< std::string > > _previousClassifierValues
Definition: flatrecord.h:179
moja::modules::cbm::FlatAgeAreaRecord::~FlatAgeAreaRecord
~FlatAgeAreaRecord()
Definition: flatrecord.h:124
moja::modules::cbm::FlatDisturbanceRecord::_id
Int64 _id
Definition: flatrecord.h:172
moja::modules::cbm::FlatPoolRecord::_value
double _value
Definition: flatrecord.h:87
moja::modules::cbm::FlatDisturbanceRecord::_year
int _year
Definition: flatrecord.h:175
moja::modules::cbm::FlatPoolRecord::_classifierValues
std::vector< Poco::Nullable< std::string > > _classifierValues
Definition: flatrecord.h:83
moja::modules::cbm::FlatFluxRecord::_landClass
std::string _landClass
Definition: flatrecord.h:48
moja::modules::cbm::FlatPoolRecord::getYear
int getYear() const
Definition: flatrecord.h:75
moja::modules::cbm::FlatFluxRecord::_srcPool
std::string _srcPool
Definition: flatrecord.h:55
moja::modules::cbm::FlatPoolRecord::_landClass
std::string _landClass
Definition: flatrecord.h:84
moja::modules::cbm::FlatDisturbanceRecord::_previousLandClass
std::string _previousLandClass
Definition: flatrecord.h:180
moja::modules::cbm::FlatPoolRecord::_id
Int64 _id
Definition: flatrecord.h:79
moja::modules::cbm::FlatDisturbanceRecord::_disturbanceCode
int _disturbanceCode
Definition: flatrecord.h:183
moja::modules::cbm::FlatPoolRecord::~FlatPoolRecord
~FlatPoolRecord()
Definition: flatrecord.h:65
moja::modules::cbm::FlatFluxRecord::setId
void setId(Int64 id)
Definition: flatrecord.h:37
moja::modules::cbm::FlatAgeAreaRecord::_year
int _year
Definition: flatrecord.h:144
moja::modules::cbm::FlatPoolRecord::_pool
std::string _pool
Definition: flatrecord.h:86
moja::modules::cbm::FlatFluxRecord::_disturbanceCode
Poco::Nullable< int > _disturbanceCode
Definition: flatrecord.h:54
moja::modules::cbm::FlatDisturbanceRecord::_previousAgeClass
std::string _previousAgeClass
Definition: flatrecord.h:181
moja::modules::cbm::FlatAgeAreaRecord::_id
Int64 _id
Definition: flatrecord.h:141
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::FlatPoolRecord::getId
Int64 getId() const
Definition: flatrecord.h:74
moja::modules::cbm::FlatRecordHelper
Definition: flatrecord.h:15
moja::modules::cbm::FlatDisturbanceRecord::~FlatDisturbanceRecord
~FlatDisturbanceRecord()
Definition: flatrecord.h:158
moja::modules::cbm::FlatAgeAreaRecord::_ageClass
std::string _ageClass
Definition: flatrecord.h:147
moja::modules::cbm::FlatErrorRecord::~FlatErrorRecord
~FlatErrorRecord()
Definition: flatrecord.h:95
moja::modules::cbm::FlatFluxRecord::getId
Int64 getId() const
Definition: flatrecord.h:38
moja::modules::cbm::FlatDisturbanceRecord::setId
void setId(Int64 id)
Definition: flatrecord.h:166
moja::modules::cbm::FlatAgeAreaRecord::getLandClass
const std::string & getLandClass() const
Definition: flatrecord.h:136