GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 68.1% 111 / 0 / 163
Functions: 69.6% 39 / 0 / 56
Branches: 38.4% 56 / 0 / 146

src/model/PythonPluginOutputVariable.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 "PythonPluginOutputVariable.hpp"
7 #include "PythonPluginOutputVariable_Impl.hpp"
8
9 #include "PythonPluginVariable.hpp"
10 #include "PythonPluginVariable_Impl.hpp"
11
12 #include "Model.hpp"
13
14 #include <utilities/idd/IddFactory.hxx>
15 #include <utilities/idd/IddEnums.hxx>
16 #include <utilities/idd/OS_PythonPlugin_OutputVariable_FieldEnums.hxx>
17
18 #include "../utilities/core/Assert.hpp"
19
20 namespace openstudio {
21 namespace model {
22
23 namespace detail {
24
25 9 PythonPluginOutputVariable_Impl::PythonPluginOutputVariable_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
26 9 : ModelObject_Impl(idfObject, model, keepHandle) {
27
4/6
✓ Branch 1 taken 9 times.
✓ Branch 4 taken 9 times.
✓ Branch 7 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✗ Branch 13 not taken.
9 OS_ASSERT(idfObject.iddObject().type() == PythonPluginOutputVariable::iddObjectType());
28 9 }
29
30 1 PythonPluginOutputVariable_Impl::PythonPluginOutputVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model,
31 1 bool keepHandle)
32 1 : ModelObject_Impl(other, model, keepHandle) {
33
4/6
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 13 not taken.
1 OS_ASSERT(other.iddObject().type() == PythonPluginOutputVariable::iddObjectType());
34 1 }
35
36 13 PythonPluginOutputVariable_Impl::PythonPluginOutputVariable_Impl(const PythonPluginOutputVariable_Impl& other, Model_Impl* model, bool keepHandle)
37 13 : ModelObject_Impl(other, model, keepHandle) {}
38
39 ✗ const std::vector<std::string>& PythonPluginOutputVariable_Impl::outputVariableNames() const {
40 ✗ static std::vector<std::string> result;
41 ✗ if (result.empty()) {
42 }
43 ✗ return result;
44 }
45
46 ✗ IddObjectType PythonPluginOutputVariable_Impl::iddObjectType() const {
47 ✗ return PythonPluginOutputVariable::iddObjectType();
48 }
49
50 12 PythonPluginVariable PythonPluginOutputVariable_Impl::pythonPluginVariable() const {
51
1/1
✓ Branch 1 taken 12 times.
12 boost::optional<PythonPluginVariable> value = optionalPythonPluginVariable();
52
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
12 if (!value) {
53 ✗ LOG_AND_THROW(briefDescription() << " does not have an Python Plugin Variable attached.");
54 }
55
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
24 return value.get();
56 12 }
57
58 7 std::string PythonPluginOutputVariable_Impl::typeofDatainVariable() const {
59
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<std::string> value = getString(OS_PythonPlugin_OutputVariableFields::TypeofDatainVariable, true);
60
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
7 OS_ASSERT(value);
61
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 return value.get();
62 7 }
63
64 7 std::string PythonPluginOutputVariable_Impl::updateFrequency() const {
65
1/1
✓ Branch 1 taken 7 times.
7 boost::optional<std::string> value = getString(OS_PythonPlugin_OutputVariableFields::UpdateFrequency, true);
66
1/3
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 4 not taken.
7 OS_ASSERT(value);
67
2/2
✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
14 return value.get();
68 7 }
69
70 7 boost::optional<std::string> PythonPluginOutputVariable_Impl::units() const {
71 7 return getString(OS_PythonPlugin_OutputVariableFields::Units, true);
72 }
73
74 9 boost::optional<std::string> PythonPluginOutputVariable_Impl::resourceType() const {
75 9 return getString(OS_PythonPlugin_OutputVariableFields::ResourceType, true);
76 }
77
78 9 boost::optional<std::string> PythonPluginOutputVariable_Impl::groupType() const {
79 9 return getString(OS_PythonPlugin_OutputVariableFields::GroupType, true);
80 }
81
82 9 boost::optional<std::string> PythonPluginOutputVariable_Impl::endUseCategory() const {
83 9 return getString(OS_PythonPlugin_OutputVariableFields::EndUseCategory, true);
84 }
85
86 7 boost::optional<std::string> PythonPluginOutputVariable_Impl::endUseSubcategory() const {
87 7 return getString(OS_PythonPlugin_OutputVariableFields::EndUseSubcategory, true);
88 }
89
90 12 bool PythonPluginOutputVariable_Impl::setPythonPluginVariable(const PythonPluginVariable& pythonPluginVariable) {
91
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 bool result = setPointer(OS_PythonPlugin_OutputVariableFields::PythonPluginVariableName, pythonPluginVariable.handle());
92 12 return result;
93 }
94
95 15 bool PythonPluginOutputVariable_Impl::setTypeofDatainVariable(const std::string& typeofDatainVariable) {
96 15 bool result = setString(OS_PythonPlugin_OutputVariableFields::TypeofDatainVariable, typeofDatainVariable);
97 15 return result;
98 }
99
100 15 bool PythonPluginOutputVariable_Impl::setUpdateFrequency(const std::string& updateFrequency) {
101 15 bool result = setString(OS_PythonPlugin_OutputVariableFields::UpdateFrequency, updateFrequency);
102 15 return result;
103 }
104
105 6 bool PythonPluginOutputVariable_Impl::setUnits(const std::string& units) {
106 6 bool result = setString(OS_PythonPlugin_OutputVariableFields::Units, units);
107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 OS_ASSERT(result);
108 6 return result;
109 }
110
111 ✗ void PythonPluginOutputVariable_Impl::resetUnits() {
112 ✗ bool result = setString(OS_PythonPlugin_OutputVariableFields::Units, "");
113 ✗ OS_ASSERT(result);
114 ✗ }
115
116 3 bool PythonPluginOutputVariable_Impl::setResourceType(const std::string& resourceType) {
117 3 bool result = setString(OS_PythonPlugin_OutputVariableFields::ResourceType, resourceType);
118 3 return result;
119 }
120
121 ✗ void PythonPluginOutputVariable_Impl::resetResourceType() {
122 ✗ bool result = setString(OS_PythonPlugin_OutputVariableFields::ResourceType, "");
123 ✗ OS_ASSERT(result);
124 ✗ }
125
126 3 bool PythonPluginOutputVariable_Impl::setGroupType(const std::string& groupType) {
127 3 bool result = setString(OS_PythonPlugin_OutputVariableFields::GroupType, groupType);
128 3 return result;
129 }
130
131 ✗ void PythonPluginOutputVariable_Impl::resetGroupType() {
132 ✗ bool result = setString(OS_PythonPlugin_OutputVariableFields::GroupType, "");
133 ✗ OS_ASSERT(result);
134 ✗ }
135
136 3 bool PythonPluginOutputVariable_Impl::setEndUseCategory(const std::string& endUseCategory) {
137 3 bool result = setString(OS_PythonPlugin_OutputVariableFields::EndUseCategory, endUseCategory);
138 3 return result;
139 }
140
141 ✗ void PythonPluginOutputVariable_Impl::resetEndUseCategory() {
142 ✗ bool result = setString(OS_PythonPlugin_OutputVariableFields::EndUseCategory, "");
143 ✗ OS_ASSERT(result);
144 ✗ }
145
146 2 bool PythonPluginOutputVariable_Impl::setEndUseSubcategory(const std::string& endUseSubcategory) {
147 2 bool result = setString(OS_PythonPlugin_OutputVariableFields::EndUseSubcategory, endUseSubcategory);
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 OS_ASSERT(result);
149 2 return result;
150 }
151
152 ✗ void PythonPluginOutputVariable_Impl::resetEndUseSubcategory() {
153 ✗ bool result = setString(OS_PythonPlugin_OutputVariableFields::EndUseSubcategory, "");
154 ✗ OS_ASSERT(result);
155 ✗ }
156
157 12 boost::optional<PythonPluginVariable> PythonPluginOutputVariable_Impl::optionalPythonPluginVariable() const {
158
2/2
✓ Branch 1 taken 12 times.
✓ Branch 4 taken 12 times.
12 return getObject<ModelObject>().getModelObjectTarget<PythonPluginVariable>(OS_PythonPlugin_OutputVariableFields::PythonPluginVariableName);
159 }
160
161 } // namespace detail
162
163 8 PythonPluginOutputVariable::PythonPluginOutputVariable(const PythonPluginVariable& pythonPluginVariable)
164
3/3
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
✓ Branch 7 taken 8 times.
8 : ModelObject(PythonPluginOutputVariable::iddObjectType(), pythonPluginVariable.model()) {
165
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 5 not taken.
8 OS_ASSERT(getImpl<detail::PythonPluginOutputVariable_Impl>());
166
167 8 bool ok = true;
168
1/1
✓ Branch 1 taken 8 times.
8 ok = setPythonPluginVariable(pythonPluginVariable);
169
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
8 OS_ASSERT(ok);
170
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 ok = setTypeofDatainVariable("Averaged");
171
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
8 OS_ASSERT(ok);
172
2/2
✓ Branch 1 taken 8 times.
✓ Branch 4 taken 8 times.
8 ok = setUpdateFrequency("ZoneTimestep");
173
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 3 not taken.
8 OS_ASSERT(ok);
174 8 }
175
176 7644 IddObjectType PythonPluginOutputVariable::iddObjectType() {
177
1/1
✓ Branch 1 taken 7644 times.
7644 return {IddObjectType::OS_PythonPlugin_OutputVariable};
178 }
179
180 ✗ std::vector<std::string> PythonPluginOutputVariable::typeofDatainVariableValues() {
181 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_PythonPlugin_OutputVariableFields::TypeofDatainVariable);
182 }
183
184 ✗ std::vector<std::string> PythonPluginOutputVariable::updateFrequencyValues() {
185 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_PythonPlugin_OutputVariableFields::UpdateFrequency);
186 }
187
188 ✗ std::vector<std::string> PythonPluginOutputVariable::resourceTypeValues() {
189 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_PythonPlugin_OutputVariableFields::ResourceType);
190 }
191
192 ✗ std::vector<std::string> PythonPluginOutputVariable::groupTypeValues() {
193 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_PythonPlugin_OutputVariableFields::GroupType);
194 }
195
196 ✗ std::vector<std::string> PythonPluginOutputVariable::endUseCategoryValues() {
197 ✗ return getIddKeyNames(IddFactory::instance().getObject(iddObjectType()).get(), OS_PythonPlugin_OutputVariableFields::EndUseCategory);
198 }
199
200 12 PythonPluginVariable PythonPluginOutputVariable::pythonPluginVariable() const {
201
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::PythonPluginOutputVariable_Impl>()->pythonPluginVariable();
202 }
203
204 7 std::string PythonPluginOutputVariable::typeofDatainVariable() const {
205
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::PythonPluginOutputVariable_Impl>()->typeofDatainVariable();
206 }
207
208 7 std::string PythonPluginOutputVariable::updateFrequency() const {
209
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::PythonPluginOutputVariable_Impl>()->updateFrequency();
210 }
211
212 7 boost::optional<std::string> PythonPluginOutputVariable::units() const {
213
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::PythonPluginOutputVariable_Impl>()->units();
214 }
215
216 9 boost::optional<std::string> PythonPluginOutputVariable::resourceType() const {
217
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::PythonPluginOutputVariable_Impl>()->resourceType();
218 }
219
220 9 boost::optional<std::string> PythonPluginOutputVariable::groupType() const {
221
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::PythonPluginOutputVariable_Impl>()->groupType();
222 }
223
224 9 boost::optional<std::string> PythonPluginOutputVariable::endUseCategory() const {
225
1/1
✓ Branch 3 taken 9 times.
9 return getImpl<detail::PythonPluginOutputVariable_Impl>()->endUseCategory();
226 }
227
228 7 boost::optional<std::string> PythonPluginOutputVariable::endUseSubcategory() const {
229
1/1
✓ Branch 3 taken 7 times.
7 return getImpl<detail::PythonPluginOutputVariable_Impl>()->endUseSubcategory();
230 }
231
232 12 bool PythonPluginOutputVariable::setPythonPluginVariable(const PythonPluginVariable& pythonPluginVariable) {
233
1/1
✓ Branch 3 taken 12 times.
12 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setPythonPluginVariable(pythonPluginVariable);
234 }
235
236 15 bool PythonPluginOutputVariable::setTypeofDatainVariable(const std::string& typeofDatainVariable) {
237
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setTypeofDatainVariable(typeofDatainVariable);
238 }
239
240 15 bool PythonPluginOutputVariable::setUpdateFrequency(const std::string& updateFrequency) {
241
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setUpdateFrequency(updateFrequency);
242 }
243
244 6 bool PythonPluginOutputVariable::setUnits(const std::string& units) {
245
1/1
✓ Branch 3 taken 6 times.
6 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setUnits(units);
246 }
247
248 ✗ void PythonPluginOutputVariable::resetUnits() {
249 ✗ getImpl<detail::PythonPluginOutputVariable_Impl>()->resetUnits();
250 ✗ }
251
252 3 bool PythonPluginOutputVariable::setResourceType(const std::string& resourceType) {
253
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setResourceType(resourceType);
254 }
255
256 ✗ void PythonPluginOutputVariable::resetResourceType() {
257 ✗ getImpl<detail::PythonPluginOutputVariable_Impl>()->resetResourceType();
258 ✗ }
259
260 3 bool PythonPluginOutputVariable::setGroupType(const std::string& groupType) {
261
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setGroupType(groupType);
262 }
263
264 ✗ void PythonPluginOutputVariable::resetGroupType() {
265 ✗ getImpl<detail::PythonPluginOutputVariable_Impl>()->resetGroupType();
266 ✗ }
267
268 3 bool PythonPluginOutputVariable::setEndUseCategory(const std::string& endUseCategory) {
269
1/1
✓ Branch 3 taken 3 times.
3 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setEndUseCategory(endUseCategory);
270 }
271
272 ✗ void PythonPluginOutputVariable::resetEndUseCategory() {
273 ✗ getImpl<detail::PythonPluginOutputVariable_Impl>()->resetEndUseCategory();
274 ✗ }
275
276 2 bool PythonPluginOutputVariable::setEndUseSubcategory(const std::string& endUseSubcategory) {
277
1/1
✓ Branch 3 taken 2 times.
2 return getImpl<detail::PythonPluginOutputVariable_Impl>()->setEndUseSubcategory(endUseSubcategory);
278 }
279
280 ✗ void PythonPluginOutputVariable::resetEndUseSubcategory() {
281 ✗ getImpl<detail::PythonPluginOutputVariable_Impl>()->resetEndUseSubcategory();
282 ✗ }
283
284 /// @cond
285 49 PythonPluginOutputVariable::PythonPluginOutputVariable(std::shared_ptr<detail::PythonPluginOutputVariable_Impl> impl)
286
1/1
✓ Branch 3 taken 49 times.
49 : ModelObject(std::move(impl)) {}
287 /// @endcond
288
289 } // namespace model
290 } // namespace openstudio
291