summaryrefslogtreecommitdiffstats
path: root/src/libs/client/PatchModel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client/PatchModel.cpp')
-rw-r--r--src/libs/client/PatchModel.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 36e829f3..68a55b40 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -69,6 +69,26 @@ PatchModel::add_child(CountedPtr<ObjectModel> c)
}
+void
+PatchModel::remove_child(CountedPtr<ObjectModel> c)
+{
+ assert(c->path().is_child_of(m_path));
+ assert(c->parent().get() == this);
+
+ CountedPtr<PortModel> pm = PtrCast<PortModel>(c);
+ if (pm) {
+ remove_port(pm);
+ return;
+ }
+
+ CountedPtr<NodeModel> nm = PtrCast<NodeModel>(c);
+ if (nm) {
+ remove_node(nm);
+ return;
+ }
+}
+
+
CountedPtr<NodeModel>
PatchModel::get_node(const string& name)
{
@@ -99,6 +119,25 @@ PatchModel::add_node(CountedPtr<NodeModel> nm)
void
+PatchModel::remove_node(CountedPtr<NodeModel> nm)
+{
+ assert(nm->path().is_child_of(m_path));
+ assert(nm->parent().get() == this);
+
+ NodeModelMap::iterator i = m_nodes.find(nm->path().name());
+ if (i != m_nodes.end()) {
+ assert(i->second == nm);
+ m_nodes.erase(i);
+ removed_node_sig.emit(nm->path().name());
+ return;
+ }
+
+ cerr << "[PatchModel::remove_node] " << m_path
+ << ": failed to find node " << nm->path().name() << endl;
+}
+
+
+void
PatchModel::remove_node(const string& name)
{
assert(name.find("/") == string::npos);