GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 88.4% 114 / 0 / 129
Functions: 88.0% 44 / 0 / 50
Branches: 80.0% 84 / 0 / 105

src/model/BuildingUnit.cpp
Line Branch Exec Source
1 /***********************************************************************************************************************
2 * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC.
3 * See also https://openstudio.net/license
4 ***********************************************************************************************************************/
5
6 #include <string>
7 #include <memory>
8
9 #include "BuildingUnit.hpp"
10 #include "BuildingUnit_Impl.hpp"
11
12 #include "Model.hpp"
13 #include "Model_Impl.hpp"
14 #include "Space.hpp"
15 #include "Space_Impl.hpp"
16 #include "RenderingColor.hpp"
17 #include "RenderingColor_Impl.hpp"
18 #include "AdditionalProperties.hpp"
19 #include "ModelExtensibleGroup.hpp"
20
21 #include <utilities/idd/OS_BuildingUnit_FieldEnums.hxx>
22 #include <utilities/idd/IddEnums.hxx>
23 #include <utilities/idd/IddFactory.hxx>
24
25 namespace openstudio {
26 namespace model {
27 namespace detail {
28
29 30 BuildingUnit_Impl::BuildingUnit_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
30 30 : ModelObject_Impl(idfObject, model, keepHandle) {
31
4/6
✓ Branch 1 taken 30 times.
✓ Branch 4 taken 30 times.
✓ Branch 7 taken 30 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 30 times.
✗ Branch 13 not taken.
30 OS_ASSERT(idfObject.iddObject().type() == BuildingUnit::iddObjectType());
32 30 }
33
34 ✗ BuildingUnit_Impl::BuildingUnit_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
35 ✗ : ModelObject_Impl(other, model, keepHandle) {
36 ✗ OS_ASSERT(other.iddObject().type() == BuildingUnit::iddObjectType());
37 ✗ }
38
39 ✗ BuildingUnit_Impl::BuildingUnit_Impl(const BuildingUnit_Impl& other, Model_Impl* model, bool keepHandle)
40 ✗ : ModelObject_Impl(other, model, keepHandle) {}
41
42 ✗ const std::vector<std::string>& BuildingUnit_Impl::outputVariableNames() const {
43 ✗ static const std::vector<std::string> result;
44 ✗ return result;
45 }
46
47 ✗ IddObjectType BuildingUnit_Impl::iddObjectType() const {
48 ✗ return BuildingUnit::iddObjectType();
49 }
50
51 13 boost::optional<RenderingColor> BuildingUnit_Impl::renderingColor() const {
52
2/2
✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
13 return getObject<ModelObject>().getModelObjectTarget<RenderingColor>(OS_BuildingUnitFields::RenderingColor);
53 }
54
55 5 bool BuildingUnit_Impl::setRenderingColor(const RenderingColor& renderingColor) {
56
2/2
✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
5 return setPointer(OS_BuildingUnitFields::RenderingColor, renderingColor.handle());
57 }
58
59 1 void BuildingUnit_Impl::resetRenderingColor() {
60
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool ok = setString(OS_BuildingUnitFields::RenderingColor, "");
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(ok);
62 1 }
63
64 4 std::string BuildingUnit_Impl::buildingUnitType() const {
65
1/1
✓ Branch 1 taken 4 times.
4 boost::optional<std::string> retval = getString(OS_BuildingUnitFields::BuildingUnitType, true, true);
66
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(retval);
67
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return *retval;
68 4 }
69
70 3 bool BuildingUnit_Impl::setBuildingUnitType(const std::string& buildingUnitType) {
71 3 bool ok = setString(OS_BuildingUnitFields::BuildingUnitType, buildingUnitType);
72 3 return ok;
73 }
74
75 1 void BuildingUnit_Impl::resetBuildingUnitType() {
76
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 bool ok = setString(OS_BuildingUnitFields::BuildingUnitType, "");
77
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 OS_ASSERT(ok);
78 1 }
79
80 3 std::vector<Space> BuildingUnit_Impl::spaces() const {
81
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 return getObject<ModelObject>().getModelObjectSources<Space>(Space::iddObjectType());
82 }
83
84 1 std::vector<std::string> BuildingUnit_Impl::featureNames() const {
85
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return this->additionalProperties().featureNames();
86 }
87
88 7 boost::optional<std::string> BuildingUnit_Impl::getFeatureDataType(const std::string& name) const {
89
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return this->additionalProperties().getFeatureDataType(name);
90 }
91
92 2 boost::optional<std::string> BuildingUnit_Impl::getFeatureAsString(const std::string& name) const {
93
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().getFeatureAsString(name);
94 }
95
96 2 boost::optional<double> BuildingUnit_Impl::getFeatureAsDouble(const std::string& name) const {
97
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().getFeatureAsDouble(name);
98 }
99
100 2 boost::optional<int> BuildingUnit_Impl::getFeatureAsInteger(const std::string& name) const {
101
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().getFeatureAsInteger(name);
102 }
103
104 2 boost::optional<bool> BuildingUnit_Impl::getFeatureAsBoolean(const std::string& name) const {
105
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().getFeatureAsBoolean(name);
106 }
107
108 1 std::vector<std::string> BuildingUnit_Impl::suggestedFeatures() const {
109 1 std::set<std::string> availableFeatureNames;
110
4/4
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 1 time.
4 for (const auto& v : this->additionalProperties().suggestedFeatureNames()) {
111
1/1
✓ Branch 1 taken 3 times.
3 availableFeatureNames.insert(v);
112 1 }
113
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 availableFeatureNames.insert("NumberOfBedrooms");
114
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 availableFeatureNames.insert("NumberOfBathrooms");
115
116 1 std::vector<std::string> retvals;
117
1/1
✓ Branch 3 taken 1 time.
1 retvals.assign(availableFeatureNames.begin(), availableFeatureNames.end());
118 2 return retvals;
119 1 }
120
121 ✗ bool BuildingUnit_Impl::setFeature(const std::string& name, const std::string& value) {
122 ✗ return this->additionalProperties().setFeature(name, value);
123 }
124
125 2 bool BuildingUnit_Impl::setFeature(const std::string& name, const char* value) {
126
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().setFeature(name, value);
127 }
128
129 1 bool BuildingUnit_Impl::setFeature(const std::string& name, double value) {
130
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
1 return this->additionalProperties().setFeature(name, value);
131 }
132
133 2 bool BuildingUnit_Impl::setFeature(const std::string& name, int value) {
134
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().setFeature(name, value);
135 }
136
137 2 bool BuildingUnit_Impl::setFeature(const std::string& name, bool value) {
138
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().setFeature(name, value);
139 }
140
141 2 bool BuildingUnit_Impl::resetFeature(const std::string& name) {
142
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return this->additionalProperties().resetFeature(name);
143 }
144
145 } // namespace detail
146
147 30 BuildingUnit::BuildingUnit(const Model& model) : ModelObject(BuildingUnit::iddObjectType(), model) {
148
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 5 not taken.
30 OS_ASSERT(getImpl<detail::BuildingUnit_Impl>());
149 30 }
150
151 7953 IddObjectType BuildingUnit::iddObjectType() {
152
1/1
✓ Branch 1 taken 7953 times.
7953 IddObjectType result(IddObjectType::OS_BuildingUnit);
153 7953 return result;
154 }
155
156 13 boost::optional<RenderingColor> BuildingUnit::renderingColor() const {
157
1/1
✓ Branch 3 taken 13 times.
13 return getImpl<detail::BuildingUnit_Impl>()->renderingColor();
158 }
159
160 5 bool BuildingUnit::setRenderingColor(const RenderingColor& renderingColor) {
161
1/1
✓ Branch 3 taken 5 times.
5 return getImpl<detail::BuildingUnit_Impl>()->setRenderingColor(renderingColor);
162 }
163
164 1 void BuildingUnit::resetRenderingColor() {
165
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::BuildingUnit_Impl>()->resetRenderingColor();
166 1 }
167
168 1 std::vector<std::string> BuildingUnit::buildingUnitTypeValues() {
169
5/5
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
1 return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_BuildingUnitFields::BuildingUnitType);
170 }
171
172 4 std::string BuildingUnit::buildingUnitType() const {
173
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::BuildingUnit_Impl>()->buildingUnitType();
174 }
175
176 3 bool BuildingUnit::setBuildingUnitType(const std::string& buildingUnitType) {
177
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::BuildingUnit_Impl>()->setBuildingUnitType(buildingUnitType);
178 }
179
180 1 void BuildingUnit::resetBuildingUnitType() {
181
1/1
✓ Branch 3 taken 1 time.
1 getImpl<detail::BuildingUnit_Impl>()->resetBuildingUnitType();
182 1 }
183
184 3 std::vector<Space> BuildingUnit::spaces() const {
185
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::BuildingUnit_Impl>()->spaces();
186 }
187
188 1 std::vector<std::string> BuildingUnit::featureNames() const {
189
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::BuildingUnit_Impl>()->featureNames();
190 }
191
192 7 boost::optional<std::string> BuildingUnit::getFeatureDataType(const std::string& name) const {
193
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::BuildingUnit_Impl>()->getFeatureDataType(name);
194 }
195
196 2 boost::optional<std::string> BuildingUnit::getFeatureAsString(const std::string& name) const {
197
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->getFeatureAsString(name);
198 }
199
200 2 boost::optional<double> BuildingUnit::getFeatureAsDouble(const std::string& name) const {
201
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->getFeatureAsDouble(name);
202 }
203
204 2 boost::optional<int> BuildingUnit::getFeatureAsInteger(const std::string& name) const {
205
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->getFeatureAsInteger(name);
206 }
207
208 2 boost::optional<bool> BuildingUnit::getFeatureAsBoolean(const std::string& name) const {
209
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->getFeatureAsBoolean(name);
210 }
211
212 1 std::vector<std::string> BuildingUnit::suggestedFeatures() const {
213
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::BuildingUnit_Impl>()->suggestedFeatures();
214 }
215
216 1 double BuildingUnit::floorArea() const {
217 1 double totalFloorArea(0.0);
218
3/3
✓ Branch 1 taken 1 time.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 1 time.
3 for (const auto& space : this->spaces()) {
219
1/1
✓ Branch 1 taken 2 times.
2 totalFloorArea += space.floorArea();
220 1 }
221 1 return totalFloorArea;
222 }
223
224 ✗ bool BuildingUnit::setFeature(const std::string& name, const std::string& value) {
225 ✗ return getImpl<detail::BuildingUnit_Impl>()->setFeature(name, value);
226 }
227
228 2 bool BuildingUnit::setFeature(const std::string& name, const char* value) {
229
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->setFeature(name, value);
230 }
231
232 1 bool BuildingUnit::setFeature(const std::string& name, double value) {
233
1/1
✓ Branch 3 taken 1 time.
1 return getImpl<detail::BuildingUnit_Impl>()->setFeature(name, value);
234 }
235
236 2 bool BuildingUnit::setFeature(const std::string& name, int value) {
237
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->setFeature(name, value);
238 }
239
240 2 bool BuildingUnit::setFeature(const std::string& name, bool value) {
241
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->setFeature(name, value);
242 }
243
244 2 bool BuildingUnit::resetFeature(const std::string& name) {
245
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::BuildingUnit_Impl>()->resetFeature(name);
246 }
247
248 /// @cond
249
1/1
✓ Branch 3 taken 390 times.
390 BuildingUnit::BuildingUnit(std::shared_ptr<detail::BuildingUnit_Impl> impl) : ModelObject(std::move(impl)) {}
250 /// @endcond
251
252 } // namespace model
253 } // namespace openstudio
254