summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/ObjectStore.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-05-14 23:31:15 +0000
committerDavid Robillard <d@drobilla.net>2008-05-14 23:31:15 +0000
commiteb10d32d8b59f2158ba64ba55e310ba0f5f24170 (patch)
treed67944c6ada3369ba988cee4bd86ca24ee9de703 /src/libs/engine/ObjectStore.cpp
parent5fc6f5df54a2650c4a53f04ee38cfebec0a515e1 (diff)
downloadingen-eb10d32d8b59f2158ba64ba55e310ba0f5f24170.tar.gz
ingen-eb10d32d8b59f2158ba64ba55e310ba0f5f24170.tar.bz2
ingen-eb10d32d8b59f2158ba64ba55e310ba0f5f24170.zip
Fix clear patch command (ticket #18).
Potential destruction race/leak fixes. More thorough thread assertions on graph object methods. git-svn-id: http://svn.drobilla.net/lad/ingen@1207 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/ObjectStore.cpp')
-rw-r--r--src/libs/engine/ObjectStore.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp
index e8fa3f4d..4497360a 100644
--- a/src/libs/engine/ObjectStore.cpp
+++ b/src/libs/engine/ObjectStore.cpp
@@ -149,5 +149,43 @@ ObjectStore::remove(Objects::iterator object)
}
}
+
+/** Remove all children of an object from the store.
+ *
+ * Returned is a vector containing all descendants of the object removed
+ * in lexicographically sorted order by Path.
+ */
+SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
+ObjectStore::remove_children(const Path& path)
+{
+ return remove_children(_objects.find(path));
+}
+
+
+/** Remove all children of an object from the store.
+ *
+ * Returned is a vector containing all descendants of the object removed
+ * in lexicographically sorted order by Path.
+ */
+SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > >
+ObjectStore::remove_children(Objects::iterator object)
+{
+ if (object != _objects.end()) {
+ Objects::iterator descendants_end = _objects.find_descendants_end(object);
+
+ if (descendants_end != object) {
+ Objects::iterator first_child = object;
+ ++first_child;
+ return _objects.yank(first_child, descendants_end);
+ }
+
+ } else {
+ cerr << "[ObjectStore] WARNING: Removing children of " << object->first << " failed." << endl;
+ return SharedPtr<Objects>();
+ }
+
+ return SharedPtr<Objects>();
+}
+
} // namespace Ingen