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

Method remove

src/model/ParentObject.cpp:45–72  ·  view source on GitHub ↗

remove self and all children objects recursively

Source from the content-addressed store, hash-verified

43
44 /// remove self and all children objects recursively
45 std::vector<IdfObject> ParentObject_Impl::remove() {
46 std::vector<IdfObject> result;
47
48 // DLM: the following code does not work because subTree includes this object
49 // and we don't want to call remove on the same object recursively
50 //
51 //ModelObjectVector subTree = getRecursiveChildren(getObject<ParentObject>());
52 //for (ModelObject& object : subTree) {
53 // std::vector<IdfObject> removed = object.remove();
54 // result.insert(result.end(), removed.begin(), removed.end());
55 //}
56
57 // subTree includes this object, make sure to include costs as well
58 // drop the ResourceObject instances, if they are used by other objects
59 // This is probably the unique situation where you want to get children minus ResourceObjects
60 auto subTree = getRecursiveChildren(getObject<ParentObject>(), true, false);
61 result.reserve(subTree.size());
62 for (const ModelObject& object : subTree) {
63 result.emplace_back(object.idfObject());
64 }
65
66 bool ok = model().removeObjects(getHandles<ModelObject>(subTree));
67 if (!ok) {
68 result.clear();
69 }
70
71 return result;
72 }
73
74 /// get a vector of allowable children types
75 std::vector<IddObjectType> ParentObject_Impl::allowableChildTypes() const {

Callers

nothing calls this directly

Calls 5

getRecursiveChildrenFunction · 0.85
idfObjectMethod · 0.80
sizeMethod · 0.45
removeObjectsMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected