| 106 | } |
| 107 | |
| 108 | std::vector<ModelObject> getRecursiveChildren(const ParentObject& object, bool includeLifeCycleCostsAndAdditionalProperties, |
| 109 | bool includeUsedResources) { |
| 110 | std::set<Handle> resultSet; |
| 111 | std::pair<HandleSet::const_iterator, bool> insertResult; |
| 112 | resultSet.insert(object.handle()); |
| 113 | std::vector<ModelObject> result; |
| 114 | result.push_back(object); |
| 115 | |
| 116 | if (includeLifeCycleCostsAndAdditionalProperties) { |
| 117 | openstudio::detail::concat_helper(result, object.lifeCycleCosts()); |
| 118 | if (object.hasAdditionalProperties()) { |
| 119 | result.push_back(object.additionalProperties()); |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | std::deque<ParentObject> parents; |
| 124 | parents.push_back(object); |
| 125 | |
| 126 | while (!parents.empty()) { |
| 127 | ParentObject currentParent(parents[0]); |
| 128 | parents.pop_front(); |
| 129 | |
| 130 | // parent's costs have already been added |
| 131 | |
| 132 | for (const ModelObject& child : currentParent.children()) { |
| 133 | if (!includeUsedResources) { |
| 134 | auto _ro = child.optionalCast<ResourceObject>(); |
| 135 | if (_ro && _ro->directUseCount() > 1) { |
| 136 | continue; |
| 137 | } |
| 138 | } |
| 139 | insertResult = resultSet.insert(child.handle()); |
| 140 | if (insertResult.second) { |
| 141 | result.push_back(child); |
| 142 | |
| 143 | if (includeLifeCycleCostsAndAdditionalProperties) { |
| 144 | openstudio::detail::concat_helper(result, child.lifeCycleCosts()); |
| 145 | if (child.hasAdditionalProperties()) { |
| 146 | result.emplace_back(child.additionalProperties()); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | OptionalParentObject opo = child.optionalCast<ParentObject>(); |
| 151 | if (opo) { |
| 152 | parents.push_back(*opo); |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | return result; |
| 159 | } |
| 160 | |
| 161 | std::vector<ModelObject> getRecursiveChildrenAndResources(const ModelObject& object) { |
| 162 | std::set<Handle> resultSet; |
no test coverage detected