src/model/ExteriorLoadInstance.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 "ExteriorLoadInstance.hpp" | ||
| 7 | #include "ExteriorLoadInstance_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "Model_Impl.hpp" | ||
| 11 | #include "ExteriorLoadDefinition.hpp" | ||
| 12 | #include "ExteriorLoadDefinition_Impl.hpp" | ||
| 13 | #include "Space.hpp" | ||
| 14 | #include "SpaceType.hpp" | ||
| 15 | |||
| 16 | #include "../utilities/core/Assert.hpp" | ||
| 17 | |||
| 18 | namespace openstudio { | ||
| 19 | namespace model { | ||
| 20 | |||
| 21 | namespace detail { | ||
| 22 | |||
| 23 | 54 | ExteriorLoadInstance_Impl::ExteriorLoadInstance_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 24 | 54 | : ModelObject_Impl(idfObject, model, keepHandle) {} | |
| 25 | |||
| 26 | 10 | ExteriorLoadInstance_Impl::ExteriorLoadInstance_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 27 | 10 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 28 | |||
| 29 | 10 | ExteriorLoadInstance_Impl::ExteriorLoadInstance_Impl(const ExteriorLoadInstance_Impl& other, Model_Impl* model, bool keepHandle) | |
| 30 | 10 | : ModelObject_Impl(other, model, keepHandle) {} | |
| 31 | |||
| 32 | 13 | ExteriorLoadDefinition ExteriorLoadInstance_Impl::definition() const { | |
| 33 |
3/3✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
✓ Branch 7 taken 13 times.
|
13 | OptionalExteriorLoadDefinition result = getObject<ModelObject>().getModelObjectTarget<ExteriorLoadDefinition>(this->definitionIndex()); |
| 34 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
|
13 | if (!result) { |
| 35 | ✗ | LOG_AND_THROW("ExteriorLoadInstance does not have a definition." << '\n' << this->idfObject()); | |
| 36 | } | ||
| 37 |
2/2✓ Branch 1 taken 13 times.
✓ Branch 4 taken 13 times.
|
26 | return result.get(); |
| 38 | 13 | } | |
| 39 | |||
| 40 | ✗ | void ExteriorLoadInstance_Impl::makeUnique() { | |
| 41 | ✗ | ExteriorLoadDefinition definition = this->definition(); | |
| 42 | ✗ | ExteriorLoadInstanceVector instances = definition.instances(); | |
| 43 | ✗ | OS_ASSERT(!instances.empty()); | |
| 44 | ✗ | if (instances.size() == 1) { | |
| 45 | ✗ | OS_ASSERT(this->handle() == instances[0].handle()); | |
| 46 | } else { | ||
| 47 | ✗ | ModelObject clone = definition.clone(this->model()); | |
| 48 | ✗ | OS_ASSERT(this->setPointer(this->definitionIndex(), clone.handle())); | |
| 49 | ✗ | } | |
| 50 | ✗ | } | |
| 51 | |||
| 52 | ✗ | int ExteriorLoadInstance_Impl::quantity() const { | |
| 53 | ✗ | return (int)this->multiplier(); | |
| 54 | } | ||
| 55 | |||
| 56 | } // namespace detail | ||
| 57 | |||
| 58 |
2/2✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 | ExteriorLoadInstance::ExteriorLoadInstance(IddObjectType type, const ExteriorLoadDefinition& definition) : ModelObject(type, definition.model()) { |
| 59 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✗ Branch 5 not taken.
|
44 | OS_ASSERT(getImpl<detail::ExteriorLoadInstance_Impl>()); |
| 60 |
4/6✓ Branch 1 taken 44 times.
✓ Branch 6 taken 44 times.
✓ Branch 9 taken 44 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 44 times.
✗ Branch 14 not taken.
|
44 | OS_ASSERT(this->setPointer(getImpl<detail::ExteriorLoadInstance_Impl>()->definitionIndex(), definition.handle())); |
| 61 | 44 | } | |
| 62 | |||
| 63 |
1/1✓ Branch 3 taken 46 times.
|
46 | ExteriorLoadInstance::ExteriorLoadInstance(std::shared_ptr<detail::ExteriorLoadInstance_Impl> impl) : ModelObject(std::move(impl)) {} |
| 64 | |||
| 65 | 3 | ExteriorLoadDefinition ExteriorLoadInstance::definition() const { | |
| 66 |
1/1✓ Branch 3 taken 3 times.
|
3 | return getImpl<detail::ExteriorLoadInstance_Impl>()->definition(); |
| 67 | } | ||
| 68 | |||
| 69 | ✗ | bool ExteriorLoadInstance::setDefinition(const ExteriorLoadDefinition& definition) { | |
| 70 | ✗ | return getImpl<detail::ExteriorLoadInstance_Impl>()->setDefinition(definition); | |
| 71 | } | ||
| 72 | |||
| 73 | ✗ | void ExteriorLoadInstance::makeUnique() { | |
| 74 | ✗ | getImpl<detail::ExteriorLoadInstance_Impl>()->makeUnique(); | |
| 75 | ✗ | } | |
| 76 | |||
| 77 | ✗ | double ExteriorLoadInstance::multiplier() const { | |
| 78 | ✗ | return getImpl<detail::ExteriorLoadInstance_Impl>()->multiplier(); | |
| 79 | } | ||
| 80 | |||
| 81 | ✗ | bool ExteriorLoadInstance::isMultiplierDefaulted() const { | |
| 82 | ✗ | return getImpl<detail::ExteriorLoadInstance_Impl>()->isMultiplierDefaulted(); | |
| 83 | } | ||
| 84 | |||
| 85 | ✗ | int ExteriorLoadInstance::quantity() const { | |
| 86 | ✗ | return getImpl<detail::ExteriorLoadInstance_Impl>()->quantity(); | |
| 87 | } | ||
| 88 | |||
| 89 | } // namespace model | ||
| 90 | } // namespace openstudio | ||
| 91 |