diff options
author | David Robillard <d@drobilla.net> | 2007-10-08 16:30:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-08 16:30:57 +0000 |
commit | 763bba9de67fb1bd06658a0bac91440727ee5a51 (patch) | |
tree | 39e7af069828981c2c06d78e015686062eba73dc /src/libs/client/PatchModel.cpp | |
parent | 260a406b12997fdab7446a9980e921d8cfc46915 (diff) | |
download | ingen-763bba9de67fb1bd06658a0bac91440727ee5a51.tar.gz ingen-763bba9de67fb1bd06658a0bac91440727ee5a51.tar.bz2 ingen-763bba9de67fb1bd06658a0bac91440727ee5a51.zip |
SharedPtr-ify engine side store.
Fix reattaching to engine.
Fix connection paths.
Remove last dependencies on client (model) library from Serialiser.
Fix Raul::PathTable::find_descendants_end.
git-svn-id: http://svn.drobilla.net/lad/ingen@847 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/PatchModel.cpp')
-rw-r--r-- | src/libs/client/PatchModel.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 3997ac77..a0f0aa4b 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -31,8 +31,6 @@ void PatchModel::add_child(SharedPtr<ObjectModel> c) { assert(c->parent().get() == this); - - //ObjectModel::add_child(c); SharedPtr<PortModel> pm = PtrCast<PortModel>(c); if (pm) { @@ -45,13 +43,6 @@ PatchModel::add_child(SharedPtr<ObjectModel> c) signal_new_node.emit(nm); } -/* -SharedPtr<NodeModel> -PatchModel::get_node(const string& name) const -{ - return PtrCast<NodeModel>(get_child(name)); -} -*/ bool PatchModel::remove_child(SharedPtr<ObjectModel> o) @@ -67,10 +58,11 @@ PatchModel::remove_child(SharedPtr<ObjectModel> o) // since they can't possibly exist anymore for (Connections::iterator j = _connections.begin(); j != _connections.end() ; ) { - list<SharedPtr<ConnectionModel> >::iterator next = j; + Connections::iterator next = j; ++next; - SharedPtr<ConnectionModel> cm = (*j); + SharedPtr<ConnectionModel> cm = PtrCast<ConnectionModel>(*j); + assert(cm); if (cm->src_port_path().parent() == o->path() || cm->src_port_path() == o->path() @@ -106,9 +98,10 @@ PatchModel::clear() SharedPtr<ConnectionModel> PatchModel::get_connection(const string& src_port_path, const string& dst_port_path) const { - for (list<SharedPtr<ConnectionModel> >::const_iterator i = _connections.begin(); i != _connections.end(); ++i) + for (Connections::const_iterator i = _connections.begin(); i != _connections.end(); ++i) if ((*i)->src_port_path() == src_port_path && (*i)->dst_port_path() == dst_port_path) - return (*i); + return PtrCast<ConnectionModel>(*i); + return SharedPtr<ConnectionModel>(); } @@ -129,18 +122,19 @@ PatchModel::add_connection(SharedPtr<ConnectionModel> cm) assert(cm->dst_port()); assert(cm->src_port()->parent()); assert(cm->dst_port()->parent()); + assert(cm->src_port_path() != cm->dst_port_path()); assert(cm->src_port()->parent().get() == this || cm->src_port()->parent()->parent().get() == this); assert(cm->dst_port()->parent().get() == this || cm->dst_port()->parent()->parent().get() == this); SharedPtr<ConnectionModel> existing = get_connection(cm->src_port_path(), cm->dst_port_path()); - + if (existing) { assert(cm->src_port() == existing->src_port()); assert(cm->dst_port() == existing->dst_port()); } else { - _connections.push_back(cm); + _connections.push_back(new Connections::Node(cm)); signal_new_connection.emit(cm); } } @@ -149,11 +143,12 @@ PatchModel::add_connection(SharedPtr<ConnectionModel> cm) void PatchModel::remove_connection(const string& src_port_path, const string& dst_port_path) { - for (list<SharedPtr<ConnectionModel> >::iterator i = _connections.begin(); i != _connections.end(); ++i) { - SharedPtr<ConnectionModel> cm = (*i); + for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) { + SharedPtr<ConnectionModel> cm = PtrCast<ConnectionModel>(*i); + assert(cm); if (cm->src_port_path() == src_port_path && cm->dst_port_path() == dst_port_path) { signal_removed_connection.emit(cm); - _connections.erase(i); // cuts our reference + delete _connections.erase(i); // cuts our reference assert(!get_connection(src_port_path, dst_port_path)); // no duplicates return; } |