hydrobricks
Loading...
Searching...
No Matches
WaterContainer.h
1#ifndef HYDROBRICKS_WATER_CONTAINER_H
2#define HYDROBRICKS_WATER_CONTAINER_H
3
4#include "Includes.h"
5#include "Process.h"
6
7class Brick;
8
9class WaterContainer : public wxObject {
10 public:
11 WaterContainer(Brick* brick);
12
13 virtual bool IsOk();
14
15 void SubtractAmountFromDynamicContentChange(double change);
16
17 void AddAmountToDynamicContentChange(double change);
18
19 void AddAmountToStaticContentChange(double change);
20
21 virtual void ApplyConstraints(double timeSte);
22
23 void SetOutgoingRatesToZero();
24
25 void Finalize();
26
27 void Reset();
28
29 void SaveAsInitialState();
30
31 vecDoublePt GetDynamicContentChanges();
32
33 bool HasMaximumCapacity() const {
34 return m_capacity != nullptr;
35 }
36
37 double GetMaximumCapacity() {
38 wxASSERT(m_capacity);
39 return *m_capacity;
40 }
41
42 void SetMaximumCapacity(float* value) {
43 if (m_infiniteStorage) {
44 throw ConceptionIssue(_("Trying to set the maximum capacity of an infinite storage."));
45 }
46
47 m_capacity = value;
48 }
49
50 void SetAsInfiniteStorage() {
51 m_infiniteStorage = true;
52 }
53
59 double GetContentWithChanges() const {
60 if (m_infiniteStorage) {
61 return INFINITY;
62 }
63
64 return m_content + m_contentChangeDynamic + m_contentChangeStatic;
65 }
66
67 double GetContentWithDynamicChanges() const {
68 if (m_infiniteStorage) {
69 return INFINITY;
70 }
71
72 return m_content + m_contentChangeDynamic;
73 }
74
75 double GetContentWithoutChanges() const {
76 if (m_infiniteStorage) {
77 return INFINITY;
78 }
79
80 return m_content;
81 }
82
83 double* GetContentPointer() {
84 return &m_content;
85 }
86
87 void UpdateContent(double value) {
88 if (m_infiniteStorage) {
89 throw ConceptionIssue(_("Trying to set the content of an infinite storage."));
90 }
91
92 m_content = value;
93 }
94
95 double GetTargetFillingRatio();
96
97 bool IsNotEmpty() {
98 double content = GetContentWithChanges();
99 return content > EPSILON_F && content > PRECISION;
100 }
101
102 bool HasOverflow() {
103 return m_overflow != nullptr;
104 }
105
106 void LinkOverflow(Process* overflow) {
107 m_overflow = overflow;
108 }
109
115 void AttachFluxIn(Flux* flux) {
116 wxASSERT(flux);
117 m_inputs.push_back(flux);
118 }
119
125 virtual double SumIncomingFluxes();
126
127 virtual bool ContentAccessible() const;
128
129 Brick* GetParentBrick() {
130 return m_parent;
131 }
132
133 protected:
134 private:
135 double m_content; // [mm]
136 double m_contentChangeDynamic; // [mm]
137 double m_contentChangeStatic; // [mm]
138 double m_initialState; // [mm]
139 float* m_capacity;
140 bool m_infiniteStorage;
141 Brick* m_parent;
142 Process* m_overflow;
143 vector<Flux*> m_inputs;
144};
145
146#endif // HYDROBRICKS_WATER_CONTAINER_H
Definition Brick.h:10
Definition Includes.h:133
Definition Flux.h:8
Definition Process.h:13
Definition WaterContainer.h:9
void AttachFluxIn(Flux *flux)
Definition WaterContainer.h:115
double GetContentWithChanges() const
Definition WaterContainer.h:59
virtual double SumIncomingFluxes()
Definition WaterContainer.cpp:190