CivBaseInpBuilder.cpp 3.36 KB
Newer Older
刘乐's avatar
刘乐 committed
1 2 3
#include "CivBaseInpBuilder.h"

#include "CivInpBuilder.h"
刘乐's avatar
刘乐 committed
4
#include "CivTypes.h"
刘乐's avatar
刘乐 committed
5
#include "CivAssembly.h"
刘乐's avatar
刘乐 committed
6
#include "CivInpDbHelper.h"
刘乐's avatar
刘乐 committed
7

刘乐's avatar
刘乐 committed
8

刘乐's avatar
刘乐 committed
9 10
CivBaseInpBuilder::CivBaseInpBuilder(const std::string & uri)
	:CivInpBuilder(uri)
刘乐's avatar
刘乐 committed
11
{
刘乐's avatar
刘乐 committed
12
	mHelper = new CivInpDbHelper(uri);
刘乐's avatar
刘乐 committed
13 14
}

刘乐's avatar
刘乐 committed
15
CivBaseInpBuilder::~CivBaseInpBuilder()
刘乐's avatar
刘乐 committed
16
{
刘乐's avatar
刘乐 committed
17
	delete mHelper;
刘乐's avatar
刘乐 committed
18 19
}

刘乐's avatar
刘乐 committed
20 21 22 23 24 25
void CivBaseInpBuilder::preHandleLikelyPipe()
{
	mHelper->handleValve();
	mHelper->handlePump();
}

刘乐's avatar
刘乐 committed
26
void CivBaseInpBuilder::buildNode()
刘乐's avatar
刘乐 committed
27
{
28
	CivNode node;
刘乐's avatar
刘乐 committed
29
	if (!mHelper->getNode(node))
30 31 32
		return;

	mNewInp->setNode(node);
刘乐's avatar
刘乐 committed
33 34
}

刘乐's avatar
刘乐 committed
35
void CivBaseInpBuilder::buildPipe()
刘乐's avatar
刘乐 committed
36
{
刘乐's avatar
刘乐 committed
37
	ASSERT(mHelper, mNewInp);
38

刘乐's avatar
刘乐 committed
39 40
	CivPipe pipe;
	if (!mHelper->getPipe(pipe))
41
		return;
刘乐's avatar
刘乐 committed
42

43
	mNewInp->setPipes(pipe);
刘乐's avatar
刘乐 committed
44 45
}

刘乐's avatar
刘乐 committed
46
void CivBaseInpBuilder::buildTank()
刘乐's avatar
刘乐 committed
47
{
刘乐's avatar
刘乐 committed
48
	ASSERT(mHelper, mNewInp);
刘乐's avatar
刘乐 committed
49

刘乐's avatar
刘乐 committed
50 51
	CivTank tank;
	if (!mHelper->getTank(tank))
52 53 54
		return;

	mNewInp->setTank(tank);
刘乐's avatar
刘乐 committed
55 56
}

刘乐's avatar
刘乐 committed
57
void CivBaseInpBuilder::buildVavle()
刘乐's avatar
刘乐 committed
58
{
刘乐's avatar
刘乐 committed
59
	ASSERT(mHelper, mNewInp);
60

刘乐's avatar
刘乐 committed
61 62
	CivValve valve;
	if (!mHelper->getValve(valve))
63
		return;
刘乐's avatar
刘乐 committed
64

65
	mNewInp->setValves(valve);
刘乐's avatar
刘乐 committed
66
}
刘乐's avatar
刘乐 committed
67

刘乐's avatar
刘乐 committed
68
void CivBaseInpBuilder::buildPump()
刘乐's avatar
刘乐 committed
69
{
刘乐's avatar
刘乐 committed
70
	ASSERT(mHelper, mNewInp);
71

刘乐's avatar
刘乐 committed
72 73
	CivPumps valve;
	if (!mHelper->getPumps(valve))
74
		return;
刘乐's avatar
刘乐 committed
75

76
	mNewInp->setPumps(valve);
刘乐's avatar
刘乐 committed
77 78
}

刘乐's avatar
刘乐 committed
79
void CivBaseInpBuilder::buildReservoir()
刘乐's avatar
刘乐 committed
80
{
刘乐's avatar
刘乐 committed
81
	ASSERT(mHelper, mNewInp);
刘乐's avatar
刘乐 committed
82

刘乐's avatar
刘乐 committed
83 84
	CivReservoirs res;
	if (!mHelper->getReservoirs(res))
85 86 87
		return;

	mNewInp->setReservoirs(res);
刘乐's avatar
刘乐 committed
88 89
}

刘乐's avatar
刘乐 committed
90
void CivBaseInpBuilder::buildEmitter()
刘乐's avatar
刘乐 committed
91
{
刘乐's avatar
刘乐 committed
92
	ASSERT(mHelper, mNewInp);
93

刘乐's avatar
刘乐 committed
94
		CivEmitters emmiters;
刘乐's avatar
刘乐 committed
95
	if (!mHelper->getEmitters(emmiters))
96
		return;
刘乐's avatar
刘乐 committed
97

98
	mNewInp->setEmitters(emmiters);
刘乐's avatar
刘乐 committed
99 100
}

刘乐's avatar
刘乐 committed
101
void CivBaseInpBuilder::buildPatterns()
刘乐's avatar
刘乐 committed
102
{
刘乐's avatar
刘乐 committed
103
	ASSERT(mHelper, mNewInp);
104

刘乐's avatar
刘乐 committed
105 106
	CivPatterns pattern;
	if (!mHelper->getPatterns(pattern))
107
		return;
刘乐's avatar
刘乐 committed
108

109
	mNewInp->setPatterns(pattern);
刘乐's avatar
刘乐 committed
110 111
}

刘乐's avatar
刘乐 committed
112
void CivBaseInpBuilder::buildCoordnates()
刘乐's avatar
刘乐 committed
113
{
刘乐's avatar
刘乐 committed
114
	ASSERT(mHelper, mNewInp);
115

刘乐's avatar
刘乐 committed
116 117
	CivCoordinates coords;
	if (!mHelper->getCoordinates(coords))
118
		return;
刘乐's avatar
刘乐 committed
119

120
	mNewInp->setCoordnates(coords);
刘乐's avatar
刘乐 committed
121 122
}

刘乐's avatar
刘乐 committed
123
void CivBaseInpBuilder::buildVertices()
刘乐's avatar
刘乐 committed
124
{
125
	return;
刘乐's avatar
刘乐 committed
126 127
}

刘乐's avatar
刘乐 committed
128
void CivBaseInpBuilder::buildLabels()
刘乐's avatar
刘乐 committed
129
{
刘乐's avatar
刘乐 committed
130
	ASSERT(mHelper, mNewInp);
131

刘乐's avatar
刘乐 committed
132 133
	CivLabels labels;
	if (!mHelper->getLabels(labels))
134
		return;
刘乐's avatar
刘乐 committed
135

136
	mNewInp->setLabels(labels);
刘乐's avatar
刘乐 committed
137 138
}

刘乐's avatar
刘乐 committed
139
void CivBaseInpBuilder::buildTags()
刘乐's avatar
刘乐 committed
140
{
刘乐's avatar
刘乐 committed
141
	ASSERT(mHelper, mNewInp);
刘乐's avatar
刘乐 committed
142

刘乐's avatar
刘乐 committed
143 144
	CivTags tag;
	if (!mHelper->getTags(tag))
145 146 147
		return;

	mNewInp->setTags(tag);
刘乐's avatar
刘乐 committed
148 149
}

刘乐's avatar
刘乐 committed
150
void CivBaseInpBuilder::buildBackDrop()
刘乐's avatar
刘乐 committed
151
{
152
	return;
刘乐's avatar
刘乐 committed
153 154
}

刘乐's avatar
刘乐 committed
155
void CivBaseInpBuilder::buildQuality()
刘乐's avatar
刘乐 committed
156
{
刘乐's avatar
刘乐 committed
157
	ASSERT(mHelper, mNewInp);
158

刘乐's avatar
刘乐 committed
159 160 161
	if (mResetToZero)
	{
		mNewInp->setQuality(mInitQuality);
162
		return;
刘乐's avatar
刘乐 committed
163
	}
刘乐's avatar
刘乐 committed
164

刘乐's avatar
刘乐 committed
165
	CivQuality quality;
刘乐's avatar
刘乐 committed
166
	if (!mHelper->getQuality(quality))
刘乐's avatar
刘乐 committed
167 168
		return;
	
169
	mNewInp->setQuality(quality);
刘乐's avatar
刘乐 committed
170 171
}

刘乐's avatar
刘乐 committed
172
void CivBaseInpBuilder::buildSources()
刘乐's avatar
刘乐 committed
173
{
刘乐's avatar
刘乐 committed
174
	ASSERT(mHelper, mNewInp);
175

刘乐's avatar
刘乐 committed
176 177
	CivSources sources;
	if (!mHelper->getSources(sources))
178
		return;
刘乐's avatar
刘乐 committed
179

180
	mNewInp->setSources(sources);
刘乐's avatar
刘乐 committed
181 182
}

刘乐's avatar
刘乐 committed
183
void CivBaseInpBuilder::buildMixing()
刘乐's avatar
刘乐 committed
184
{
刘乐's avatar
刘乐 committed
185
	ASSERT(mHelper, mNewInp);
刘乐's avatar
刘乐 committed
186

刘乐's avatar
刘乐 committed
187 188
	CivMixing mixing;
	if (!mHelper->getMixing(mixing))
189 190 191
		return;

	mNewInp->setMixing(mixing);
刘乐's avatar
刘乐 committed
192 193
}

刘乐's avatar
刘乐 committed
194
void CivBaseInpBuilder::buildCurves()
刘乐's avatar
刘乐 committed
195
{
刘乐's avatar
刘乐 committed
196
	ASSERT(mHelper, mNewInp);
197

刘乐's avatar
刘乐 committed
198 199 200
	CivCurves curves;
	if (!mHelper->getCurves(curves))
		return;
刘乐's avatar
刘乐 committed
201

刘乐's avatar
刘乐 committed
202
	mNewInp->setCurves(curves);
刘乐's avatar
刘乐 committed
203 204
}

刘乐's avatar
刘乐 committed
205
void CivBaseInpBuilder::buildStatus()
刘乐's avatar
刘乐 committed
206
{
刘乐's avatar
刘乐 committed
207
	ASSERT(mHelper, mNewInp);
208

刘乐's avatar
刘乐 committed
209 210
	CivStatus status;
	if (!mHelper->getStatus(status))
211
		return;
刘乐's avatar
刘乐 committed
212

213
	mNewInp->setStatus(status);
刘乐's avatar
刘乐 committed
214 215
}

刘乐's avatar
刘乐 committed
216
void CivBaseInpBuilder::buildControls()
刘乐's avatar
刘乐 committed
217 218 219 220
{

}

刘乐's avatar
刘乐 committed
221
void CivBaseInpBuilder::buildRules()
刘乐's avatar
刘乐 committed
222
{
刘乐's avatar
刘乐 committed
223

刘乐's avatar
刘乐 committed
224 225
}

刘乐's avatar
刘乐 committed
226
void CivBaseInpBuilder::buildDemands()
刘乐's avatar
刘乐 committed
227
{
刘乐's avatar
刘乐 committed
228
	ASSERT(mHelper, mNewInp);
229

刘乐's avatar
刘乐 committed
230 231
	CivDemands mand;
	if (!mHelper->getDemands(mand))
232
		return;
刘乐's avatar
刘乐 committed
233

234
	mNewInp->setDemands(mand);
刘乐's avatar
刘乐 committed
235
}