| 23 | : ParentObject_Impl(other, model, keepHandle) {} |
| 24 | |
| 25 | unsigned ResourceObject_Impl::directUseCount(bool excludeChildren) const { |
| 26 | |
| 27 | unsigned result = 0; |
| 28 | |
| 29 | ModelObjectVector children; |
| 30 | if (excludeChildren) { |
| 31 | children = this->children(); |
| 32 | } |
| 33 | |
| 34 | WorkspaceObjectVector sources = this->sources(); |
| 35 | for (const WorkspaceObject& source : sources) { |
| 36 | if (excludeChildren) { |
| 37 | // check if this is a child |
| 38 | auto it = std::find_if(children.cbegin(), children.cend(), |
| 39 | [h = source.handle()](const ModelObject& mo) { return handleEquals<ModelObject, Handle>(mo, h); }); |
| 40 | if (it == children.end()) { |
| 41 | // non-Child--count the use |
| 42 | ++result; |
| 43 | } |
| 44 | } else { |
| 45 | // count the use |
| 46 | ++result; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return result; |
| 51 | } |
| 52 | |
| 53 | unsigned ResourceObject_Impl::nonResourceObjectUseCount(bool excludeChildren) const { |
| 54 | |