From 9d9efa215c52a6b75eef7e9a8b088b11dfd76a07 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 8 Oct 2007 01:38:38 +0000 Subject: Shared abstract Connection interface. Only Patch to go, now.... git-svn-id: http://svn.drobilla.net/lad/ingen@843 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/Store.cpp | 49 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'src/libs/client/Store.cpp') diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 2838ca12..af6b33c5 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -106,12 +106,12 @@ Store::resolve_plugin_orphans(SharedPtr plugin) void -Store::add_connection_orphan(SharedPtr connection) +Store::add_connection_orphan(std::pair orphan) { - cerr << "WARNING: Orphan connection " << connection->src_port_path() - << " -> " << connection->dst_port_path() << " received." << endl; + cerr << "WARNING: Orphan connection " << orphan.first + << " -> " << orphan.second << " received." << endl; - _connection_orphans.push_back(connection); + _connection_orphans.push_back(orphan); } @@ -120,26 +120,16 @@ Store::resolve_connection_orphans(SharedPtr port) { assert(port->parent()); - for (list >::iterator c = _connection_orphans.begin(); + for (list< pair >::iterator c = _connection_orphans.begin(); c != _connection_orphans.end(); ) { - if ((*c)->src_port_path() == port->path()) - (*c)->set_src_port(port); - - if ((*c)->dst_port_path() == port->path()) - (*c)->set_dst_port(port); - - list >::iterator next = c; + list< pair >::iterator next = c; ++next; - if ((*c)->src_port() && (*c)->dst_port()) { - SharedPtr patch = connection_patch((*c)->src_port_path(), (*c)->dst_port_path()); - if (patch) { - cerr << "Resolved orphan connection " << (*c)->src_port_path() << - (*c)->dst_port_path() << endl; - patch->add_connection(*c); + if (c->first == port->path() || c->second == port->path()) { + bool success = attempt_connection(c->first, c->second); + if (success) _connection_orphans.erase(c); - } } c = next; @@ -553,14 +543,12 @@ Store::connection_patch(const Path& src_port_path, const Path& dst_port_path) } -void -Store::connection_event(const Path& src_port_path, const Path& dst_port_path) +bool +Store::attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan) { SharedPtr src_port = PtrCast(object(src_port_path)); SharedPtr dst_port = PtrCast(object(dst_port_path)); - SharedPtr dangling_cm(new ConnectionModel(src_port_path, dst_port_path)); - if (src_port && dst_port) { assert(src_port->parent()); @@ -575,12 +563,23 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path) dst_port->connected_to(src_port); patch->add_connection(cm); + + return true; - } else { + } else if (add_orphan) { - add_connection_orphan(dangling_cm); + add_connection_orphan(make_pair(src_port_path, dst_port_path)); } + + return false; +} + + +void +Store::connection_event(const Path& src_port_path, const Path& dst_port_path) +{ + attempt_connection(src_port_path, dst_port_path, true); } -- cgit v1.2.1