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 | 27281 | Connection_Impl::Connection_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 24 | 27281 | : ModelObject_Impl(idfObject, model, keepHandle) { | |
| 25 |
4/6✓ Branch 1 taken 27281 times.
✓ Branch 4 taken 27281 times.
✓ Branch 7 taken 27281 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 27281 times.
✗ Branch 13 not taken.
|
27281 | OS_ASSERT(idfObject.iddObject().type() == Connection::iddObjectType()); |
| 26 | 27281 | } | |
| 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 | 9114 | 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 | 402654 | boost::optional<ModelObject> Connection_Impl::sourceObject() const { | |
| 48 |
3/3✓ Branch 1 taken 402654 times.
✓ Branch 3 taken 402571 times.
✓ Branch 4 taken 83 times.
|
805308 | if (boost::optional<WorkspaceObject> oCandidate = getTarget(openstudio::OS_ConnectionFields::SourceObject)) { |
| 49 |
2/2✓ Branch 1 taken 402571 times.
✓ Branch 4 taken 402571 times.
|
402571 | return oCandidate->optionalCast<ModelObject>(); |
| 50 | 402654 | } | |
| 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 | 400523 | boost::optional<ModelObject> Connection_Impl::targetObject() const { | |
| 59 |
3/3✓ Branch 1 taken 400523 times.
✓ Branch 3 taken 400459 times.
✓ Branch 4 taken 64 times.
|
801046 | if (boost::optional<WorkspaceObject> oCandidate = getTarget(openstudio::OS_ConnectionFields::TargetObject)) { |
| 60 |
2/2✓ Branch 1 taken 400459 times.
✓ Branch 4 taken 400459 times.
|
400459 | return oCandidate->optionalCast<ModelObject>(); |
| 61 | 400523 | } | |
| 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 | 24675 | bool Connection_Impl::setSourceObject(const ModelObject& object) { | |
| 70 |
2/2✓ Branch 1 taken 24675 times.
✓ Branch 4 taken 24675 times.
|
24675 | return setPointer(openstudio::OS_ConnectionFields::SourceObject, object.handle()); |
| 71 | ; | ||
| 72 | } | ||
| 73 | |||
| 74 | 24679 | bool Connection_Impl::setSourceObjectPort(unsigned port) { | |
| 75 | 24679 | return this->setUnsigned(openstudio::OS_ConnectionFields::OutletPort, port); | |
| 76 | } | ||
| 77 | |||
| 78 | 24675 | bool Connection_Impl::setTargetObject(const ModelObject& object) { | |
| 79 |
2/2✓ Branch 1 taken 24675 times.
✓ Branch 4 taken 24675 times.
|
24675 | return setPointer(openstudio::OS_ConnectionFields::TargetObject, object.handle()); |
| 80 | ; | ||
| 81 | } | ||
| 82 | |||
| 83 | 24679 | bool Connection_Impl::setTargetObjectPort(unsigned port) { | |
| 84 | 24679 | return this->setUnsigned(openstudio::OS_ConnectionFields::InletPort, port); | |
| 85 | } | ||
| 86 | |||
| 87 | } // namespace detail | ||
| 88 | |||
| 89 | 24676 | Connection::Connection(const Model& model) | |
| 90 | 24676 | : ModelObject(Connection::iddObjectType(), model, false) // No FastName | |
| 91 | { | ||
| 92 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 24676 times.
✗ Branch 5 not taken.
|
24676 | OS_ASSERT(getImpl<detail::Connection_Impl>()); |
| 93 | 24676 | } | |
| 94 | |||
| 95 |
1/1✓ Branch 3 taken 402658 times.
|
402658 | Connection::Connection(std::shared_ptr<detail::Connection_Impl> impl) : ModelObject(std::move(impl)) {} |
| 96 | |||
| 97 | 402654 | OptionalModelObject Connection::sourceObject() const { | |
| 98 |
1/1✓ Branch 3 taken 402654 times.
|
402654 | 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 | 400523 | OptionalModelObject Connection::targetObject() const { | |
| 106 |
1/1✓ Branch 3 taken 400523 times.
|
400523 | 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 | 24675 | bool Connection::setSourceObject(const ModelObject& object) { | |
| 114 |
1/1✓ Branch 3 taken 24675 times.
|
24675 | return getImpl<detail::Connection_Impl>()->setSourceObject(object); |
| 115 | } | ||
| 116 | |||
| 117 | 24679 | bool Connection::setSourceObjectPort(unsigned port) { | |
| 118 |
1/1✓ Branch 3 taken 24679 times.
|
24679 | return getImpl<detail::Connection_Impl>()->setSourceObjectPort(port); |
| 119 | } | ||
| 120 | |||
| 121 | 24675 | bool Connection::setTargetObject(const ModelObject& object) { | |
| 122 |
1/1✓ Branch 3 taken 24675 times.
|
24675 | return getImpl<detail::Connection_Impl>()->setTargetObject(object); |
| 123 | } | ||
| 124 | |||
| 125 | 24679 | bool Connection::setTargetObjectPort(unsigned port) { | |
| 126 |
1/1✓ Branch 3 taken 24679 times.
|
24679 | return getImpl<detail::Connection_Impl>()->setTargetObjectPort(port); |
| 127 | } | ||
| 128 | |||
| 129 | 62291 | IddObjectType Connection::iddObjectType() { | |
| 130 |
1/1✓ Branch 1 taken 62291 times.
|
62291 | IddObjectType result(IddObjectType::OS_Connection); |
| 131 | 62291 | return result; | |
| 132 | } | ||
| 133 | |||
| 134 | } // namespace model | ||
| 135 | } // namespace openstudio | ||
| 136 |