GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 88.5% 46 / 0 / 52
Functions: 85.7% 12 / 0 / 14
Branches: 83.1% 49 / 0 / 59

src/model/PythonPluginVariable.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 "PythonPluginVariable.hpp"
7 #include "PythonPluginVariable_Impl.hpp"
8
9 #include "PythonPluginTrendVariable.hpp"
10 #include "PythonPluginTrendVariable_Impl.hpp"
11 #include "PythonPluginOutputVariable.hpp"
12 #include "PythonPluginOutputVariable_Impl.hpp"
13
14 #include "Model.hpp"
15
16 #include <utilities/idd/IddEnums.hxx>
17 #include <utilities/idd/OS_PythonPlugin_Variable_FieldEnums.hxx>
18
19 #include "../utilities/core/Assert.hpp"
20
21 namespace openstudio {
22 namespace model {
23
24 namespace detail {
25
26 14 PythonPluginVariable_Impl::PythonPluginVariable_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
27 14 : ModelObject_Impl(idfObject, model, keepHandle) {
28
4/6
✓ Branch 1 taken 14 times.
✓ Branch 4 taken 14 times.
✓ Branch 7 taken 14 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
✗ Branch 13 not taken.
14 OS_ASSERT(idfObject.iddObject().type() == PythonPluginVariable::iddObjectType());
29 14 }
30
31 1 PythonPluginVariable_Impl::PythonPluginVariable_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, 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() == PythonPluginVariable::iddObjectType());
34 1 }
35
36 14 PythonPluginVariable_Impl::PythonPluginVariable_Impl(const PythonPluginVariable_Impl& other, Model_Impl* model, bool keepHandle)
37 14 : ModelObject_Impl(other, model, keepHandle) {}
38
39 ✗ const std::vector<std::string>& PythonPluginVariable_Impl::outputVariableNames() const {
40 ✗ static std::vector<std::string> result;
41 ✗ if (result.empty()) {
42 }
43 ✗ return result;
44 }
45
46 ✗ IddObjectType PythonPluginVariable_Impl::iddObjectType() const {
47 ✗ return PythonPluginVariable::iddObjectType();
48 }
49
50 18 std::vector<PythonPluginTrendVariable> PythonPluginVariable_Impl::pythonPluginTrendVariables() const {
51
3/3
✓ Branch 1 taken 18 times.
✓ Branch 4 taken 18 times.
✓ Branch 7 taken 18 times.
18 return getObject<ModelObject>().getModelObjectSources<PythonPluginTrendVariable>(PythonPluginTrendVariable::iddObjectType());
52 }
53
54 22 std::vector<PythonPluginOutputVariable> PythonPluginVariable_Impl::pythonPluginOutputVariables() const {
55
3/3
✓ Branch 1 taken 22 times.
✓ Branch 4 taken 22 times.
✓ Branch 7 taken 22 times.
22 return getObject<ModelObject>().getModelObjectSources<PythonPluginOutputVariable>(PythonPluginOutputVariable::iddObjectType());
56 }
57
58 2 ModelObject PythonPluginVariable_Impl::clone(Model model) const {
59
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
2 auto newVar = ModelObject_Impl::clone(model).cast<PythonPluginVariable>();
60
61
3/3
✓ Branch 1 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
4 for (const auto& child : pythonPluginTrendVariables()) {
62
4/4
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
✓ Branch 10 taken 2 times.
2 child.clone(model).cast<PythonPluginTrendVariable>().setPythonPluginVariable(newVar);
63 2 }
64
65
3/3
✓ Branch 1 taken 2 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 2 times.
5 for (const auto& child : pythonPluginOutputVariables()) {
66
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 child.clone(model).cast<PythonPluginOutputVariable>().setPythonPluginVariable(newVar);
67 2 }
68
69 4 return std::move(newVar);
70 2 }
71
72 1 std::vector<IdfObject> PythonPluginVariable_Impl::remove() {
73 1 std::vector<IdfObject> result;
74
1/1
✓ Branch 1 taken 1 time.
1 auto trends = pythonPluginTrendVariables();
75
1/1
✓ Branch 1 taken 1 time.
1 auto outputs = pythonPluginOutputVariables();
76
1/1
✓ Branch 3 taken 1 time.
1 result.reserve(trends.size() + outputs.size() + 1);
77
78
2/2
✓ Branch 4 taken 1 time.
✓ Branch 5 taken 1 time.
2 for (auto& child : trends) {
79
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 result.emplace_back(child.remove().front());
80 }
81
82
2/2
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1 time.
3 for (auto& child : outputs) {
83
2/2
✓ Branch 1 taken 2 times.
✓ Branch 5 taken 2 times.
2 result.emplace_back(child.remove().front());
84 }
85
86
2/2
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
1 result.emplace_back(ModelObject_Impl::remove().front());
87 2 return result;
88 1 }
89
90 } // namespace detail
91
92 13 PythonPluginVariable::PythonPluginVariable(const Model& model) : ModelObject(PythonPluginVariable::iddObjectType(), model) {
93
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 5 not taken.
13 OS_ASSERT(getImpl<detail::PythonPluginVariable_Impl>());
94 13 }
95
96 7630 IddObjectType PythonPluginVariable::iddObjectType() {
97
1/1
✓ Branch 1 taken 7630 times.
7630 return {IddObjectType::OS_PythonPlugin_Variable};
98 }
99
100 15 std::vector<PythonPluginTrendVariable> PythonPluginVariable::pythonPluginTrendVariables() const {
101
1/1
✓ Branch 3 taken 15 times.
15 return getImpl<detail::PythonPluginVariable_Impl>()->pythonPluginTrendVariables();
102 }
103 19 std::vector<PythonPluginOutputVariable> PythonPluginVariable::pythonPluginOutputVariables() const {
104
1/1
✓ Branch 3 taken 19 times.
19 return getImpl<detail::PythonPluginVariable_Impl>()->pythonPluginOutputVariables();
105 }
106
107 /// @cond
108
1/1
✓ Branch 3 taken 37 times.
37 PythonPluginVariable::PythonPluginVariable(std::shared_ptr<detail::PythonPluginVariable_Impl> impl) : ModelObject(std::move(impl)) {}
109 /// @endcond
110
111 } // namespace model
112 } // namespace openstudio
113