summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-19 06:17:49 +0000
committerDavid Robillard <d@drobilla.net>2006-06-19 06:17:49 +0000
commit2db1897709eba0e80677bd09e8444e7320e15120 (patch)
tree8062b5ede632c1c084a2c3b43bbd1a3d9991734e /src/libs/client
parent4adc4f4a2b4f57f43affcd48f2c01c60f471b20a (diff)
downloadingen-2db1897709eba0e80677bd09e8444e7320e15120.tar.gz
ingen-2db1897709eba0e80677bd09e8444e7320e15120.tar.bz2
ingen-2db1897709eba0e80677bd09e8444e7320e15120.zip
Connecting of patch ports internally (seemingly anyway, data not flowing yet)
git-svn-id: http://svn.drobilla.net/lad/grauph@61 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/ConnectionModel.cpp24
-rw-r--r--src/libs/client/ConnectionModel.h2
-rw-r--r--src/libs/client/PatchModel.cpp12
-rw-r--r--src/libs/client/Store.cpp16
-rw-r--r--src/libs/client/Store.h6
5 files changed, 42 insertions, 18 deletions
diff --git a/src/libs/client/ConnectionModel.cpp b/src/libs/client/ConnectionModel.cpp
index 1c7541b9..18b6fbd7 100644
--- a/src/libs/client/ConnectionModel.cpp
+++ b/src/libs/client/ConnectionModel.cpp
@@ -27,8 +27,8 @@ ConnectionModel::ConnectionModel(const Path& src_port, const Path& dst_port)
m_dst_port(NULL)
{
// Be sure connection is within one patch
- assert(m_src_port_path.parent().parent()
- == m_dst_port_path.parent().parent());
+ //assert(m_src_port_path.parent().parent()
+ // == m_dst_port_path.parent().parent());
}
@@ -51,4 +51,24 @@ ConnectionModel::dst_port_path() const
return m_dst_port->path();
}
+const Path
+ConnectionModel::patch_path() const
+{
+ const Path& src_node = m_src_port_path.parent();
+ const Path& dst_node = m_dst_port_path.parent();
+ Path patch_path = src_node.parent();
+
+ if (src_node.parent() != dst_node.parent()) {
+ // Connection to a patch port from inside the patch
+ assert(src_node.parent() == dst_node || dst_node.parent() == src_node);
+ if (src_node.parent() == dst_node)
+ patch_path = dst_node;
+ else
+ patch_path = src_node;
+ }
+
+ return patch_path;
+}
+
+
} // namespace LibOmClient
diff --git a/src/libs/client/ConnectionModel.h b/src/libs/client/ConnectionModel.h
index ef909850..427c5858 100644
--- a/src/libs/client/ConnectionModel.h
+++ b/src/libs/client/ConnectionModel.h
@@ -55,7 +55,7 @@ public:
const Path& src_port_path() const;
const Path& dst_port_path() const;
- const Path patch_path() const { return src_port_path().parent().parent(); }
+ const Path patch_path() const;
private:
Path m_src_port_path; ///< Only used if m_src_port == NULL
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index 7d786301..265a17d8 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -163,19 +163,23 @@ void
PatchModel::add_connection(CountedPtr<ConnectionModel> cm)
{
assert(cm);
- assert(cm->src_port_path().parent().parent() == m_path);
- assert(cm->dst_port_path().parent().parent() == m_path);
+ //assert(cm->src_port_path().parent().parent() == m_path);
+ //assert(cm->dst_port_path().parent().parent() == m_path);
assert(cm->patch_path() == path());
+ cerr << "PatchModel::add_connection: " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl;
+
CountedPtr<ConnectionModel> existing = get_connection(cm->src_port_path(), cm->dst_port_path());
if (existing) {
return;
}
- NodeModel* src_node = get_node(cm->src_port_path().parent().name()).get();
+ NodeModel* src_node = (cm->src_port_path().parent() == path())
+ ? this : get_node(cm->src_port_path().parent().name()).get();
PortModel* src_port = (src_node == NULL) ? NULL : src_node->get_port(cm->src_port_path().name()).get();
- NodeModel* dst_node = get_node(cm->dst_port_path().parent().name()).get();
+ NodeModel* dst_node = (cm->dst_port_path().parent() == path())
+ ? this : get_node(cm->dst_port_path().parent().name()).get();
PortModel* dst_port = (dst_node == NULL) ? NULL : dst_node->get_port(cm->dst_port_path().name()).get();
assert(src_port != NULL);
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp
index 542c1bc5..15f91786 100644
--- a/src/libs/client/Store.cpp
+++ b/src/libs/client/Store.cpp
@@ -311,24 +311,22 @@ Store::metadata_update_event(const string& subject_path, const string& predicate
void
-Store::connection_event(const string& src_port_path, const string& dst_port_path)
+Store::connection_event(const Path& src_port_path, const Path& dst_port_path)
{
- const Path& src = src_port_path;
- const Path& dst = dst_port_path;
-
- assert(src.parent().parent() == dst.parent().parent());
- const Path& patch_path = src.parent().parent();
+ // ConnectionModel has the clever patch-path-figuring-out stuff in it, so
+ // just make one right away to get at that
+ ConnectionModel* cm = new ConnectionModel(src_port_path, dst_port_path);
- CountedPtr<PatchModel> patch = this->patch(patch_path);
+ CountedPtr<PatchModel> patch = this->patch(cm->patch_path());
if (patch)
- patch->add_connection(new ConnectionModel(src, dst));
+ patch->add_connection(cm);
else
cerr << "ERROR: connection in nonexistant patch" << endl;
}
void
-Store::disconnection_event(const string& src_port_path, const string& dst_port_path)
+Store::disconnection_event(const Path& src_port_path, const Path& dst_port_path)
{
const Path& src = src_port_path;
const Path& dst = dst_port_path;
diff --git a/src/libs/client/Store.h b/src/libs/client/Store.h
index 0b84d418..0e47168d 100644
--- a/src/libs/client/Store.h
+++ b/src/libs/client/Store.h
@@ -22,7 +22,9 @@
#include <map>
#include "util/CountedPtr.h"
#include <sigc++/sigc++.h>
+#include "util/Path.h"
using std::string; using std::map;
+using Om::Path;
namespace LibOmClient {
@@ -71,8 +73,8 @@ private:
void new_node_event(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports);
void new_port_event(const string& path, const string& data_type, bool is_output);
void metadata_update_event(const string& subject_path, const string& predicate, const string& value);
- void connection_event(const string& src_port_path, const string& dst_port_path);
- void disconnection_event(const string& src_port_path, const string& dst_port_path);
+ void connection_event(const Path& src_port_path, const Path& dst_port_path);
+ void disconnection_event(const Path& src_port_path, const Path& dst_port_path);
map<string, CountedPtr<ObjectModel> > m_objects; ///< Keyed by Om path
map<string, CountedPtr<PluginModel> > m_plugins; ///< Keyed by URI