hydrobricks
Loading...
Searching...
No Matches
Flux.h
1#ifndef HYDROBRICKS_FLUX_H
2#define HYDROBRICKS_FLUX_H
3
4#include "../base/ContentTypes.h"
5#include "Includes.h"
6
7class Modifier;
8
9class Flux : public wxObject {
10 public:
11 explicit Flux();
12
13 ~Flux() override = default;
14
20 [[nodiscard]] virtual bool IsValid() const = 0;
21
28 virtual void Validate() const;
29
33 virtual void Reset();
34
40 virtual double GetAmount() = 0;
41
47 virtual void UpdateFlux(double amount);
48
54 void LinkChangeRate(double* rate) {
55 _changeRate = rate;
56 }
57
64 return _changeRate;
65 }
66
72 double* GetAmountPointer() {
73 return &_amount;
74 }
75
81 virtual bool IsForcing() const {
82 return false;
83 }
84
90 virtual bool IsInstantaneous() const {
91 return false;
92 }
93
97 void SetAsStatic() {
98 _static = true;
99 }
100
106 [[nodiscard]] bool IsStatic() const {
107 return _static;
108 }
109
115 [[nodiscard]] bool NeedsWeighting() const {
116 return _needsWeighting;
117 }
118
124 void NeedsWeighting(bool value) {
125 _needsWeighting = value;
126 }
127
133 void SetFractionUnitArea(double value) {
134 _fractionUnitArea = value;
136 }
137
143 void SetFractionLandCover(double value) {
144 _fractionLandCover = value;
146 }
147
152 _fractionTotal = _fractionUnitArea * _fractionLandCover;
153 }
154
160 ContentType GetType() const {
161 return _type;
162 }
163
169 void SetType(const ContentType type) {
170 _type = type;
171 }
172
178 [[nodiscard]] bool HasChangeRate() const {
179 return _changeRate != nullptr;
180 }
181
187 [[nodiscard]] bool HasModifier() const {
188 return _modifier != nullptr;
189 }
190
191 protected:
192 double _amount{};
193 double* _changeRate{}; // non-owning reference
194 bool _static{};
195 bool _needsWeighting{};
196 double _fractionUnitArea{1.0};
197 double _fractionLandCover{1.0};
198 double _fractionTotal{1.0};
199 Modifier* _modifier{};
200 ContentType _type{ContentType::Water};
201};
202
203#endif // HYDROBRICKS_FLUX_H
Definition Flux.h:9
bool HasChangeRate() const
Definition Flux.h:178
bool NeedsWeighting() const
Definition Flux.h:115
void LinkChangeRate(double *rate)
Definition Flux.h:54
virtual void Reset()
Definition Flux.cpp:16
virtual bool IsForcing() const
Definition Flux.h:81
virtual void UpdateFlux(double amount)
Definition Flux.cpp:20
virtual bool IsInstantaneous() const
Definition Flux.h:90
bool HasModifier() const
Definition Flux.h:187
double * GetChangeRatePointer()
Definition Flux.h:63
double * GetAmountPointer()
Definition Flux.h:72
void SetFractionLandCover(double value)
Definition Flux.h:143
ContentType GetType() const
Definition Flux.h:160
void SetType(const ContentType type)
Definition Flux.h:169
bool IsStatic() const
Definition Flux.h:106
void SetFractionUnitArea(double value)
Definition Flux.h:133
virtual bool IsValid() const =0
virtual void Validate() const
Definition Flux.cpp:28
void UpdateFractionTotal()
Definition Flux.h:151
void SetAsStatic()
Definition Flux.h:97
virtual double GetAmount()=0
void NeedsWeighting(bool value)
Definition Flux.h:124
Definition Modifier.h:6