MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / nonResourceObjectUseCount

Method nonResourceObjectUseCount

src/model/ResourceObject.cpp:53–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 }
52
53 unsigned ResourceObject_Impl::nonResourceObjectUseCount(bool excludeChildren) const {
54
55 unsigned result = 0;
56
57 ModelObjectVector children;
58 if (excludeChildren) {
59 children = this->children();
60 }
61
62 WorkspaceObjectVector sources = this->sources();
63 for (const WorkspaceObject& source : sources) {
64 OptionalResourceObject oro = source.optionalCast<ResourceObject>();
65 if (oro) {
66 // another ResourceObject, pass the request through
67 result += oro->nonResourceObjectUseCount(excludeChildren);
68 } else {
69
70 if (excludeChildren) {
71 // check if this is a child
72 auto it = std::find_if(children.cbegin(), children.cend(),
73 [h = source.handle()](const ModelObject& mo) { return handleEquals<ModelObject, Handle>(mo, h); });
74 if (it == children.end()) {
75 // non-ResourceObject and non-Child--count the use
76 ++result;
77 }
78 } else {
79 // non-ResourceObject--count the use
80 ++result;
81 }
82 }
83 }
84
85 return result;
86 }
87
88 } // namespace detail
89

Callers 2

TEST_FFunction · 0.80

Calls 6

sourcesMethod · 0.80
cbeginMethod · 0.80
cendMethod · 0.80
childrenMethod · 0.45
handleMethod · 0.45
endMethod · 0.45

Tested by 1

TEST_FFunction · 0.64