GCBM
cbmdisturbancelistener.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMDISTURBANCELISTENER_H_
2 #define MOJA_MODULES_CBM_CBMDISTURBANCELISTENER_H_
3 
5 #include "moja/hash.h"
6 #include "moja/flint/ivariable.h"
7 #include "moja/flint/ipool.h"
8 #include "moja/flint/itiming.h"
9 
10 #include <unordered_map>
11 #include <unordered_set>
12 
13 namespace moja {
14  namespace modules {
15  namespace cbm {
16 
18  std::string disturbanceType;
19  int year;
21  };
22 
24  bool hadRunConditions = false;
25  bool shouldRun = false;
26  std::string newDisturbanceType = "";
27 
28  void merge(const DisturbanceConditionResult& other) {
30  shouldRun = shouldRun || other.shouldRun;
31  if (newDisturbanceType == "") {
33  }
34  }
35  };
36 
38  public:
39  virtual ~IDisturbanceSubCondition() = default;
40 
41  virtual bool check() const = 0;
42  };
43 
45  LessThan,
46  EqualTo,
47  AtLeast,
48  Between,
49  In,
50  NotIn
51  };
52 
54  std::string disturbanceType;
55  int maxYearsAgo = 9999;
57  DynamicVar ageAtDisturbance = 0;
58  };
59 
61  public:
63  const std::vector<std::string> disturbanceTypes,
64  const std::vector<std::shared_ptr<IDisturbanceSubCondition>> matchConditions,
65  const std::vector<std::shared_ptr<IDisturbanceSubCondition>> runConditions,
66  const std::vector<std::shared_ptr<IDisturbanceSubCondition>> overrideConditions,
67  const std::string& overrideDisturbanceType = "") : _disturbanceTypes(disturbanceTypes),
68  _matchConditions(matchConditions), _runConditions(runConditions),
69  _overrideConditions(overrideConditions), _overrideDisturbanceType(overrideDisturbanceType) { }
70 
71  bool isApplicable(const std::string& disturbanceType) {
72  bool isMatchingDisturbance = false;
73  for (const auto& matchDisturbanceType : _disturbanceTypes) {
74  if (disturbanceType == matchDisturbanceType) {
75  isMatchingDisturbance = true;
76  break;
77  }
78  }
79 
80  if (!isMatchingDisturbance) {
81  return false;
82  }
83 
84  for (auto matchCondition : _matchConditions) {
85  if (!matchCondition->check()) {
86  return false;
87  }
88  }
89 
90  return true;
91  }
92 
95 
96  if (_runConditions.size() > 0) {
97  result.hadRunConditions = true;
98  }
99 
100  for (auto runCondition : _runConditions) {
101  if (runCondition->check()) {
102  result.shouldRun = true;
103  break;
104  }
105  }
106 
107  if (result.hadRunConditions && !result.shouldRun) {
108  return result;
109  }
110 
111  for (auto overrideCondition : _overrideConditions) {
112  if (overrideCondition->check()) {
114  break;
115  }
116  }
117 
118  return result;
119  }
120 
121  private:
122  const std::vector<std::string> _disturbanceTypes;
123  const std::vector<std::shared_ptr<IDisturbanceSubCondition>> _matchConditions;
124  const std::vector<std::shared_ptr<IDisturbanceSubCondition>> _runConditions;
125  const std::vector<std::shared_ptr<IDisturbanceSubCondition>> _overrideConditions;
126  const std::string _overrideDisturbanceType;
127  };
128 
130  public:
131  CompositeDisturbanceSubCondition(std::vector<std::shared_ptr<IDisturbanceSubCondition>> conditions) :
132  _conditions(conditions) { }
133 
134  bool check() const override {
135  for (const auto condition : _conditions) {
136  if (!condition->check()) {
137  return false;
138  }
139  }
140 
141  return true;
142  }
143 
144  private:
145  std::vector<std::shared_ptr<IDisturbanceSubCondition>> _conditions;
146  };
147 
149  public:
151  const flint::IVariable* var, DisturbanceConditionType type, const DynamicVar& target,
152  const std::string& propertyName = "") : _var(var), _property(propertyName),
153  _type(type), _target(target) { }
154 
155  bool check() const override {
156  const auto value = _property == "" ? _var->value() : _var->value()[_property];
157  return _type == DisturbanceConditionType::LessThan ? value - _target < 0
160  : _type == DisturbanceConditionType::Between ? value >= _target[0] && value <= _target[1]
163  : false;
164  }
165 
166  private:
167  const std::string _property;
168  const flint::IVariable* _var;
170  const DynamicVar _target;
171 
172  bool search(DynamicVar value) const {
173  for (const auto& targetValue : _target) {
174  if (value == targetValue) {
175  return true;
176  }
177  }
178 
179  return false;
180  }
181  };
182 
184  public:
186  std::vector<const flint::IPool*> pools, DisturbanceConditionType type, const DynamicVar& target)
187  : _pools(pools), _type(type), _target(target) { }
188 
189  bool check() const override {
190  double sum = 0.0;
191  for (auto pool : _pools) {
192  sum += pool->value();
193  }
194 
195  return _type == DisturbanceConditionType::LessThan ? sum - _target < 0
198  : _type == DisturbanceConditionType::Between ? sum >= _target[0] && sum <= _target[1]
199  : false;
200  }
201 
202  private:
203  const std::vector<const flint::IPool*> _pools;
205  const DynamicVar _target;
206  };
207 
209  public:
211  flint::ITiming* timing,
212  std::shared_ptr<std::deque<DisturbanceHistoryRecord>> disturbanceHistory,
213  const std::vector<DisturbanceHistoryCondition>& sequence)
214  : _timing(timing), _disturbanceHistory(disturbanceHistory), _sequence(sequence) { }
215 
216  bool check() const override {
217  auto referenceYear = _timing->curStartDate().year();
218  int historyIndex = 0;
219  int lastHistoryIndex = _disturbanceHistory->size() - 1;
220  for (auto i = 0; i < _sequence.size(); i++) {
221  const auto& expected = _sequence[i];
222  bool matchNone = expected.disturbanceType == "none";
223  bool matchAny = expected.disturbanceType == "any";
224 
225  if (historyIndex > lastHistoryIndex) {
226  return (matchNone && i == _sequence.size() - 1) ? true : false;
227  }
228 
229  const auto& actual = _disturbanceHistory->operator[](historyIndex);
230 
231  if (!(matchNone || matchAny) && expected.disturbanceType != actual.disturbanceType) {
232  return false;
233  }
234 
235  bool withinMaxYears = expected.maxYearsAgo == -1 || referenceYear - actual.year <= expected.maxYearsAgo;
236  if (matchNone && withinMaxYears) {
237  return false;
238  }
239  else if (!matchNone && !withinMaxYears) {
240  return false;
241  }
242 
243  if (!(expected.ageComparison == DisturbanceConditionType::LessThan ? actual.ageAtDisturbance - expected.ageAtDisturbance < 0
244  : expected.ageComparison == DisturbanceConditionType::EqualTo ? actual.ageAtDisturbance == expected.ageAtDisturbance
245  : expected.ageComparison == DisturbanceConditionType::AtLeast ? actual.ageAtDisturbance - expected.ageAtDisturbance >= 0
246  : expected.ageComparison == DisturbanceConditionType::Between ? actual.ageAtDisturbance >= expected.ageAtDisturbance[0] && actual.ageAtDisturbance <= expected.ageAtDisturbance[1]
247  : false)) {
248 
249  return false;
250  }
251 
252  if (!matchNone) {
253  referenceYear = actual.year;
254  historyIndex++;
255  }
256  else {
257  // "Match none" condition passed, so the next sequence condition
258  // gets checked against the same disturbance event relative to the
259  // end of the "Match none" time period.
260  if (expected.maxYearsAgo != -1) {
261  referenceYear -= expected.maxYearsAgo;
262  }
263  }
264  }
265 
266  return true;
267  }
268 
269  private:
270  flint::ITiming* _timing;
271  std::shared_ptr<std::deque<DisturbanceHistoryRecord>> _disturbanceHistory;
272  std::vector<DisturbanceHistoryCondition> _sequence;
273  };
274 
276  public:
277  CBMDistEventRef() = default;
278 
279  explicit CBMDistEventRef(
280  std::string& disturbanceType, int year, int transitionId,
281  std::vector<std::shared_ptr<IDisturbanceSubCondition>> conditions,
282  const DynamicObject& metadata) :
284  _disturbanceConditions(conditions), _metadata(metadata) { }
285 
286  std::string disturbanceType() const { return _disturbanceType; }
288  int transitionRuleId() const { return _transitionRuleId; }
289  int year() const { return _year; }
290  const DynamicObject& metadata() { return _metadata; }
291 
293  for (const auto condition : _disturbanceConditions) {
294  if (!condition->check()) {
295  return false;
296  }
297  }
298 
299  return true;
300  }
301 
302  private:
303  std::string _disturbanceType;
305  int _year;
306  DynamicObject _metadata;
307  std::vector<std::shared_ptr<IDisturbanceSubCondition>> _disturbanceConditions;
308  };
309 
311  public:
312  CBMDistEventTransfer() = default;
313 
314  CBMDistEventTransfer(flint::ILandUnitDataWrapper& landUnitData, const DynamicObject& data) :
315  _disturbanceMatrixId(data["disturbance_matrix_id"]),
316  _sourcePool(landUnitData.getPool(data["source_pool_name"].convert<std::string>())),
317  _destPool(landUnitData.getPool(data["dest_pool_name"].convert<std::string>())),
318  _proportion(data["proportion"]) { }
319 
320  CBMDistEventTransfer(flint::ILandUnitDataWrapper& landUnitData, const std::string& sourcePool,
321  const std::string& destPool, double proportion) :
323  _sourcePool(landUnitData.getPool(sourcePool)),
324  _destPool(landUnitData.getPool(destPool)),
326 
328  const flint::IPool* sourcePool() const { return _sourcePool; }
329  const flint::IPool* destPool() const { return _destPool; }
330  double proportion() const { return _proportion; }
332 
333  private:
335  const flint::IPool* _sourcePool;
336  const flint::IPool* _destPool;
337  double _proportion;
338  };
339 
341  public:
343  _disturbanceHistory = std::make_shared<std::deque<DisturbanceHistoryRecord>>();
344  }
345 
346  virtual ~CBMDisturbanceListener() = default;
347 
348  void configure(const DynamicObject& config) override;
349  void subscribe(NotificationCenter& notificationCenter) override;
350 
351  flint::ModuleTypes moduleType() { return flint::ModuleTypes::DisturbanceEvent; };
352 
353  virtual void doLocalDomainInit() override;
354  virtual void doSystemShutdown() override;
355  virtual void doTimingInit() override;
356  virtual void doTimingStep() override;
357  virtual void doDisturbanceEvent(DynamicVar) override;
358 
359  private:
360  typedef std::vector<CBMDistEventTransfer> EventVector;
361  typedef std::unordered_map<int, EventVector> EventMap;
362 
363  NotificationCenter* _notificationCenter;
364  std::vector<std::string> _layerNames;
365  std::vector<const flint::IVariable*> _layers;
366  flint::IVariable* _landClass;
367  flint::IVariable* _spu;
368  flint::IVariable* _classifierSet;
369  flint::IVariable* _age;
371 
372  std::unordered_map<std::pair<int, std::string>, std::pair<int, int>> _peatlandDmAssociations;
373  std::unordered_map<std::pair<std::string, int>, int> _dmAssociations;
374  std::unordered_map<std::string, std::string> _landClassTransitions;
375  std::map<int, std::vector<CBMDistEventRef>> _landUnitEvents;
376  std::unordered_map<std::string, int> _distTypeCodes;
377  std::unordered_map<int, std::string> _distTypeNames;
378  std::unordered_set<std::string> _errorLayers;
379  std::unordered_set<std::string> _classifierNames;
380  std::unordered_map<std::string, int> _disturbanceOrder;
381 
383  DynamicVar _conditionConfig;
384  std::vector<DisturbanceCondition> _disturbanceConditions;
385  std::shared_ptr<std::deque<DisturbanceHistoryRecord>> _disturbanceHistory;
386 
387  void fetchMatrices();
388  void fetchDMAssociations();
390  void fetchDistTypeCodes();
392  void fetchDisturbanceOrder();
393  std::shared_ptr<IDisturbanceSubCondition> createSubCondition(const DynamicObject& config);
394  std::string getDisturbanceTypeName(const DynamicObject& eventData);
395  bool addLandUnitEvent(const DynamicVar& eventData);
398  };
399 
400  }
401  }
402 } // namespace moja::modules::cbm
403 #endif // MOJA_MODULES_CBM_CBMDISTURBANCELISTENER_H_
moja::modules::cbm::CBMDisturbanceListener::configure
void configure(const DynamicObject &config) override
Definition: cbmdisturbancelistener.cpp:45
moja::modules::cbm::CBMDisturbanceListener::_conditionConfig
DynamicVar _conditionConfig
Definition: cbmdisturbancelistener.h:383
moja::modules::cbm::IDisturbanceSubCondition::~IDisturbanceSubCondition
virtual ~IDisturbanceSubCondition()=default
moja::modules::cbm::DisturbanceSequenceSubCondition::_disturbanceHistory
std::shared_ptr< std::deque< DisturbanceHistoryRecord > > _disturbanceHistory
Definition: cbmdisturbancelistener.h:271
moja::modules::cbm::CBMDistEventRef::CBMDistEventRef
CBMDistEventRef()=default
moja::modules::cbm::DisturbanceHistoryCondition::ageAtDisturbance
DynamicVar ageAtDisturbance
Definition: cbmdisturbancelistener.h:57
moja::modules::cbm::CBMDistEventRef::metadata
const DynamicObject & metadata()
Definition: cbmdisturbancelistener.h:290
moja::modules::cbm::DisturbanceConditionResult
Definition: cbmdisturbancelistener.h:23
moja::modules::cbm::DisturbanceHistoryRecord::year
int year
Definition: cbmdisturbancelistener.h:19
moja::modules::cbm::DisturbanceCondition::_overrideDisturbanceType
const std::string _overrideDisturbanceType
Definition: cbmdisturbancelistener.h:126
moja::modules::cbm::CompositeDisturbanceSubCondition
Definition: cbmdisturbancelistener.h:129
moja::modules::cbm::DisturbanceHistoryRecord::ageAtDisturbance
int ageAtDisturbance
Definition: cbmdisturbancelistener.h:20
moja::modules::cbm::DisturbanceConditionResult::merge
void merge(const DisturbanceConditionResult &other)
Definition: cbmdisturbancelistener.h:28
moja::modules::cbm::DisturbanceCondition::isApplicable
bool isApplicable(const std::string &disturbanceType)
Definition: cbmdisturbancelistener.h:71
moja::modules::cbm::DisturbanceCondition::_matchConditions
const std::vector< std::shared_ptr< IDisturbanceSubCondition > > _matchConditions
Definition: cbmdisturbancelistener.h:123
moja::modules::cbm::DisturbanceCondition
Definition: cbmdisturbancelistener.h:60
moja::modules::cbm::DisturbanceConditionType::EqualTo
@ EqualTo
moja::modules::cbm::DisturbanceConditionType::In
@ In
moja::modules::cbm::VariableDisturbanceSubCondition
Definition: cbmdisturbancelistener.h:148
moja::modules::cbm::VariableDisturbanceSubCondition::_property
const std::string _property
Definition: cbmdisturbancelistener.h:167
moja::modules::cbm::CBMDisturbanceListener
Definition: cbmdisturbancelistener.h:340
moja::modules::cbm::CBMDisturbanceListener::_disturbanceConditionsInitialized
bool _disturbanceConditionsInitialized
Definition: cbmdisturbancelistener.h:382
moja::modules::cbm::CBMDistEventRef::_disturbanceConditions
std::vector< std::shared_ptr< IDisturbanceSubCondition > > _disturbanceConditions
Definition: cbmdisturbancelistener.h:307
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::CBMDisturbanceListener::doSystemShutdown
virtual void doSystemShutdown() override
Definition: cbmdisturbancelistener.cpp:107
moja::modules::cbm::CBMDisturbanceListener::_classifierNames
std::unordered_set< std::string > _classifierNames
Definition: cbmdisturbancelistener.h:379
moja::modules::cbm::CBMDisturbanceListener::fetchMatrices
void fetchMatrices()
Definition: cbmdisturbancelistener.cpp:564
moja::modules::cbm::DisturbanceHistoryCondition::ageComparison
DisturbanceConditionType ageComparison
Definition: cbmdisturbancelistener.h:56
moja::modules::cbm::VariableDisturbanceSubCondition::search
bool search(DynamicVar value) const
Definition: cbmdisturbancelistener.h:172
moja::modules::cbm::CBMDisturbanceListener::_matrices
EventMap _matrices
Definition: cbmdisturbancelistener.h:370
moja::modules::cbm::CBMDistEventTransfer
Definition: cbmdisturbancelistener.h:310
moja::modules::cbm::DisturbanceHistoryCondition::maxYearsAgo
int maxYearsAgo
Definition: cbmdisturbancelistener.h:55
moja::modules::cbm::IDisturbanceSubCondition
Definition: cbmdisturbancelistener.h:37
moja::modules::cbm::PoolDisturbanceSubCondition::_pools
const std::vector< const flint::IPool * > _pools
Definition: cbmdisturbancelistener.h:203
moja::modules::cbm::DisturbanceSequenceSubCondition::DisturbanceSequenceSubCondition
DisturbanceSequenceSubCondition(flint::ITiming *timing, std::shared_ptr< std::deque< DisturbanceHistoryRecord >> disturbanceHistory, const std::vector< DisturbanceHistoryCondition > &sequence)
Definition: cbmdisturbancelistener.h:210
moja::modules::cbm::DisturbanceConditionResult::newDisturbanceType
std::string newDisturbanceType
Definition: cbmdisturbancelistener.h:26
moja::modules::cbm::DisturbanceCondition::DisturbanceCondition
DisturbanceCondition(const std::vector< std::string > disturbanceTypes, const std::vector< std::shared_ptr< IDisturbanceSubCondition >> matchConditions, const std::vector< std::shared_ptr< IDisturbanceSubCondition >> runConditions, const std::vector< std::shared_ptr< IDisturbanceSubCondition >> overrideConditions, const std::string &overrideDisturbanceType="")
Definition: cbmdisturbancelistener.h:62
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::CBMDistEventRef::disturbanceType
std::string disturbanceType() const
Definition: cbmdisturbancelistener.h:286
moja::modules::cbm::CBMDistEventRef::_year
int _year
Definition: cbmdisturbancelistener.h:305
moja::modules::cbm::DisturbanceCondition::_disturbanceTypes
const std::vector< std::string > _disturbanceTypes
Definition: cbmdisturbancelistener.h:122
moja::modules::cbm::CBMDisturbanceListener::_dmAssociations
std::unordered_map< std::pair< std::string, int >, int > _dmAssociations
Definition: cbmdisturbancelistener.h:373
moja::modules::cbm::CBMDistEventRef::_metadata
DynamicObject _metadata
Definition: cbmdisturbancelistener.h:306
moja::modules::cbm::CBMDisturbanceListener::EventMap
std::unordered_map< int, EventVector > EventMap
Definition: cbmdisturbancelistener.h:361
moja::modules::cbm::CBMDistEventRef::transitionRuleId
int transitionRuleId() const
Definition: cbmdisturbancelistener.h:288
moja::modules::cbm::CBMDistEventTransfer::_disturbanceMatrixId
int _disturbanceMatrixId
Definition: cbmdisturbancelistener.h:334
moja::modules::cbm::CBMDistEventTransfer::_destPool
const flint::IPool * _destPool
Definition: cbmdisturbancelistener.h:336
moja::modules::cbm::CBMDisturbanceListener::_notificationCenter
NotificationCenter * _notificationCenter
Definition: cbmdisturbancelistener.h:363
moja::modules::cbm::CBMDisturbanceListener::fetchDistTypeCodes
void fetchDistTypeCodes()
Definition: cbmdisturbancelistener.cpp:637
moja::modules::cbm::CBMDisturbanceListener::getDisturbanceTypeName
std::string getDisturbanceTypeName(const DynamicObject &eventData)
Definition: cbmdisturbancelistener.cpp:264
moja::modules::cbm::PoolDisturbanceSubCondition::check
bool check() const override
Definition: cbmdisturbancelistener.h:189
moja::modules::cbm::CompositeDisturbanceSubCondition::CompositeDisturbanceSubCondition
CompositeDisturbanceSubCondition(std::vector< std::shared_ptr< IDisturbanceSubCondition >> conditions)
Definition: cbmdisturbancelistener.h:131
moja::modules::cbm::CBMDisturbanceListener::_age
flint::IVariable * _age
Definition: cbmdisturbancelistener.h:369
moja::modules::cbm::DisturbanceHistoryCondition
Definition: cbmdisturbancelistener.h:53
moja::modules::cbm::CBMDistEventTransfer::destPool
const flint::IPool * destPool() const
Definition: cbmdisturbancelistener.h:329
moja::modules::cbm::CBMDistEventRef::checkConditions
bool checkConditions()
Definition: cbmdisturbancelistener.h:292
moja::modules::cbm::CBMDistEventTransfer::_sourcePool
const flint::IPool * _sourcePool
Definition: cbmdisturbancelistener.h:335
moja::modules::cbm::CBMDisturbanceListener::doTimingInit
virtual void doTimingInit() override
Definition: cbmdisturbancelistener.cpp:151
moja::modules::cbm::CBMDisturbanceListener::doTimingStep
virtual void doTimingStep() override
Definition: cbmdisturbancelistener.cpp:365
moja::modules::cbm::CBMDisturbanceListener::_peatlandDmAssociations
std::unordered_map< std::pair< int, std::string >, std::pair< int, int > > _peatlandDmAssociations
Definition: cbmdisturbancelistener.h:372
moja::modules::cbm::CBMDistEventTransfer::setProportion
void setProportion(double proportion)
Definition: cbmdisturbancelistener.h:331
moja::modules::cbm::CBMDisturbanceListener::moduleType
flint::ModuleTypes moduleType()
Definition: cbmdisturbancelistener.h:351
moja::modules::cbm::CBMDisturbanceListener::firePeatlandDisturbanceEvent
void firePeatlandDisturbanceEvent(CBMDistEventRef &e)
Definition: cbmdisturbancelistener.cpp:446
moja::modules::cbm::DisturbanceConditionType::NotIn
@ NotIn
moja::modules::cbm::CBMDisturbanceListener::~CBMDisturbanceListener
virtual ~CBMDisturbanceListener()=default
moja::modules::cbm::CBMDisturbanceListener::_errorLayers
std::unordered_set< std::string > _errorLayers
Definition: cbmdisturbancelistener.h:378
moja::modules::cbm::CBMDistEventRef::CBMDistEventRef
CBMDistEventRef(std::string &disturbanceType, int year, int transitionId, std::vector< std::shared_ptr< IDisturbanceSubCondition >> conditions, const DynamicObject &metadata)
Definition: cbmdisturbancelistener.h:279
moja::modules::cbm::DisturbanceConditionType::Between
@ Between
moja::modules::cbm::CBMDistEventTransfer::disturbanceMatrixId
int disturbanceMatrixId() const
Definition: cbmdisturbancelistener.h:327
moja::modules::cbm::CBMDisturbanceListener::_disturbanceConditions
std::vector< DisturbanceCondition > _disturbanceConditions
Definition: cbmdisturbancelistener.h:384
moja::modules::cbm::CBMDistEventTransfer::proportion
double proportion() const
Definition: cbmdisturbancelistener.h:330
moja::modules::cbm::CBMDisturbanceListener::createSubCondition
std::shared_ptr< IDisturbanceSubCondition > createSubCondition(const DynamicObject &config)
Definition: cbmdisturbancelistener.cpp:737
moja::modules::cbm::DisturbanceConditionType
DisturbanceConditionType
Definition: cbmdisturbancelistener.h:44
moja::modules::cbm::CBMDistEventTransfer::CBMDistEventTransfer
CBMDistEventTransfer(flint::ILandUnitDataWrapper &landUnitData, const DynamicObject &data)
Definition: cbmdisturbancelistener.h:314
moja::modules::cbm::DisturbanceSequenceSubCondition::_timing
flint::ITiming * _timing
Definition: cbmdisturbancelistener.h:270
moja::modules::cbm::CBMDisturbanceListener::CBMDisturbanceListener
CBMDisturbanceListener()
Definition: cbmdisturbancelistener.h:342
moja::modules::cbm::CBMDisturbanceListener::_disturbanceOrder
std::unordered_map< std::string, int > _disturbanceOrder
Definition: cbmdisturbancelistener.h:380
moja::modules::cbm::VariableDisturbanceSubCondition::_target
const DynamicVar _target
Definition: cbmdisturbancelistener.h:170
moja::modules::cbm::DisturbanceHistoryRecord::disturbanceType
std::string disturbanceType
Definition: cbmdisturbancelistener.h:18
moja::modules::cbm::PoolDisturbanceSubCondition
Definition: cbmdisturbancelistener.h:183
moja::modules::cbm::CBMDisturbanceListener::_classifierSet
flint::IVariable * _classifierSet
Definition: cbmdisturbancelistener.h:368
moja::modules::cbm::CBMDistEventTransfer::sourcePool
const flint::IPool * sourcePool() const
Definition: cbmdisturbancelistener.h:328
moja::modules::cbm::CBMDistEventRef::year
int year() const
Definition: cbmdisturbancelistener.h:289
moja::modules::cbm::CBMDistEventTransfer::CBMDistEventTransfer
CBMDistEventTransfer()=default
moja::modules::cbm::CBMDistEventRef::_transitionRuleId
int _transitionRuleId
Definition: cbmdisturbancelistener.h:304
moja::modules::cbm::DisturbanceSequenceSubCondition::_sequence
std::vector< DisturbanceHistoryCondition > _sequence
Definition: cbmdisturbancelistener.h:272
moja::modules::cbm::VariableDisturbanceSubCondition::VariableDisturbanceSubCondition
VariableDisturbanceSubCondition(const flint::IVariable *var, DisturbanceConditionType type, const DynamicVar &target, const std::string &propertyName="")
Definition: cbmdisturbancelistener.h:150
moja::modules::cbm::CompositeDisturbanceSubCondition::check
bool check() const override
Definition: cbmdisturbancelistener.h:134
moja::modules::cbm::CBMDisturbanceListener::_distTypeNames
std::unordered_map< int, std::string > _distTypeNames
Definition: cbmdisturbancelistener.h:377
moja::modules::cbm::VariableDisturbanceSubCondition::check
bool check() const override
Definition: cbmdisturbancelistener.h:155
moja::modules::cbm::DisturbanceSequenceSubCondition::check
bool check() const override
Definition: cbmdisturbancelistener.h:216
moja::modules::cbm::CBMDisturbanceListener::fireCBMDisturbanceEvent
void fireCBMDisturbanceEvent(CBMDistEventRef &e)
Definition: cbmdisturbancelistener.cpp:497
moja::modules::cbm::DisturbanceCondition::check
DisturbanceConditionResult check()
Definition: cbmdisturbancelistener.h:93
moja::modules::cbm::VariableDisturbanceSubCondition::_var
const flint::IVariable * _var
Definition: cbmdisturbancelistener.h:168
moja::modules::cbm::DisturbanceConditionType::AtLeast
@ AtLeast
moja::modules::cbm::DisturbanceCondition::_runConditions
const std::vector< std::shared_ptr< IDisturbanceSubCondition > > _runConditions
Definition: cbmdisturbancelistener.h:124
moja::modules::cbm::CBMDisturbanceListener::_landClassTransitions
std::unordered_map< std::string, std::string > _landClassTransitions
Definition: cbmdisturbancelistener.h:374
moja::modules::cbm::DisturbanceConditionResult::hadRunConditions
bool hadRunConditions
Definition: cbmdisturbancelistener.h:24
moja::modules::cbm::CBMDistEventTransfer::CBMDistEventTransfer
CBMDistEventTransfer(flint::ILandUnitDataWrapper &landUnitData, const std::string &sourcePool, const std::string &destPool, double proportion)
Definition: cbmdisturbancelistener.h:320
moja::modules::cbm::DisturbanceConditionType::LessThan
@ LessThan
moja::modules::cbm::CBMDisturbanceListener::fetchPeatlandDMAssociations
void fetchPeatlandDMAssociations()
Definition: cbmdisturbancelistener.cpp:666
moja::modules::cbm::IDisturbanceSubCondition::check
virtual bool check() const =0
moja::modules::cbm::DisturbanceCondition::_overrideConditions
const std::vector< std::shared_ptr< IDisturbanceSubCondition > > _overrideConditions
Definition: cbmdisturbancelistener.h:125
moja::modules::cbm::CBMDisturbanceListener::addLandUnitEvent
bool addLandUnitEvent(const DynamicVar &eventData)
Definition: cbmdisturbancelistener.cpp:314
moja::modules::cbm::CBMDisturbanceListener::EventVector
std::vector< CBMDistEventTransfer > EventVector
Definition: cbmdisturbancelistener.h:360
moja::modules::cbm::CBMDisturbanceListener::fetchDMAssociations
void fetchDMAssociations()
Definition: cbmdisturbancelistener.cpp:591
moja::modules::cbm::DisturbanceHistoryRecord
Definition: cbmdisturbancelistener.h:17
moja::modules::cbm::CBMDisturbanceListener::_landClass
flint::IVariable * _landClass
Definition: cbmdisturbancelistener.h:366
moja::modules::cbm::PoolDisturbanceSubCondition::_type
const DisturbanceConditionType _type
Definition: cbmdisturbancelistener.h:204
moja::modules::cbm::DisturbanceHistoryCondition::disturbanceType
std::string disturbanceType
Definition: cbmdisturbancelistener.h:54
moja::modules::cbm::CBMDisturbanceListener::subscribe
void subscribe(NotificationCenter &notificationCenter) override
Definition: cbmdisturbancelistener.cpp:65
moja::modules::cbm::PoolDisturbanceSubCondition::_target
const DynamicVar _target
Definition: cbmdisturbancelistener.h:205
moja::modules::cbm::CBMDisturbanceListener::_spu
flint::IVariable * _spu
Definition: cbmdisturbancelistener.h:367
moja::modules::cbm::PoolDisturbanceSubCondition::PoolDisturbanceSubCondition
PoolDisturbanceSubCondition(std::vector< const flint::IPool * > pools, DisturbanceConditionType type, const DynamicVar &target)
Definition: cbmdisturbancelistener.h:185
moja::modules::cbm::CBMDistEventRef::_disturbanceType
std::string _disturbanceType
Definition: cbmdisturbancelistener.h:303
moja::modules::cbm::CBMDisturbanceListener::_layerNames
std::vector< std::string > _layerNames
Definition: cbmdisturbancelistener.h:364
moja::modules::cbm::DisturbanceSequenceSubCondition
Definition: cbmdisturbancelistener.h:208
moja::modules::cbm::CompositeDisturbanceSubCondition::_conditions
std::vector< std::shared_ptr< IDisturbanceSubCondition > > _conditions
Definition: cbmdisturbancelistener.h:145
moja::modules::cbm::CBMDisturbanceListener::_disturbanceHistory
std::shared_ptr< std::deque< DisturbanceHistoryRecord > > _disturbanceHistory
Definition: cbmdisturbancelistener.h:385
moja
Definition: ageclasshelper.cpp:10
moja::modules::cbm::CBMDisturbanceListener::fetchLandClassTransitions
void fetchLandClassTransitions()
Definition: cbmdisturbancelistener.cpp:612
moja::modules::cbm::CBMDisturbanceListener::doDisturbanceEvent
virtual void doDisturbanceEvent(DynamicVar) override
Definition: cbmdisturbancelistener.cpp:124
moja::modules::cbm::CBMDistEventRef
Definition: cbmdisturbancelistener.h:275
moja::modules::cbm::CBMDisturbanceListener::_landUnitEvents
std::map< int, std::vector< CBMDistEventRef > > _landUnitEvents
Definition: cbmdisturbancelistener.h:375
moja::modules::cbm::CBMDistEventTransfer::_proportion
double _proportion
Definition: cbmdisturbancelistener.h:337
moja::modules::cbm::CBMDisturbanceListener::fetchDisturbanceOrder
void fetchDisturbanceOrder()
Definition: cbmdisturbancelistener.cpp:692
cbmmodulebase.h
moja::modules::cbm::CBMDisturbanceListener::_layers
std::vector< const flint::IVariable * > _layers
Definition: cbmdisturbancelistener.h:365
moja::modules::cbm::CBMDisturbanceListener::doLocalDomainInit
virtual void doLocalDomainInit() override
Definition: cbmdisturbancelistener.cpp:84
moja::modules::cbm::CBMDisturbanceListener::_distTypeCodes
std::unordered_map< std::string, int > _distTypeCodes
Definition: cbmdisturbancelistener.h:376
moja::modules::cbm::VariableDisturbanceSubCondition::_type
const DisturbanceConditionType _type
Definition: cbmdisturbancelistener.h:169
moja::modules::cbm::DisturbanceConditionResult::shouldRun
bool shouldRun
Definition: cbmdisturbancelistener.h:25
moja::modules::cbm::CBMDistEventRef::setDisturbanceType
void setDisturbanceType(const std::string &disturbanceType)
Definition: cbmdisturbancelistener.h:287