src/model/SpaceLoadDefinition.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 "SpaceLoadDefinition.hpp" | ||
| 7 | #include "SpaceLoadDefinition_Impl.hpp" | ||
| 8 | |||
| 9 | #include "Model.hpp" | ||
| 10 | #include "Model_Impl.hpp" | ||
| 11 | #include "SpaceLoadInstance.hpp" | ||
| 12 | #include "SpaceLoadInstance_Impl.hpp" | ||
| 13 | |||
| 14 | #include "../utilities/core/Assert.hpp" | ||
| 15 | |||
| 16 | namespace openstudio { | ||
| 17 | namespace model { | ||
| 18 | |||
| 19 | namespace detail { | ||
| 20 | |||
| 21 | 3654 | SpaceLoadDefinition_Impl::SpaceLoadDefinition_Impl(const IdfObject& idfObject, Model_Impl* model, bool keepHandle) | |
| 22 | 3654 | : ResourceObject_Impl(idfObject, model, keepHandle) {} | |
| 23 | |||
| 24 | 2519 | SpaceLoadDefinition_Impl::SpaceLoadDefinition_Impl(const openstudio::detail::WorkspaceObject_Impl& other, Model_Impl* model, bool keepHandle) | |
| 25 | 2519 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 26 | |||
| 27 | 1363 | SpaceLoadDefinition_Impl::SpaceLoadDefinition_Impl(const SpaceLoadDefinition_Impl& other, Model_Impl* model, bool keepHandle) | |
| 28 | 1363 | : ResourceObject_Impl(other, model, keepHandle) {} | |
| 29 | |||
| 30 | 9 | std::vector<openstudio::IdfObject> SpaceLoadDefinition_Impl::remove() { | |
| 31 | 9 | std::vector<openstudio::IdfObject> temp1; | |
| 32 |
1/1✓ Branch 1 taken 9 times.
|
9 | std::vector<SpaceLoadInstance> instances = this->instances(); |
| 33 |
2/2✓ Branch 5 taken 10 times.
✓ Branch 6 taken 9 times.
|
19 | for (SpaceLoadInstance& instance : instances) { |
| 34 |
1/1✓ Branch 1 taken 10 times.
|
10 | std::vector<openstudio::IdfObject> temp2 = instance.remove(); |
| 35 |
1/1✓ Branch 5 taken 10 times.
|
10 | temp1.insert(temp1.end(), temp2.begin(), temp2.end()); |
| 36 | 10 | } | |
| 37 | |||
| 38 |
1/1✓ Branch 1 taken 9 times.
|
9 | std::vector<openstudio::IdfObject> result = ResourceObject_Impl::remove(); |
| 39 |
1/1✓ Branch 5 taken 9 times.
|
9 | result.insert(result.end(), temp1.begin(), temp1.end()); |
| 40 | |||
| 41 | 18 | return result; | |
| 42 | 9 | } | |
| 43 | |||
| 44 | 220 | std::vector<SpaceLoadInstance> SpaceLoadDefinition_Impl::instances() const { | |
| 45 |
2/2✓ Branch 1 taken 220 times.
✓ Branch 4 taken 220 times.
|
220 | return getObject<ModelObject>().getModelObjectSources<SpaceLoadInstance>(); |
| 46 | } | ||
| 47 | |||
| 48 | 46 | double SpaceLoadDefinition_Impl::floorArea() const { | |
| 49 | 46 | double result = 0; | |
| 50 |
3/3✓ Branch 1 taken 46 times.
✓ Branch 7 taken 53 times.
✓ Branch 8 taken 46 times.
|
99 | for (const SpaceLoadInstance& instance : this->instances()) { |
| 51 |
1/1✓ Branch 1 taken 53 times.
|
53 | result += instance.floorArea(); |
| 52 | 46 | } | |
| 53 | 46 | return result; | |
| 54 | } | ||
| 55 | |||
| 56 | 19 | int SpaceLoadDefinition_Impl::quantity() const { | |
| 57 | 19 | int result = 0; | |
| 58 |
3/3✓ Branch 1 taken 19 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 19 times.
|
40 | for (const SpaceLoadInstance& instance : this->instances()) { |
| 59 |
1/1✓ Branch 1 taken 21 times.
|
21 | result += instance.quantity(); |
| 60 | 19 | } | |
| 61 | 19 | return result; | |
| 62 | } | ||
| 63 | |||
| 64 | } // namespace detail | ||
| 65 | |||
| 66 | 1131 | SpaceLoadDefinition::SpaceLoadDefinition(IddObjectType type, const Model& model) : ResourceObject(type, model) { | |
| 67 |
1/3✗ Branch 2 not taken.
✓ Branch 3 taken 1131 times.
✗ Branch 5 not taken.
|
1131 | OS_ASSERT(getImpl<detail::SpaceLoadDefinition_Impl>()); |
| 68 | 1131 | } | |
| 69 | |||
| 70 |
1/1✓ Branch 3 taken 4487 times.
|
4487 | SpaceLoadDefinition::SpaceLoadDefinition(std::shared_ptr<detail::SpaceLoadDefinition_Impl> impl) : ResourceObject(std::move(impl)) {} |
| 71 | |||
| 72 | 146 | std::vector<SpaceLoadInstance> SpaceLoadDefinition::instances() const { | |
| 73 |
1/1✓ Branch 3 taken 146 times.
|
146 | return getImpl<detail::SpaceLoadDefinition_Impl>()->instances(); |
| 74 | } | ||
| 75 | |||
| 76 | 46 | double SpaceLoadDefinition::floorArea() const { | |
| 77 |
1/1✓ Branch 3 taken 46 times.
|
46 | return getImpl<detail::SpaceLoadDefinition_Impl>()->floorArea(); |
| 78 | } | ||
| 79 | |||
| 80 | 19 | int SpaceLoadDefinition::quantity() const { | |
| 81 |
1/1✓ Branch 3 taken 19 times.
|
19 | return getImpl<detail::SpaceLoadDefinition_Impl>()->quantity(); |
| 82 | } | ||
| 83 | |||
| 84 | } // namespace model | ||
| 85 | } // namespace openstudio | ||
| 86 |