GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 60 / 0 / 60
Functions: 100.0% 24 / 0 / 24
Branches: 84.8% 39 / 0 / 46

src/model/Connection.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 "Connection.hpp"
7 #include "Connection_Impl.hpp"
8 #include "ModelObject.hpp"
9
10 #include "../utilities/core/Assert.hpp"
11 #include "../utilities/core/Compare.hpp"
12 #include "../utilities/core/Containers.hpp"
13 #include "../utilities/core/UUID.hpp"
14
15 #include <utilities/idd/OS_Connection_FieldEnums.hxx>
16 #include <utilities/idd/IddEnums.hxx>
17
18 namespace openstudio {
19 namespace model {
20
21 namespace detail {
22
23 27273 Connection_Impl::Connection_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle)
24 27273 : ModelObject_Impl(idfObject, model, keepHandle) {
25
4/6
✓ Branch 1 taken 27273 times.
✓ Branch 4 taken 27273 times.
✓ Branch 7 taken 27273 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 27273 times.
✗ Branch 13 not taken.
27273 OS_ASSERT(idfObject.iddObject().type() == Connection::iddObjectType());
26 27273 }
27
28 2580 Connection_Impl::Connection_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle)
29 2580 : ModelObject_Impl(other, model, keepHandle) {
30
4/6
✓ Branch 1 taken 2580 times.
✓ Branch 4 taken 2580 times.
✓ Branch 7 taken 2580 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2580 times.
✗ Branch 13 not taken.
2580 OS_ASSERT(other.iddObject().type() == Connection::iddObjectType());
31 2580 }
32
33 9103 Connection_Impl::Connection_Impl(const Connection_Impl& other, Model_Impl* model, bool keepHandle) : ModelObject_Impl(other, model, keepHandle) {}
34
35 // virtual destructor
36
37 // Get all output variable names that could be associated with this object.
38 25 const std::vector<std::string>& Connection_Impl::outputVariableNames() const {
39
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 24 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
25 static const std::vector<std::string> result;
40 25 return result;
41 }
42
43 25 IddObjectType Connection_Impl::iddObjectType() const {
44 25 return Connection::iddObjectType();
45 }
46
47 402381 boost::optional<ModelObject> Connection_Impl::sourceObject() const {
48
3/3
✓ Branch 1 taken 402381 times.
✓ Branch 3 taken 402298 times.
✓ Branch 4 taken 83 times.
804762 if (boost::optional<WorkspaceObject> oCandidate = getTarget(openstudio::OS_ConnectionFields::SourceObject)) {
49
2/2
✓ Branch 1 taken 402298 times.
✓ Branch 4 taken 402298 times.
402298 return oCandidate->optionalCast<ModelObject>();
50 402381 }
51 83 return boost::none;
52 }
53
54 5299 boost::optional<unsigned> Connection_Impl::sourceObjectPort() const {
55 5299 return this->getUnsigned(openstudio::OS_ConnectionFields::OutletPort);
56 }
57
58 400250 boost::optional<ModelObject> Connection_Impl::targetObject() const {
59
3/3
✓ Branch 1 taken 400250 times.
✓ Branch 3 taken 400186 times.
✓ Branch 4 taken 64 times.
800500 if (boost::optional<WorkspaceObject> oCandidate = getTarget(openstudio::OS_ConnectionFields::TargetObject)) {
60
2/2
✓ Branch 1 taken 400186 times.
✓ Branch 4 taken 400186 times.
400186 return oCandidate->optionalCast<ModelObject>();
61 400250 }
62 64 return boost::none;
63 }
64
65 6233 boost::optional<unsigned> Connection_Impl::targetObjectPort() const {
66
3/3
✓ Branch 1 taken 6233 times.
✓ Branch 4 taken 6233 times.
✓ Branch 7 taken 6233 times.
6233 return this->getUnsigned(openstudio::OS_ConnectionFields::InletPort).get();
67 }
68
69 24667 bool Connection_Impl::setSourceObject(const ModelObject& object) {
70
2/2
✓ Branch 1 taken 24667 times.
✓ Branch 4 taken 24667 times.
24667 return setPointer(openstudio::OS_ConnectionFields::SourceObject, object.handle());
71 ;
72 }
73
74 24671 bool Connection_Impl::setSourceObjectPort(unsigned port) {
75 24671 return this->setUnsigned(openstudio::OS_ConnectionFields::OutletPort, port);
76 }
77
78 24667 bool Connection_Impl::setTargetObject(const ModelObject& object) {
79
2/2
✓ Branch 1 taken 24667 times.
✓ Branch 4 taken 24667 times.
24667 return setPointer(openstudio::OS_ConnectionFields::TargetObject, object.handle());
80 ;
81 }
82
83 24671 bool Connection_Impl::setTargetObjectPort(unsigned port) {
84 24671 return this->setUnsigned(openstudio::OS_ConnectionFields::InletPort, port);
85 }
86
87 } // namespace detail
88
89 24668 Connection::Connection(const Model& model)
90 24668 : ModelObject(Connection::iddObjectType(), model, false) // No FastName
91 {
92
1/3
✗ Branch 2 not taken.
✓ Branch 3 taken 24668 times.
✗ Branch 5 not taken.
24668 OS_ASSERT(getImpl<detail::Connection_Impl>());
93 24668 }
94
95
1/1
✓ Branch 3 taken 402385 times.
402385 Connection::Connection(std::shared_ptr<detail::Connection_Impl> impl) : ModelObject(std::move(impl)) {}
96
97 402381 OptionalModelObject Connection::sourceObject() const {
98
1/1
✓ Branch 3 taken 402381 times.
402381 return getImpl<detail::Connection_Impl>()->sourceObject();
99 }
100
101 5299 OptionalUnsigned Connection::sourceObjectPort() const {
102
1/1
✓ Branch 3 taken 5299 times.
5299 return getImpl<detail::Connection_Impl>()->sourceObjectPort();
103 }
104
105 400250 OptionalModelObject Connection::targetObject() const {
106
1/1
✓ Branch 3 taken 400250 times.
400250 return getImpl<detail::Connection_Impl>()->targetObject();
107 }
108
109 6233 OptionalUnsigned Connection::targetObjectPort() const {
110
1/1
✓ Branch 3 taken 6233 times.
6233 return getImpl<detail::Connection_Impl>()->targetObjectPort();
111 }
112
113 24667 bool Connection::setSourceObject(const ModelObject& object) {
114
1/1
✓ Branch 3 taken 24667 times.
24667 return getImpl<detail::Connection_Impl>()->setSourceObject(object);
115 }
116
117 24671 bool Connection::setSourceObjectPort(unsigned port) {
118
1/1
✓ Branch 3 taken 24671 times.
24671 return getImpl<detail::Connection_Impl>()->setSourceObjectPort(port);
119 }
120
121 24667 bool Connection::setTargetObject(const ModelObject& object) {
122
1/1
✓ Branch 3 taken 24667 times.
24667 return getImpl<detail::Connection_Impl>()->setTargetObject(object);
123 }
124
125 24671 bool Connection::setTargetObjectPort(unsigned port) {
126
1/1
✓ Branch 3 taken 24671 times.
24671 return getImpl<detail::Connection_Impl>()->setTargetObjectPort(port);
127 }
128
129 62145 IddObjectType Connection::iddObjectType() {
130
1/1
✓ Branch 1 taken 62145 times.
62145 IddObjectType result(IddObjectType::OS_Connection);
131 62145 return result;
132 }
133
134 } // namespace model
135 } // namespace openstudio
136