GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 75.0% 78 / 0 / 104
Functions: 78.6% 22 / 0 / 28
Branches: 59.5% 66 / 0 / 111

src/model/SurfaceControlMovableInsulation.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 "SurfaceControlMovableInsulation.hpp"
7 #include "SurfaceControlMovableInsulation_Impl.hpp"
8
9 #include "Model.hpp"
10 #include "Model_Impl.hpp"
11 #include "Surface.hpp"
12 #include "Surface_Impl.hpp"
13 #include "Material.hpp"
14 #include "Material_Impl.hpp"
15 #include "Schedule.hpp"
16 #include "Schedule_Impl.hpp"
17
18 #include <utilities/idd/IddFactory.hxx>
19 #include <utilities/idd/IddEnums.hxx>
20 #include <utilities/idd/OS_SurfaceControl_MovableInsulation_FieldEnums.hxx>
21
22 #include "../utilities/units/Unit.hpp"
23
24 #include "../utilities/core/Assert.hpp"
25
26 namespace openstudio {
27 namespace model {
28
29 namespace detail {
30
31 7 SurfaceControlMovableInsulation_Impl::SurfaceControlMovableInsulation_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
32 7 : ModelObject_Impl(idfObject, model, keepHandle) {
33
4/6
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 7 times.
✗ Branch 13 not taken.
7 OS_ASSERT(idfObject.iddObject().type() == SurfaceControlMovableInsulation::iddObjectType());
34 7 }
35
36 ✗ SurfaceControlMovableInsulation_Impl::SurfaceControlMovableInsulation_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
37 ✗ Model_Impl* model, bool keepHandle)
38 ✗ : ModelObject_Impl(other, model, keepHandle) {
39 ✗ OS_ASSERT(other.iddObject().type() == SurfaceControlMovableInsulation::iddObjectType());
40 ✗ }
41
42 5 SurfaceControlMovableInsulation_Impl::SurfaceControlMovableInsulation_Impl(const SurfaceControlMovableInsulation_Impl& other, Model_Impl* model,
43 5 bool keepHandle)
44 5 : ModelObject_Impl(other, model, keepHandle) {}
45
46 2 ModelObject SurfaceControlMovableInsulation_Impl::clone(Model model) const {
47
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 ModelObject result = ModelObject_Impl::clone(model);
48
49
1/1
✓ Branch 1 taken 2 times.
2 Model m = this->model();
50
3/3
✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 time.
✓ Branch 4 taken 1 time.
2 if (model == m) {
51 // cloned into same model, erase reference to parent
52 // this object is now invalid but having two objects point to same surface would also be invalid
53
2/2
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
2 result.setString(OS_SurfaceControl_MovableInsulationFields::SurfaceName, "");
54
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 LOG(Warn, "Cloning the SurfaceControlMoveableInsulation resets the Surface attached to it while it is a required field. "
55 "You should call `setSurface(Surface&)` on the clone");
56 }
57
58 4 return result;
59 2 }
60
61 ✗ const std::vector<std::string>& SurfaceControlMovableInsulation_Impl::outputVariableNames() const {
62 ✗ static std::vector<std::string> result;
63 ✗ return result;
64 }
65
66 ✗ IddObjectType SurfaceControlMovableInsulation_Impl::iddObjectType() const {
67 ✗ return SurfaceControlMovableInsulation::iddObjectType();
68 }
69
70 ✗ std::vector<ScheduleTypeKey> SurfaceControlMovableInsulation_Impl::getScheduleTypeKeys(const Schedule& schedule) const {
71 ✗ std::vector<ScheduleTypeKey> result;
72 ✗ UnsignedVector fieldIndices = getSourceIndices(schedule.handle());
73 ✗ UnsignedVector::const_iterator b(fieldIndices.begin());
74 ✗ UnsignedVector::const_iterator e(fieldIndices.end());
75 ✗ if (std::find(b, e, OS_SurfaceControl_MovableInsulationFields::ScheduleName) != e) {
76 ✗ result.push_back(ScheduleTypeKey("SurfaceControlMovableInsulation", "Resistance Modifier Fraction"));
77 }
78 ✗ return result;
79 ✗ }
80
81 10 std::string SurfaceControlMovableInsulation_Impl::insulationType() const {
82
1/1
✓ Branch 1 taken 10 times.
10 boost::optional<std::string> insulationType = getString(OS_SurfaceControl_MovableInsulationFields::InsulationType, true, true);
83
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 4 not taken.
10 OS_ASSERT(insulationType);
84
2/2
✓ Branch 1 taken 10 times.
✓ Branch 4 taken 10 times.
20 return insulationType.get();
85 10 }
86
87 4 Surface SurfaceControlMovableInsulation_Impl::surface() const {
88 boost::optional<Surface> surface =
89
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 getObject<ModelObject>().getModelObjectTarget<Surface>(OS_SurfaceControl_MovableInsulationFields::SurfaceName);
90
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(surface);
91
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return surface.get();
92 4 }
93
94 4 Material SurfaceControlMovableInsulation_Impl::material() const {
95 boost::optional<Material> material =
96
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 getObject<ModelObject>().getModelObjectTarget<Material>(OS_SurfaceControl_MovableInsulationFields::MaterialName);
97
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 4 not taken.
4 OS_ASSERT(material);
98
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
8 return material.get();
99 4 }
100
101 8 Schedule SurfaceControlMovableInsulation_Impl::schedule() const {
102 boost::optional<Schedule> schedule =
103
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_SurfaceControl_MovableInsulationFields::ScheduleName);
104
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 4 not taken.
8 OS_ASSERT(schedule);
105
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
16 return schedule.get();
106 8 }
107
108 14 bool SurfaceControlMovableInsulation_Impl::setInsulationType(const std::string& insulationType) {
109 14 bool result = setString(OS_SurfaceControl_MovableInsulationFields::InsulationType, insulationType);
110 14 return result;
111 }
112
113 7 bool SurfaceControlMovableInsulation_Impl::setSurface(const Surface& surface) {
114
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<SurfaceControlMovableInsulation> currentIns = surface.surfaceControlMovableInsulation();
115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if (currentIns) {
116 ✗ if (currentIns->handle() == this->handle()) {
117 ✗ return true;
118 }
119 ✗ currentIns->remove();
120 }
121
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return setPointer(OS_SurfaceControl_MovableInsulationFields::SurfaceName, surface.handle());
122 7 }
123
124 9 bool SurfaceControlMovableInsulation_Impl::setMaterial(const Material& material) {
125
2/2
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
9 return setPointer(OS_SurfaceControl_MovableInsulationFields::MaterialName, material.handle());
126 }
127
128 11 bool SurfaceControlMovableInsulation_Impl::setSchedule(Schedule& schedule) {
129
3/3
✓ Branch 1 taken 11 times.
✓ Branch 4 taken 11 times.
✓ Branch 7 taken 11 times.
44 bool result = ModelObject_Impl::setSchedule(OS_SurfaceControl_MovableInsulationFields::ScheduleName, "SurfaceControlMovableInsulation",
130 "Resistance Modifier Fraction", schedule);
131 11 return result;
132 }
133
134 } // namespace detail
135
136 7 SurfaceControlMovableInsulation::SurfaceControlMovableInsulation(const Surface& surface, const Material& material)
137
3/3
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
7 : ModelObject(SurfaceControlMovableInsulation::iddObjectType(), surface.model()) {
138
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 5 not taken.
7 OS_ASSERT(getImpl<detail::SurfaceControlMovableInsulation_Impl>());
139
140
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 setInsulationType("Outside");
141
142
1/1
✓ Branch 1 taken 7 times.
7 setSurface(surface);
143
144
1/1
✓ Branch 1 taken 7 times.
7 setMaterial(material);
145
146 {
147
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 auto schedule = surface.model().alwaysOnContinuousSchedule();
148
1/1
✓ Branch 1 taken 7 times.
7 setSchedule(schedule);
149 7 }
150 7 }
151
152 11045 IddObjectType SurfaceControlMovableInsulation::iddObjectType() {
153
1/1
✓ Branch 1 taken 11045 times.
11045 return {IddObjectType::OS_SurfaceControl_MovableInsulation};
154 }
155
156 ✗ std::vector<std::string> SurfaceControlMovableInsulation::insulationTypeValues() {
157 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_SurfaceControl_MovableInsulationFields::InsulationType);
158 }
159
160 ✗ std::vector<std::string> SurfaceControlMovableInsulation::validInsulationTypeValues() {
161 ✗ return SurfaceControlMovableInsulation::insulationTypeValues();
162 }
163
164 10 std::string SurfaceControlMovableInsulation::insulationType() const {
165
1/1
✓ Branch 3 taken 10 times.
10 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->insulationType();
166 }
167
168 4 Surface SurfaceControlMovableInsulation::surface() const {
169
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->surface();
170 }
171
172 4 Material SurfaceControlMovableInsulation::material() const {
173
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->material();
174 }
175
176 8 Schedule SurfaceControlMovableInsulation::schedule() const {
177
1/1
✓ Branch 3 taken 8 times.
8 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->schedule();
178 }
179
180 14 bool SurfaceControlMovableInsulation::setInsulationType(const std::string& insulationType) {
181
1/1
✓ Branch 3 taken 14 times.
14 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->setInsulationType(insulationType);
182 }
183
184 7 bool SurfaceControlMovableInsulation::setSurface(const Surface& surface) {
185
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->setSurface(surface);
186 }
187
188 9 bool SurfaceControlMovableInsulation::setMaterial(const Material& material) {
189
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->setMaterial(material);
190 }
191
192 11 bool SurfaceControlMovableInsulation::setSchedule(Schedule& schedule) {
193
1/1
✓ Branch 3 taken 11 times.
11 return getImpl<detail::SurfaceControlMovableInsulation_Impl>()->setSchedule(schedule);
194 }
195
196 /// @cond
197 10 SurfaceControlMovableInsulation::SurfaceControlMovableInsulation(std::shared_ptr<detail::SurfaceControlMovableInsulation_Impl> impl)
198
1/1
✓ Branch 3 taken 10 times.
10 : ModelObject(std::move(impl)) {}
199 /// @endcond
200
201 } // namespace model
202 } // namespace openstudio
203