GCBM
cbmaggregatorlandunitdata.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMAGGREGATORLANDUNITDATA_H_
2 #define MOJA_MODULES_CBM_CBMAGGREGATORLANDUNITDATA_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
8 #include "moja/flint/spatiallocationinfo.h"
9 
10 #include <Poco/Mutex.h>
11 
12 #include <vector>
13 
14 namespace moja {
15 namespace flint {
16  template<class TPersistable, class TRecord>
17  class RecordAccumulatorWithMutex2;
18 }
19 
20 namespace modules {
21 namespace cbm {
22 
23  class CBM_API CBMAggregatorLandUnitData : public CBMModuleBase {
24  public:
26  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DateRow, DateRecord>> dateDimension,
27  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolInfoRow, PoolInfoRecord>> poolInfoDimension,
34  std::shared_ptr<std::vector<std::string>> classifierNames,
35  std::shared_ptr<Poco::Mutex> classifierNamesLock,
36  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolRow, PoolRecord>> poolDimension,
37  std::shared_ptr<flint::RecordAccumulatorWithMutex2<FluxRow, FluxRecord>> fluxDimension,
38  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeClassRow, AgeClassRecord>> AgeClassDimension,
39  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeAreaRow, AgeAreaRecord>> AgeAreaDimension,
40  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ErrorRow, ErrorRecord>> errorDimension,
42  : CBMModuleBase(),
43  _dateDimension(dateDimension),
44  _poolInfoDimension(poolInfoDimension),
45  _classifierSetDimension(classifierSetDimension),
46  _landClassDimension(landClassDimension),
47  _locationDimension(locationDimension),
48  _moduleInfoDimension(moduleInfoDimension),
49  _disturbanceTypeDimension(disturbanceTypeDimension),
50  _disturbanceDimension(disturbanceDimension),
51  _classifierNames(classifierNames),
52  _classifierNamesLock(classifierNamesLock),
53  _poolDimension(poolDimension),
54  _fluxDimension(fluxDimension),
55  _ageClassDimension(AgeClassDimension),
56  _ageAreaDimension(AgeAreaDimension),
57  _errorDimension(errorDimension),
58  _locationErrorDimension(locationErrorDimension),
59  _landUnitArea(0),
60  _previousLocationId(0) {}
61 
62  virtual ~CBMAggregatorLandUnitData() = default;
63 
64  void configure(const DynamicObject& config) override;
65  void subscribe(NotificationCenter& notificationCenter) override;
66 
67  flint::ModuleTypes moduleType() override { return flint::ModuleTypes::System; };
68 
69  void doLocalDomainInit() override;
70  void doTimingInit() override;
71  void doOutputStep() override;
72  void doError(std::string msg) override;
73 
74  private:
75  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DateRow, DateRecord>> _dateDimension;
76  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolInfoRow, PoolInfoRecord>> _poolInfoDimension;
77  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ClassifierSetRow, ClassifierSetRecord>> _classifierSetDimension;
78  std::shared_ptr<flint::RecordAccumulatorWithMutex2<LandClassRow, LandClassRecord>> _landClassDimension;
79  std::shared_ptr<flint::RecordAccumulatorWithMutex2<TemporalLocationRow, TemporalLocationRecord>> _locationDimension;
80  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ModuleInfoRow, ModuleInfoRecord>> _moduleInfoDimension;
81  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolRow, PoolRecord>> _poolDimension;
82  std::shared_ptr<flint::RecordAccumulatorWithMutex2<FluxRow, FluxRecord>> _fluxDimension;
83  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeClassRow, AgeClassRecord>> _ageClassDimension;
84  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeAreaRow, AgeAreaRecord>> _ageAreaDimension;
85  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DisturbanceTypeRow, DisturbanceTypeRecord>> _disturbanceTypeDimension;
86  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DisturbanceRow, DisturbanceRecord>> _disturbanceDimension;
87  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ErrorRow, ErrorRecord>> _errorDimension;
88  std::shared_ptr<flint::RecordAccumulatorWithMutex2<LocationErrorRow, LocationErrorRecord>> _locationErrorDimension;
89  std::shared_ptr<std::vector<std::string>> _classifierNames;
90  std::shared_ptr<Poco::Mutex> _classifierNamesLock;
91 
92  flint::IVariable* _classifierSet;
93  flint::IVariable* _landClass;
94 
95  std::shared_ptr<const flint::SpatialLocationInfo> _spatialLocationInfo;
96  double _landUnitArea;
99  std::string _classifierSetVar;
101 
102  Int64 getPoolId(const flint::IPool* pool);
103  Int64 recordLocation(bool isSpinup);
104  void recordLandUnitData(bool isSpinup);
105  void recordPoolsSet(Int64 locationId);
106  void recordFluxSet(Int64 locationId);
107  void recordClassifierNames(const DynamicObject& classifierSet);
108  void recordAgeArea(Int64 locationId);
109  void recordAgeClass();
110  bool hasDisturbanceInfo(std::shared_ptr<flint::IOperationResult> flux);
111  };
112 
113 }}} // namespace moja::modules::cbm
114 
115 #endif // MOJA_MODULES_CBM_CBMAGGREGATORLANDUNITDATA_H_
moja::modules::cbm::CBMAggregatorLandUnitData::_ageClassHelper
AgeClassHelper _ageClassHelper
Definition: cbmaggregatorlandunitdata.h:100
moja::modules::cbm::CBMAggregatorLandUnitData::_ageClassDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeClassRow, AgeClassRecord > > _ageClassDimension
Definition: cbmaggregatorlandunitdata.h:83
moja::modules::cbm::CBMAggregatorLandUnitData::_spatialLocationInfo
std::shared_ptr< const flint::SpatialLocationInfo > _spatialLocationInfo
Definition: cbmaggregatorlandunitdata.h:95
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::CBMAggregatorLandUnitData::_disturbanceDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceRow, DisturbanceRecord > > _disturbanceDimension
Definition: cbmaggregatorlandunitdata.h:86
moja::modules::cbm::CBMAggregatorLandUnitData::moduleType
flint::ModuleTypes moduleType() override
Definition: cbmaggregatorlandunitdata.h:67
moja::modules::cbm::CBMAggregatorLandUnitData::_locationDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< TemporalLocationRow, TemporalLocationRecord > > _locationDimension
Definition: cbmaggregatorlandunitdata.h:79
moja::flint::RecordAccumulatorWithMutex2
Definition: cbmaggregatorcsvwriter.h:21
moja::modules::cbm::CBMAggregatorLandUnitData::_errorDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ErrorRow, ErrorRecord > > _errorDimension
Definition: cbmaggregatorlandunitdata.h:87
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::CBMAggregatorLandUnitData::_poolInfoDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolInfoRow, PoolInfoRecord > > _poolInfoDimension
Definition: cbmaggregatorlandunitdata.h:76
moja::modules::cbm::CBMAggregatorLandUnitData::_landClass
flint::IVariable * _landClass
Definition: cbmaggregatorlandunitdata.h:93
moja::modules::cbm::CBMAggregatorLandUnitData::_classifierSetVar
std::string _classifierSetVar
Definition: cbmaggregatorlandunitdata.h:99
moja::modules::cbm::CBMAggregatorLandUnitData::_classifierSetDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ClassifierSetRow, ClassifierSetRecord > > _classifierSetDimension
Definition: cbmaggregatorlandunitdata.h:77
record.h
moja::modules::cbm::CBMAggregatorLandUnitData::_poolDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolRow, PoolRecord > > _poolDimension
Definition: cbmaggregatorlandunitdata.h:81
moja::modules::cbm::CBMAggregatorLandUnitData::_ageAreaDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeAreaRow, AgeAreaRecord > > _ageAreaDimension
Definition: cbmaggregatorlandunitdata.h:84
moja::modules::cbm::CBMAggregatorLandUnitData::_locationErrorDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< LocationErrorRow, LocationErrorRecord > > _locationErrorDimension
Definition: cbmaggregatorlandunitdata.h:88
moja::modules::cbm::CBMAggregatorLandUnitData::_isPrimaryAggregator
bool _isPrimaryAggregator
Definition: cbmaggregatorlandunitdata.h:98
moja::modules::cbm::CBMAggregatorLandUnitData::_classifierNamesLock
std::shared_ptr< Poco::Mutex > _classifierNamesLock
Definition: cbmaggregatorlandunitdata.h:90
moja::flint
Definition: cbmaggregatorcsvwriter.h:19
moja::modules::cbm::CBMAggregatorLandUnitData::_disturbanceTypeDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceTypeRow, DisturbanceTypeRecord > > _disturbanceTypeDimension
Definition: cbmaggregatorlandunitdata.h:85
moja::modules::cbm::CBMAggregatorLandUnitData
Definition: cbmaggregatorlandunitdata.h:23
moja::modules::cbm::CBMAggregatorLandUnitData::_classifierSet
flint::IVariable * _classifierSet
Definition: cbmaggregatorlandunitdata.h:92
moja::modules::cbm::CBMAggregatorLandUnitData::_landClassDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< LandClassRow, LandClassRecord > > _landClassDimension
Definition: cbmaggregatorlandunitdata.h:78
moja::modules::cbm::CBMAggregatorLandUnitData::CBMAggregatorLandUnitData
CBMAggregatorLandUnitData(std::shared_ptr< flint::RecordAccumulatorWithMutex2< DateRow, DateRecord >> dateDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolInfoRow, PoolInfoRecord >> poolInfoDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< ClassifierSetRow, ClassifierSetRecord >> classifierSetDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< LandClassRow, LandClassRecord >> landClassDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< TemporalLocationRow, TemporalLocationRecord >> locationDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< ModuleInfoRow, ModuleInfoRecord >> moduleInfoDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceTypeRow, DisturbanceTypeRecord >> disturbanceTypeDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceRow, DisturbanceRecord >> disturbanceDimension, std::shared_ptr< std::vector< std::string >> classifierNames, std::shared_ptr< Poco::Mutex > classifierNamesLock, std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolRow, PoolRecord >> poolDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< FluxRow, FluxRecord >> fluxDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeClassRow, AgeClassRecord >> AgeClassDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeAreaRow, AgeAreaRecord >> AgeAreaDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< ErrorRow, ErrorRecord >> errorDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< LocationErrorRow, LocationErrorRecord >> locationErrorDimension)
Definition: cbmaggregatorlandunitdata.h:25
moja::modules::cbm::CBMAggregatorLandUnitData::_previousLocationId
Int64 _previousLocationId
Definition: cbmaggregatorlandunitdata.h:97
moja::modules::cbm::AgeClassHelper
Definition: ageclasshelper.h:11
ageclasshelper.h
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::CBMAggregatorLandUnitData::_dateDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DateRow, DateRecord > > _dateDimension
Definition: cbmaggregatorlandunitdata.h:75
moja::modules::cbm::CBMAggregatorLandUnitData::_moduleInfoDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ModuleInfoRow, ModuleInfoRecord > > _moduleInfoDimension
Definition: cbmaggregatorlandunitdata.h:80
cbmmodulebase.h
moja::modules::cbm::CBMAggregatorLandUnitData::_fluxDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< FluxRow, FluxRecord > > _fluxDimension
Definition: cbmaggregatorlandunitdata.h:82
moja::modules::cbm::CBMAggregatorLandUnitData::_classifierNames
std::shared_ptr< std::vector< std::string > > _classifierNames
Definition: cbmaggregatorlandunitdata.h:89
moja::modules::cbm::CBMAggregatorLandUnitData::_landUnitArea
double _landUnitArea
Definition: cbmaggregatorlandunitdata.h:96