GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 73.4% 69 / 0 / 94
Functions: 75.9% 22 / 0 / 29
Branches: 35.9% 46 / 0 / 128

src/model/AirflowNetworkDistributionLinkage.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 "AirflowNetworkDistributionLinkage.hpp"
7 #include "AirflowNetworkDistributionLinkage_Impl.hpp"
8 #include "AirflowNetworkDistributionNode.hpp"
9 #include "AirflowNetworkDistributionNode_Impl.hpp"
10
11 // TODO: Check the following class names against object getters and setters.
12 #include "AirflowNetworkNode.hpp"
13 #include "AirflowNetworkNode_Impl.hpp"
14 #include "AirflowNetworkComponent.hpp"
15 #include "AirflowNetworkComponent_Impl.hpp"
16 #include "AirflowNetworkFan.hpp"
17 #include "AirflowNetworkFan_Impl.hpp"
18 #include "ThermalZone.hpp"
19 #include "ThermalZone_Impl.hpp"
20
21 #include <utilities/idd/IddEnums.hxx>
22 #include <utilities/idd/OS_AirflowNetworkDistributionLinkage_FieldEnums.hxx>
23
24 #include "../utilities/core/Assert.hpp"
25
26 namespace openstudio {
27 namespace model {
28
29 namespace detail {
30
31 4 AirflowNetworkDistributionLinkage_Impl::AirflowNetworkDistributionLinkage_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
32 4 : AirflowNetworkLinkage_Impl(idfObject, model, keepHandle) {
33
4/6
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 4 times.
✗ Branch 13 not taken.
4 OS_ASSERT(idfObject.iddObject().type() == AirflowNetworkDistributionLinkage::iddObjectType());
34 4 }
35
36 ✗ AirflowNetworkDistributionLinkage_Impl::AirflowNetworkDistributionLinkage_Impl(const openstudio::detail::WorkspaceObject_Impl& other,
37 ✗ Model_Impl* model, bool keepHandle)
38 ✗ : AirflowNetworkLinkage_Impl(other, model, keepHandle) {
39 ✗ OS_ASSERT(other.iddObject().type() == AirflowNetworkDistributionLinkage::iddObjectType());
40 ✗ }
41
42 2 AirflowNetworkDistributionLinkage_Impl::AirflowNetworkDistributionLinkage_Impl(const AirflowNetworkDistributionLinkage_Impl& other,
43 2 Model_Impl* model, bool keepHandle)
44 2 : AirflowNetworkLinkage_Impl(other, model, keepHandle) {}
45
46 ✗ const std::vector<std::string>& AirflowNetworkDistributionLinkage_Impl::outputVariableNames() const {
47 ✗ static const std::vector<std::string> result;
48 ✗ return result;
49 }
50
51 ✗ IddObjectType AirflowNetworkDistributionLinkage_Impl::iddObjectType() const {
52 ✗ return AirflowNetworkDistributionLinkage::iddObjectType();
53 }
54
55 3 AirflowNetworkNode AirflowNetworkDistributionLinkage_Impl::node1() const {
56
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<AirflowNetworkNode> value = optionalNode1();
57
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (!value) {
58 ✗ LOG_AND_THROW(briefDescription() << " does not have an Node1 attached.");
59 }
60
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 return value.get();
61 3 }
62
63 3 AirflowNetworkNode AirflowNetworkDistributionLinkage_Impl::node2() const {
64
1/1
✓ Branch 1 taken 3 times.
3 boost::optional<AirflowNetworkNode> value = optionalNode2();
65
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
3 if (!value) {
66 ✗ LOG_AND_THROW(briefDescription() << " does not have an Node2 attached.");
67 }
68
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
6 return value.get();
69 3 }
70
71 7 AirflowNetworkComponent AirflowNetworkDistributionLinkage_Impl::component() const {
72
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<AirflowNetworkComponent> value = optionalComponent();
73
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
7 if (!value) {
74 ✗ LOG_AND_THROW(briefDescription() << " does not have an Component attached.");
75 }
76
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 return value.get();
77 7 }
78
79 2 boost::optional<ThermalZone> AirflowNetworkDistributionLinkage_Impl::thermalZone() const {
80
2/2
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
2 return getObject<ModelObject>().getModelObjectTarget<ThermalZone>(OS_AirflowNetworkDistributionLinkageFields::ThermalZoneName);
81 }
82
83 ✗ bool AirflowNetworkDistributionLinkage_Impl::setThermalZone(const ThermalZone& zone) {
84 ✗ bool result = setPointer(OS_AirflowNetworkDistributionLinkageFields::ThermalZoneName, zone.handle());
85 ✗ return result;
86 }
87
88 ✗ void AirflowNetworkDistributionLinkage_Impl::resetThermalZone() {
89 ✗ bool result = setString(OS_AirflowNetworkDistributionLinkageFields::ThermalZoneName, "");
90 ✗ OS_ASSERT(result);
91 ✗ }
92
93 3 boost::optional<AirflowNetworkNode> AirflowNetworkDistributionLinkage_Impl::optionalNode1() const {
94
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return getObject<ModelObject>().getModelObjectTarget<AirflowNetworkNode>(OS_AirflowNetworkDistributionLinkageFields::Node1Name);
95 }
96
97 3 boost::optional<AirflowNetworkNode> AirflowNetworkDistributionLinkage_Impl::optionalNode2() const {
98
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 return getObject<ModelObject>().getModelObjectTarget<AirflowNetworkNode>(OS_AirflowNetworkDistributionLinkageFields::Node2Name);
99 }
100
101 7 boost::optional<AirflowNetworkComponent> AirflowNetworkDistributionLinkage_Impl::optionalComponent() const {
102
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
7 return getObject<ModelObject>().getModelObjectTarget<AirflowNetworkComponent>(OS_AirflowNetworkDistributionLinkageFields::ComponentName);
103 }
104
105 4 bool AirflowNetworkDistributionLinkage_Impl::setNode1(const AirflowNetworkNode& airflowNetworkNode) {
106
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 bool result = setPointer(OS_AirflowNetworkDistributionLinkageFields::Node1Name, airflowNetworkNode.handle());
107 4 return result;
108 }
109
110 4 bool AirflowNetworkDistributionLinkage_Impl::setNode2(const AirflowNetworkNode& airflowNetworkNode) {
111
2/2
✓ Branch 1 taken 4 times.
✓ Branch 4 taken 4 times.
4 bool result = setPointer(OS_AirflowNetworkDistributionLinkageFields::Node2Name, airflowNetworkNode.handle());
112 4 return result;
113 }
114
115 6 bool AirflowNetworkDistributionLinkage_Impl::setComponent(const AirflowNetworkComponent& airflowNetworkComponent) {
116
2/2
✓ Branch 1 taken 6 times.
✓ Branch 4 taken 6 times.
6 bool result = setPointer(OS_AirflowNetworkDistributionLinkageFields::ComponentName, airflowNetworkComponent.handle());
117 6 return result;
118 }
119
120 } // namespace detail
121
122 4 AirflowNetworkDistributionLinkage::AirflowNetworkDistributionLinkage(const Model& model, const AirflowNetworkNode& node1,
123 4 const AirflowNetworkNode& node2, const AirflowNetworkComponent& component)
124 4 : AirflowNetworkLinkage(AirflowNetworkDistributionLinkage::iddObjectType(), model) {
125
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 5 not taken.
4 OS_ASSERT(getImpl<detail::AirflowNetworkDistributionLinkage_Impl>());
126
127 // TODO: Appropriately handle the following required object-list fields.
128 // OS_AirflowNetworkDistributionLinkageFields::Node1Name
129 // OS_AirflowNetworkDistributionLinkageFields::Node2Name
130 // OS_AirflowNetworkDistributionLinkageFields::ComponentName
131 4 bool ok = true;
132
1/1
✓ Branch 1 taken 4 times.
4 ok = setNode1(node1);
133
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
134
1/1
✓ Branch 1 taken 4 times.
4 ok = setNode2(node2);
135
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
136
1/1
✓ Branch 1 taken 4 times.
4 ok = setComponent(component);
137
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 3 not taken.
4 OS_ASSERT(ok);
138 4 }
139
140 8495 IddObjectType AirflowNetworkDistributionLinkage::iddObjectType() {
141
1/1
✓ Branch 1 taken 8495 times.
8495 return {IddObjectType::OS_AirflowNetworkDistributionLinkage};
142 }
143
144 3 AirflowNetworkNode AirflowNetworkDistributionLinkage::node1() const {
145
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->node1();
146 }
147
148 3 AirflowNetworkNode AirflowNetworkDistributionLinkage::node2() const {
149
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->node2();
150 }
151
152 7 AirflowNetworkComponent AirflowNetworkDistributionLinkage::component() const {
153
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->component();
154 }
155
156 2 boost::optional<ThermalZone> AirflowNetworkDistributionLinkage::thermalZone() const {
157
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->thermalZone();
158 }
159
160 4 bool AirflowNetworkDistributionLinkage::setNode1(const AirflowNetworkNode& airflowNetworkNode) {
161
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->setNode1(airflowNetworkNode);
162 }
163
164 4 bool AirflowNetworkDistributionLinkage::setNode2(const AirflowNetworkNode& airflowNetworkNode) {
165
1/1
✓ Branch 3 taken 4 times.
4 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->setNode2(airflowNetworkNode);
166 }
167
168 6 bool AirflowNetworkDistributionLinkage::setComponent(const AirflowNetworkComponent& airflowNetworkComponent) {
169
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->setComponent(airflowNetworkComponent);
170 }
171
172 ✗ bool AirflowNetworkDistributionLinkage::setThermalZone(const ThermalZone& zone) {
173 ✗ return getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->setThermalZone(zone);
174 }
175
176 ✗ void AirflowNetworkDistributionLinkage::resetThermalZone() {
177 ✗ getImpl<detail::AirflowNetworkDistributionLinkage_Impl>()->resetThermalZone();
178 ✗ }
179
180 /// @cond
181 2 AirflowNetworkDistributionLinkage::AirflowNetworkDistributionLinkage(std::shared_ptr<detail::AirflowNetworkDistributionLinkage_Impl> impl)
182
1/1
✓ Branch 2 taken 2 times.
2 : AirflowNetworkLinkage(impl) {}
183 /// @endcond
184
185 } // namespace model
186 } // namespace openstudio
187