summaryrefslogtreecommitdiffstats
path: root/src/libs/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/client')
-rw-r--r--src/libs/client/ConnectionModel.cpp78
-rw-r--r--src/libs/client/ConnectionModel.hpp30
-rw-r--r--src/libs/client/Makefile.am1
-rw-r--r--src/libs/client/PatchModel.cpp2
-rw-r--r--src/libs/client/PatchModel.hpp14
-rw-r--r--src/libs/client/Serializer.cpp6
-rw-r--r--src/libs/client/Serializer.hpp4
-rw-r--r--src/libs/client/Store.cpp49
-rw-r--r--src/libs/client/Store.hpp6
9 files changed, 56 insertions, 134 deletions
diff --git a/src/libs/client/ConnectionModel.cpp b/src/libs/client/ConnectionModel.cpp
deleted file mode 100644
index d35457d1..00000000
--- a/src/libs/client/ConnectionModel.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <cassert>
-#include "ConnectionModel.hpp"
-#include "PortModel.hpp"
-#include "PatchModel.hpp"
-
-namespace Ingen {
-namespace Client {
-
-
-ConnectionModel::ConnectionModel(const Path& src_port, const Path& dst_port)
-: _src_port_path(src_port),
- _dst_port_path(dst_port)
-{
- // Be sure connection is within one patch
- //assert(_src_port_path.parent().parent()
- // == _dst_port_path.parent().parent());
-}
-
-
-ConnectionModel::ConnectionModel(SharedPtr<PortModel> src, SharedPtr<PortModel> dst)
-: _src_port_path(src->path()),
- _dst_port_path(dst->path()),
- _src_port(src),
- _dst_port(dst)
-{
- assert(_src_port);
- assert(_dst_port);
- assert(_src_port->parent());
- assert(_dst_port->parent());
-
- // Be sure connection is within one patch
- //assert(_src_port_path.parent().parent()
- // == _dst_port_path.parent().parent());
-}
-
-
-const Path
-ConnectionModel::src_port_path() const
-{
- if (!_src_port)
- return _src_port_path;
- else
- return _src_port->path();
-}
-
-
-const Path
-ConnectionModel::dst_port_path() const
-{
- if (!_dst_port)
- return _dst_port_path;
- else
- return _dst_port->path();
-}
-
-
-typedef list<SharedPtr<ConnectionModel> > ConnectionList;
-
-
-} // namespace Client
-} // namespace Ingen
diff --git a/src/libs/client/ConnectionModel.hpp b/src/libs/client/ConnectionModel.hpp
index 1a73b123..83ddbd58 100644
--- a/src/libs/client/ConnectionModel.hpp
+++ b/src/libs/client/ConnectionModel.hpp
@@ -18,12 +18,13 @@
#ifndef CONNECTIONMODEL_H
#define CONNECTIONMODEL_H
+#include <cassert>
#include <string>
#include <list>
#include <raul/Path.hpp>
#include <raul/SharedPtr.hpp>
+#include "interface/Connection.hpp"
#include "PortModel.hpp"
-#include <cassert>
namespace Ingen {
namespace Client {
@@ -41,35 +42,32 @@ class Store;
*
* \ingroup IngenClient
*/
-class ConnectionModel
+class ConnectionModel : public Shared::Connection
{
public:
SharedPtr<PortModel> src_port() const { return _src_port; }
SharedPtr<PortModel> dst_port() const { return _dst_port; }
- const Path src_port_path() const;
- const Path dst_port_path() const;
+ const Path src_port_path() const { return _src_port->path(); }
+ const Path dst_port_path() const { return _dst_port->path(); }
private:
friend class Store;
- ConnectionModel(const Path& src_port, const Path& dst_port);
- ConnectionModel(SharedPtr<PortModel> src, SharedPtr<PortModel> dst);
+ ConnectionModel(SharedPtr<PortModel> src, SharedPtr<PortModel> dst)
+ : _src_port(src)
+ , _dst_port(dst)
+ {
+ assert(_src_port);
+ assert(_dst_port);
+ assert(_src_port->parent());
+ assert(_dst_port->parent());
+ }
- void set_src_port(SharedPtr<PortModel> port) { _src_port = port; _src_port_path = port->path(); }
- void set_dst_port(SharedPtr<PortModel> port) { _dst_port = port; _dst_port_path = port->path(); }
-
- void src_port_path(const std::string& s) { _src_port_path = s; }
- void dst_port_path(const std::string& s) { _dst_port_path = s; }
-
- Path _src_port_path; ///< Only used if _src_port == NULL
- Path _dst_port_path; ///< Only used if _dst_port == NULL
SharedPtr<PortModel> _src_port;
SharedPtr<PortModel> _dst_port;
};
-typedef std::list<SharedPtr<ConnectionModel> > ConnectionList;
-
} // namespace Client
} // namespace Ingen
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am
index 45ec0bea..9ee32b84 100644
--- a/src/libs/client/Makefile.am
+++ b/src/libs/client/Makefile.am
@@ -22,7 +22,6 @@ libingen_client_la_LIBADD = \
libingen_client_la_SOURCES = \
$(top_srcdir)/ingen/src/common/interface/ClientInterface.hpp \
$(top_srcdir)/ingen/src/common/interface/EngineInterface.hpp \
- ConnectionModel.cpp \
ConnectionModel.hpp \
ControlModel.hpp \
DeprecatedLoader.cpp \
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp
index b50e4fd0..2bd514f3 100644
--- a/src/libs/client/PatchModel.cpp
+++ b/src/libs/client/PatchModel.cpp
@@ -64,7 +64,7 @@ PatchModel::remove_child(SharedPtr<ObjectModel> o)
// Remove any connections which referred to this object,
// since they can't possibly exist anymore
- for (ConnectionList::iterator j = _connections.begin(); j != _connections.end() ; ) {
+ for (Connections::iterator j = _connections.begin(); j != _connections.end() ; ) {
list<SharedPtr<ConnectionModel> >::iterator next = j;
++next;
diff --git a/src/libs/client/PatchModel.hpp b/src/libs/client/PatchModel.hpp
index 21e89cee..1c35b959 100644
--- a/src/libs/client/PatchModel.hpp
+++ b/src/libs/client/PatchModel.hpp
@@ -41,7 +41,9 @@ class Store;
class PatchModel : public NodeModel
{
public:
- const ConnectionList& connections() const { return _connections; }
+ typedef std::list<SharedPtr<ConnectionModel> > Connections;
+
+ const Connections& connections() const { return _connections; }
SharedPtr<ConnectionModel> get_connection(const string& src_port_path, const string& dst_port_path) const;
SharedPtr<NodeModel> get_node(const string& node_name) const;
@@ -97,11 +99,11 @@ private:
void rename_node(const Path& old_path, const Path& new_path);
void rename_node_port(const Path& old_path, const Path& new_path);
- ConnectionList _connections;
- string _filename;
- bool _enabled;
- size_t _poly;
- bool _editable;
+ Connections _connections;
+ string _filename;
+ bool _enabled;
+ size_t _poly;
+ bool _editable;
};
typedef Table<string, SharedPtr<PatchModel> > PatchModelMap;
diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp
index a5fbb614..a8683d00 100644
--- a/src/libs/client/Serializer.cpp
+++ b/src/libs/client/Serializer.cpp
@@ -36,7 +36,7 @@
#include <raul/TableImpl.hpp>
#include "interface/EngineInterface.hpp"
#include "interface/Port.hpp"
-#include "ConnectionModel.hpp"
+#include "interface/Connection.hpp"
#include "PatchModel.hpp"
#include "Serializer.hpp"
@@ -311,7 +311,7 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch)
serialize_port(p, port_id);
}
- for (ConnectionList::const_iterator c = patch->connections().begin(); c != patch->connections().end(); ++c) {
+ for (PatchModel::Connections::const_iterator c = patch->connections().begin(); c != patch->connections().end(); ++c) {
serialize_connection(*c);
}
}
@@ -420,7 +420,7 @@ Serializer::serialize_port(const Port* port, const RDF::Node& port_id)
void
-Serializer::serialize_connection(SharedPtr<ConnectionModel> connection) throw (std::logic_error)
+Serializer::serialize_connection(SharedPtr<Connection> connection) throw (std::logic_error)
{
if (!_model)
throw std::logic_error("serialize_connection called without serialization in progress");
diff --git a/src/libs/client/Serializer.hpp b/src/libs/client/Serializer.hpp
index fafedfa5..7a739f94 100644
--- a/src/libs/client/Serializer.hpp
+++ b/src/libs/client/Serializer.hpp
@@ -39,12 +39,12 @@ namespace Shared {
class GraphObject;
class Node;
class Port;
+ class Connection;
}
namespace Client {
class PatchModel;
-class ConnectionModel;
/** Serializes Ingen objects (patches, nodes, etc) to RDF.
@@ -61,7 +61,7 @@ public:
void start_to_string();
void serialize(SharedPtr<GraphObject> object) throw (std::logic_error);
- void serialize_connection(SharedPtr<ConnectionModel> c) throw (std::logic_error);
+ void serialize_connection(SharedPtr<Shared::Connection> c) throw (std::logic_error);
string finish();
private:
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<PluginModel> plugin)
void
-Store::add_connection_orphan(SharedPtr<ConnectionModel> connection)
+Store::add_connection_orphan(std::pair<Path, Path> 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<PortModel> port)
{
assert(port->parent());
- for (list<SharedPtr<ConnectionModel> >::iterator c = _connection_orphans.begin();
+ for (list< pair<Path, Path> >::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<SharedPtr<ConnectionModel> >::iterator next = c;
+ list< pair<Path, Path> >::iterator next = c;
++next;
- if ((*c)->src_port() && (*c)->dst_port()) {
- SharedPtr<PatchModel> 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<PortModel> src_port = PtrCast<PortModel>(object(src_port_path));
SharedPtr<PortModel> dst_port = PtrCast<PortModel>(object(dst_port_path));
- SharedPtr<ConnectionModel> 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);
}
diff --git a/src/libs/client/Store.hpp b/src/libs/client/Store.hpp
index af241097..26aac803 100644
--- a/src/libs/client/Store.hpp
+++ b/src/libs/client/Store.hpp
@@ -81,7 +81,7 @@ private:
void add_orphan(SharedPtr<ObjectModel> orphan);
void resolve_orphans(SharedPtr<ObjectModel> parent);
- void add_connection_orphan(SharedPtr<ConnectionModel> orphan);
+ void add_connection_orphan(std::pair<Path, Path> orphan);
void resolve_connection_orphans(SharedPtr<PortModel> port);
void add_plugin_orphan(SharedPtr<NodeModel> orphan);
@@ -108,6 +108,8 @@ private:
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);
+ bool attempt_connection(const Path& src_port_path, const Path& dst_port_path, bool add_orphan=false);
+
SharedPtr<EngineInterface> _engine;
SharedPtr<SigClientInterface> _emitter;
@@ -126,7 +128,7 @@ private:
Raul::PathTable<list<std::pair<string, Atom> > > _metadata_orphans;
/** Ditto */
- list<SharedPtr<ConnectionModel> > _connection_orphans;
+ list<std::pair<Path, Path> > _connection_orphans;
};