From 3dd4b42f3054f819c865e9415c4b86ba78d43aec Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 11 May 2012 03:56:54 +0000 Subject: "Connection" => "Edge" git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4345 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/Connection.hpp | 39 -------- ingen/Edge.hpp | 39 ++++++++ ingen/Patch.hpp | 10 +- ingen/client/EdgeModel.hpp | 4 +- ingen/client/PatchModel.hpp | 18 ++-- ingen/serialisation/Serialiser.hpp | 6 +- src/client/ClientStore.cpp | 12 +-- src/client/PatchModel.cpp | 37 ++++--- src/gui/Connection.cpp | 38 ------- src/gui/Connection.hpp | 53 ---------- src/gui/Edge.cpp | 33 +++++++ src/gui/Edge.hpp | 54 ++++++++++ src/gui/PatchCanvas.cpp | 20 ++-- src/gui/wscript | 2 +- src/serialisation/Serialiser.cpp | 36 +++---- src/server/ClientBroadcaster.cpp | 2 +- src/server/ClientBroadcaster.hpp | 5 - src/server/CompiledPatch.hpp | 8 +- src/server/ConnectionImpl.cpp | 192 ------------------------------------ src/server/ConnectionImpl.hpp | 105 -------------------- src/server/DuplexPort.cpp | 1 - src/server/EdgeImpl.cpp | 192 ++++++++++++++++++++++++++++++++++++ src/server/EdgeImpl.hpp | 105 ++++++++++++++++++++ src/server/InputPort.cpp | 70 ++++++------- src/server/InputPort.hpp | 30 +++--- src/server/MessageContext.cpp | 2 +- src/server/ObjectSender.cpp | 8 +- src/server/PatchImpl.cpp | 46 ++++----- src/server/PatchImpl.hpp | 22 ++--- src/server/events/Connect.cpp | 24 ++--- src/server/events/Connect.hpp | 6 +- src/server/events/Disconnect.cpp | 34 +++---- src/server/events/Disconnect.hpp | 14 +-- src/server/events/DisconnectAll.cpp | 16 +-- src/server/wscript | 2 +- src/shared/Builder.cpp | 14 +-- src/shared/World.cpp | 6 +- 37 files changed, 646 insertions(+), 659 deletions(-) delete mode 100644 ingen/Connection.hpp create mode 100644 ingen/Edge.hpp delete mode 100644 src/gui/Connection.cpp delete mode 100644 src/gui/Connection.hpp create mode 100644 src/gui/Edge.cpp create mode 100644 src/gui/Edge.hpp delete mode 100644 src/server/ConnectionImpl.cpp delete mode 100644 src/server/ConnectionImpl.hpp create mode 100644 src/server/EdgeImpl.cpp create mode 100644 src/server/EdgeImpl.hpp diff --git a/ingen/Connection.hpp b/ingen/Connection.hpp deleted file mode 100644 index 7ff34847..00000000 --- a/ingen/Connection.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#ifndef INGEN_INTERFACE_CONNECTION_HPP -#define INGEN_INTERFACE_CONNECTION_HPP - -namespace Raul { class Path; } - -namespace Ingen { - -/** A connection between two ports. - * - * \ingroup interface - */ -class Connection -{ -public: - virtual ~Connection() {} - - virtual const Raul::Path& tail_path() const = 0; - virtual const Raul::Path& head_path() const = 0; -}; - -} // namespace Ingen - -#endif // INGEN_INTERFACE_CONNECTION_HPP diff --git a/ingen/Edge.hpp b/ingen/Edge.hpp new file mode 100644 index 00000000..66e9c21b --- /dev/null +++ b/ingen/Edge.hpp @@ -0,0 +1,39 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_INTERFACE_EDGE_HPP +#define INGEN_INTERFACE_EDGE_HPP + +namespace Raul { class Path; } + +namespace Ingen { + +/** A connection between two ports. + * + * \ingroup interface + */ +class Edge +{ +public: + virtual ~Edge() {} + + virtual const Raul::Path& tail_path() const = 0; + virtual const Raul::Path& head_path() const = 0; +}; + +} // namespace Ingen + +#endif // INGEN_INTERFACE_EDGE_HPP diff --git a/ingen/Patch.hpp b/ingen/Patch.hpp index 807b843a..c0056f44 100644 --- a/ingen/Patch.hpp +++ b/ingen/Patch.hpp @@ -26,19 +26,19 @@ namespace Ingen { -class Connection; +class Edge; -/** A Path (graph of Nodes/Connections) +/** A Path (graph of Nodes/Edges) * * \ingroup interface */ class Patch : virtual public Node { public: - typedef std::pair ConnectionsKey; - typedef std::map< ConnectionsKey, SharedPtr > Connections; + typedef std::pair EdgesKey; + typedef std::map< EdgesKey, SharedPtr > Edges; - virtual const Connections& connections() const = 0; + virtual const Edges& edges() const = 0; virtual bool enabled() const = 0; virtual uint32_t internal_poly() const = 0; diff --git a/ingen/client/EdgeModel.hpp b/ingen/client/EdgeModel.hpp index 9b409e92..83faa25f 100644 --- a/ingen/client/EdgeModel.hpp +++ b/ingen/client/EdgeModel.hpp @@ -22,7 +22,7 @@ #include "raul/Path.hpp" #include "raul/SharedPtr.hpp" -#include "ingen/Connection.hpp" +#include "ingen/Edge.hpp" #include "ingen/client/PortModel.hpp" namespace Ingen { @@ -34,7 +34,7 @@ class ClientStore; * * \ingroup IngenClient */ -class EdgeModel : public Connection +class EdgeModel : public Edge { public: SharedPtr tail() const { return _tail; } diff --git a/ingen/client/PatchModel.hpp b/ingen/client/PatchModel.hpp index 1ea822bb..af5ecb2f 100644 --- a/ingen/client/PatchModel.hpp +++ b/ingen/client/PatchModel.hpp @@ -40,10 +40,10 @@ class PatchModel : public NodeModel, public Ingen::Patch public: /* WARNING: Copy constructor creates a shallow copy WRT connections */ - const Connections& connections() const { return *_connections.get(); } + const Edges& edges() const { return *_edges.get(); } - SharedPtr get_connection(const Ingen::Port* tail, - const Ingen::Port* head); + SharedPtr get_edge(const Ingen::Port* tail, + const Ingen::Port* head); bool enabled() const; bool polyphonic() const; @@ -52,15 +52,15 @@ public: // Signals INGEN_SIGNAL(new_node, void, SharedPtr); INGEN_SIGNAL(removed_node, void, SharedPtr); - INGEN_SIGNAL(new_connection, void, SharedPtr); - INGEN_SIGNAL(removed_connection, void, SharedPtr); + INGEN_SIGNAL(new_edge, void, SharedPtr); + INGEN_SIGNAL(removed_edge, void, SharedPtr); private: friend class ClientStore; PatchModel(Shared::URIs& uris, const Raul::Path& patch_path) : NodeModel(uris, "http://drobilla.net/ns/ingen#Patch", patch_path) - , _connections(new Connections()) + , _edges(new Edges()) { } @@ -68,11 +68,11 @@ private: void add_child(SharedPtr c); bool remove_child(SharedPtr c); - void add_connection(SharedPtr cm); - void remove_connection(const Ingen::Port* tail, + void add_edge(SharedPtr cm); + void remove_edge(const Ingen::Port* tail, const Ingen::Port* head); - SharedPtr _connections; + SharedPtr _edges; }; } // namespace Client diff --git a/ingen/serialisation/Serialiser.hpp b/ingen/serialisation/Serialiser.hpp index cfc11c02..b09c194a 100644 --- a/ingen/serialisation/Serialiser.hpp +++ b/ingen/serialisation/Serialiser.hpp @@ -34,7 +34,7 @@ class GraphObject; class Patch; class Node; class Port; -class Connection; +class Edge; namespace Shared { class World; @@ -69,8 +69,8 @@ public: virtual void serialise(SharedPtr object) throw (std::logic_error); - virtual void serialise_connection(const Sord::Node& parent, - SharedPtr c) throw (std::logic_error); + virtual void serialise_edge(const Sord::Node& parent, + SharedPtr c) throw (std::logic_error); virtual std::string finish(); diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 042cba57..a78653e5 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -457,7 +457,7 @@ ClientStore::attempt_connection(const Raul::Path& tail_path, tail->connected_to(head); head->connected_to(tail); - patch->add_connection(cm); + patch->add_edge(cm); return true; } @@ -495,7 +495,7 @@ ClientStore::disconnect(const Raul::Path& src, SharedPtr patch = connection_patch(src_path, dst_path); if (patch) - patch->remove_connection(tail.get(), head.get()); + patch->remove_edge(tail.get(), head.get()); } void @@ -511,9 +511,9 @@ ClientStore::disconnect_all(const Raul::Path& parent_patch, return; } - const PatchModel::Connections connections = patch->connections(); - for (PatchModel::Connections::const_iterator i = connections.begin(); - i != connections.end(); ++i) { + const PatchModel::Edges edges = patch->edges(); + for (PatchModel::Edges::const_iterator i = edges.begin(); + i != edges.end(); ++i) { SharedPtr c = PtrCast(i->second); if (c->tail()->parent() == object || c->head()->parent() == object @@ -521,7 +521,7 @@ ClientStore::disconnect_all(const Raul::Path& parent_patch, || c->head()->path() == path) { c->tail()->disconnected_from(c->head()); c->head()->disconnected_from(c->tail()); - patch->remove_connection(c->tail().get(), c->head().get()); + patch->remove_edge(c->tail().get(), c->head().get()); } } } diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index e52e4eea..df6f63c0 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -53,9 +53,8 @@ PatchModel::remove_child(SharedPtr o) // Remove any connections which referred to this object, // since they can't possibly exist anymore - for (Connections::iterator j = _connections->begin(); - j != _connections->end();) { - Connections::iterator next = j; + for (Edges::iterator j = _edges->begin(); j != _edges->end();) { + Edges::iterator next = j; ++next; SharedPtr cm = PtrCast(j->second); @@ -65,8 +64,8 @@ PatchModel::remove_child(SharedPtr o) || cm->tail_path() == o->path() || cm->head_path().parent() == o->path() || cm->head_path() == o->path()) { - _signal_removed_connection.emit(cm); - _connections->erase(j); // cuts our reference + _signal_removed_edge.emit(cm); + _edges->erase(j); // cuts our reference } j = next; } @@ -85,19 +84,19 @@ PatchModel::remove_child(SharedPtr o) void PatchModel::clear() { - _connections->clear(); + _edges->clear(); NodeModel::clear(); - assert(_connections->empty()); + assert(_edges->empty()); assert(_ports.empty()); } SharedPtr -PatchModel::get_connection(const Port* tail, const Ingen::Port* head) +PatchModel::get_edge(const Port* tail, const Ingen::Port* head) { - Connections::iterator i = _connections->find(make_pair(tail, head)); - if (i != _connections->end()) + Edges::iterator i = _edges->find(make_pair(tail, head)); + if (i != _edges->end()) return PtrCast(i->second); else return SharedPtr(); @@ -111,7 +110,7 @@ PatchModel::get_connection(const Port* tail, const Ingen::Port* head) * this patch is a fatal error. */ void -PatchModel::add_connection(SharedPtr cm) +PatchModel::add_edge(SharedPtr cm) { // Store should have 'resolved' the connection already assert(cm); @@ -125,27 +124,27 @@ PatchModel::add_connection(SharedPtr cm) assert(cm->head()->parent().get() == this || cm->head()->parent()->parent().get() == this); - SharedPtr existing = get_connection( + SharedPtr existing = get_edge( cm->tail().get(), cm->head().get()); if (existing) { assert(cm->tail() == existing->tail()); assert(cm->head() == existing->head()); } else { - _connections->insert(make_pair(make_pair(cm->tail().get(), + _edges->insert(make_pair(make_pair(cm->tail().get(), cm->head().get()), cm)); - _signal_new_connection.emit(cm); + _signal_new_edge.emit(cm); } } void -PatchModel::remove_connection(const Port* tail, const Ingen::Port* head) +PatchModel::remove_edge(const Port* tail, const Ingen::Port* head) { - Connections::iterator i = _connections->find(make_pair(tail, head)); - if (i != _connections->end()) { + Edges::iterator i = _edges->find(make_pair(tail, head)); + if (i != _edges->end()) { SharedPtr c = PtrCast(i->second); - _signal_removed_connection.emit(c); - _connections->erase(i); + _signal_removed_edge.emit(c); + _edges->erase(i); } else { Raul::warn(Raul::fmt("Failed to remove patch connection %1% => %2%\n") % tail->path() % head->path()); diff --git a/src/gui/Connection.cpp b/src/gui/Connection.cpp deleted file mode 100644 index 0e0093de..00000000 --- a/src/gui/Connection.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#include "Connection.hpp" -#include "Port.hpp" - -#include "ingen/client/EdgeModel.hpp" - -using namespace std; - -namespace Ingen { -namespace GUI { - -Connection::Connection(Ganv::Canvas& canvas, - boost::shared_ptr model, - Ganv::Node* src, - Ganv::Node* dst, - uint32_t color) - : Ganv::Edge(canvas, src, dst, color) - , _edge_model(model) -{ -} - -} // namespace GUI -} // namespace Ingen diff --git a/src/gui/Connection.hpp b/src/gui/Connection.hpp deleted file mode 100644 index 17d80bc0..00000000 --- a/src/gui/Connection.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#ifndef INGEN_GUI_CONNECTION_HPP -#define INGEN_GUI_CONNECTION_HPP - -#include -#include -#include "ganv/Edge.hpp" -#include "raul/SharedPtr.hpp" - -namespace Ingen { - -namespace Client { class EdgeModel; } - -namespace GUI { - -/** A Connection in a Patch. - * - * \ingroup GUI - */ -class Connection : public Ganv::Edge -{ -public: - Connection(Ganv::Canvas& canvas, - boost::shared_ptr model, - Ganv::Node* src, - Ganv::Node* dst, - uint32_t color); - - SharedPtr model() const { return _edge_model; } - -private: - SharedPtr _edge_model; -}; - -} // namespace GUI -} // namespace Ingen - -#endif // INGEN_GUI_CONNECTION_HPP diff --git a/src/gui/Edge.cpp b/src/gui/Edge.cpp new file mode 100644 index 00000000..9916959e --- /dev/null +++ b/src/gui/Edge.cpp @@ -0,0 +1,33 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#include "Edge.hpp" + +namespace Ingen { +namespace GUI { + +Edge::Edge(Ganv::Canvas& canvas, + boost::shared_ptr model, + Ganv::Node* src, + Ganv::Node* dst, + uint32_t color) + : Ganv::Edge(canvas, src, dst, color) + , _edge_model(model) +{ +} + +} // namespace GUI +} // namespace Ingen diff --git a/src/gui/Edge.hpp b/src/gui/Edge.hpp new file mode 100644 index 00000000..99b83cbb --- /dev/null +++ b/src/gui/Edge.hpp @@ -0,0 +1,54 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_GUI_EDGE_HPP +#define INGEN_GUI_EDGE_HPP + +#include +#include + +#include "ganv/Edge.hpp" +#include "raul/SharedPtr.hpp" + +namespace Ingen { + +namespace Client { class EdgeModel; } + +namespace GUI { + +/** An Edge in a Patch. + * + * \ingroup GUI + */ +class Edge : public Ganv::Edge +{ +public: + Edge(Ganv::Canvas& canvas, + boost::shared_ptr model, + Ganv::Node* src, + Ganv::Node* dst, + uint32_t color); + + SharedPtr model() const { return _edge_model; } + +private: + SharedPtr _edge_model; +}; + +} // namespace GUI +} // namespace Ingen + +#endif // INGEN_GUI_EDGE_HPP diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index c8347bcb..20e3e82a 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -35,7 +35,7 @@ #include "raul/log.hpp" #include "App.hpp" -#include "Connection.hpp" +#include "Edge.hpp" #include "LoadPluginWindow.hpp" #include "NewSubpatchWindow.hpp" #include "NodeModule.hpp" @@ -131,9 +131,9 @@ PatchCanvas::PatchCanvas(App& app, sigc::mem_fun(this, &PatchCanvas::add_port)); _patch->signal_removed_port().connect( sigc::mem_fun(this, &PatchCanvas::remove_port)); - _patch->signal_new_connection().connect( + _patch->signal_new_edge().connect( sigc::mem_fun(this, &PatchCanvas::connection)); - _patch->signal_removed_connection().connect( + _patch->signal_removed_edge().connect( sigc::mem_fun(this, &PatchCanvas::disconnection)); _app.store()->signal_new_plugin().connect( @@ -301,9 +301,9 @@ PatchCanvas::build() add_port(*i); } - // Create connections - for (PatchModel::Connections::const_iterator i = _patch->connections().begin(); - i != _patch->connections().end(); ++i) { + // Create edges + for (PatchModel::Edges::const_iterator i = _patch->edges().begin(); + i != _patch->edges().end(); ++i) { connection(PtrCast(i->second)); } } @@ -478,7 +478,7 @@ PatchCanvas::connection(SharedPtr cm) Ganv::Port* const head = get_port_view(cm->head()); if (tail && head) { - new GUI::Connection(*this, cm, tail, head, tail->get_fill_color()); + new GUI::Edge(*this, cm, tail, head, tail->get_fill_color()); } else { LOG(error) << "Unable to find ports to connect " << cm->tail_path() << " -> " << cm->head_path() << endl; @@ -657,11 +657,11 @@ PatchCanvas::copy_selection() for (SelectedEdges::const_iterator c = selected_edges().begin(); c != selected_edges().end(); ++c) { - Connection* const connection = dynamic_cast(*c); - if (connection) { + Edge* const edge = dynamic_cast(*c); + if (edge) { const Sord::URI subject(*_app.world()->rdf_world(), base_uri); - serialiser.serialise_connection(subject, connection->model()); + serialiser.serialise_edge(subject, edge->model()); } } diff --git a/src/gui/wscript b/src/gui/wscript index f0893cbf..6aa80389 100644 --- a/src/gui/wscript +++ b/src/gui/wscript @@ -31,7 +31,7 @@ def build(bld): BreadCrumbs.cpp Configuration.cpp ConnectWindow.cpp - Connection.cpp + Edge.cpp LoadPatchWindow.cpp LoadPluginWindow.cpp MessagesWindow.cpp diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 2d8f9d70..6e126c42 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -28,7 +28,7 @@ #include #include -#include "ingen/Connection.hpp" +#include "ingen/Edge.hpp" #include "ingen/Interface.hpp" #include "ingen/Node.hpp" #include "ingen/Patch.hpp" @@ -93,8 +93,8 @@ struct Serialiser::Impl { SharedPtr patch, const std::string& patch_symbol); - void serialise_connection(const Sord::Node& parent, - SharedPtr c) + void serialise_edge(const Sord::Node& parent, + SharedPtr c) throw (std::logic_error); std::string finish(); @@ -440,9 +440,9 @@ Serialiser::Impl::serialise_patch(SharedPtr patch, serialise_port(p, Resource::INTERNAL, port_id); } - for (Patch::Connections::const_iterator c = patch->connections().begin(); - c != patch->connections().end(); ++c) { - serialise_connection(patch_id, c->second); + for (Patch::Edges::const_iterator c = patch->edges().begin(); + c != patch->edges().end(); ++c) { + serialise_edge(patch_id, c->second); } } @@ -498,37 +498,37 @@ Serialiser::Impl::serialise_port(const Port* port, } void -Serialiser::serialise_connection(const Sord::Node& parent, - SharedPtr connection) +Serialiser::serialise_edge(const Sord::Node& parent, + SharedPtr edge) throw (std::logic_error) { - return me->serialise_connection(parent, connection); + return me->serialise_edge(parent, edge); } void -Serialiser::Impl::serialise_connection(const Sord::Node& parent, - SharedPtr connection) +Serialiser::Impl::serialise_edge(const Sord::Node& parent, + SharedPtr edge) throw (std::logic_error) { if (!_model) throw std::logic_error( - "serialise_connection called without serialisation in progress"); + "serialise_edge called without serialisation in progress"); Sord::World& world = _model->world(); - const Sord::Node src = path_rdf_node(connection->tail_path()); - const Sord::Node dst = path_rdf_node(connection->head_path()); - const Sord::Node connection_id = Sord::Node::blank_id(*_world.rdf_world()); - _model->add_statement(connection_id, + const Sord::Node src = path_rdf_node(edge->tail_path()); + const Sord::Node dst = path_rdf_node(edge->head_path()); + const Sord::Node edge_id = Sord::Node::blank_id(*_world.rdf_world()); + _model->add_statement(edge_id, Sord::Curie(world, "ingen:tail"), src); - _model->add_statement(connection_id, + _model->add_statement(edge_id, Sord::Curie(world, "ingen:head"), dst); _model->add_statement(parent, Sord::Curie(world, "ingen:edge"), - connection_id); + edge_id); } static bool diff --git a/src/server/ClientBroadcaster.cpp b/src/server/ClientBroadcaster.cpp index 1194cd82..6c81e5de 100644 --- a/src/server/ClientBroadcaster.cpp +++ b/src/server/ClientBroadcaster.cpp @@ -21,7 +21,7 @@ #include "raul/log.hpp" #include "ClientBroadcaster.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "EngineStore.hpp" #include "ObjectSender.hpp" #include "PluginImpl.hpp" diff --git a/src/server/ClientBroadcaster.hpp b/src/server/ClientBroadcaster.hpp index 5eea1093..88c471c6 100644 --- a/src/server/ClientBroadcaster.hpp +++ b/src/server/ClientBroadcaster.hpp @@ -33,11 +33,6 @@ namespace Ingen { namespace Server { class GraphObjectImpl; -class NodeImpl; -class PortImpl; -class PluginImpl; -class PatchImpl; -class ConnectionImpl; /** Broadcaster for all clients. * diff --git a/src/server/CompiledPatch.hpp b/src/server/CompiledPatch.hpp index 5f699d2d..0a5752a5 100644 --- a/src/server/CompiledPatch.hpp +++ b/src/server/CompiledPatch.hpp @@ -28,7 +28,7 @@ namespace Ingen { namespace Server { -class ConnectionImpl; +class EdgeImpl; class NodeImpl; /** All information required about a node to execute it in an audio thread. @@ -69,10 +69,10 @@ class CompiledPatch : public std::vector , public boost::noncopyable { public: - typedef std::vector QueuedConnections; + typedef std::vector QueuedEdges; - /** All (audio context => other context) connections */ - std::vector queued_connections; + /** All (audio context => other context) edges */ + std::vector queued_edges; }; } // namespace Server diff --git a/src/server/ConnectionImpl.cpp b/src/server/ConnectionImpl.cpp deleted file mode 100644 index c91b7403..00000000 --- a/src/server/ConnectionImpl.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#include -#include - -#include "ingen/shared/URIs.hpp" -#include "lv2/lv2plug.in/ns/ext/atom/util.h" -#include "raul/Maid.hpp" -#include "raul/log.hpp" - -#include "AudioBuffer.hpp" -#include "BufferFactory.hpp" -#include "ConnectionImpl.hpp" -#include "Engine.hpp" -#include "InputPort.hpp" -#include "MessageContext.hpp" -#include "NodeImpl.hpp" -#include "OutputPort.hpp" -#include "PortImpl.hpp" -#include "ProcessContext.hpp" -#include "mix.hpp" -#include "util.hpp" - -namespace Ingen { -namespace Server { - -/** Constructor for a connection from a node's output port. - * - * This handles both polyphonic and monophonic nodes, transparently to the - * user (InputPort). - */ -ConnectionImpl::ConnectionImpl(PortImpl* tail, PortImpl* head) - : _tail(tail) - , _head(head) - , _queue(NULL) -{ - assert(tail); - assert(head); - assert(tail != head); - assert(tail->path() != head->path()); - - if (must_queue()) - _queue = new Raul::RingBuffer(tail->buffer_size() * 2); -} - -void -ConnectionImpl::dump() const -{ - Raul::debug << _tail->path() << " -> " << _head->path() - << (must_mix() ? " (MIX) " : " (DIRECT) ") - << (must_queue() ? " (QUEUE)" : " (NOQUEUE) ") - << "POLY: " << _tail->poly() << " => " << _head->poly() - << std::endl; -} - -const Raul::Path& -ConnectionImpl::tail_path() const -{ - return _tail->path(); -} - -const Raul::Path& -ConnectionImpl::head_path() const -{ - return _head->path(); -} - -void -ConnectionImpl::get_sources(Context& context, - uint32_t voice, - boost::intrusive_ptr* srcs, - uint32_t max_num_srcs, - uint32_t& num_srcs) -{ - if (must_queue() && _queue->read_space() > 0) { - LV2_Atom obj; - _queue->peek(sizeof(LV2_Atom), &obj); - BufferRef buf = context.engine().buffer_factory()->get( - head()->buffer_type(), sizeof(LV2_Atom) + obj.size); - void* data = buf->port_data(PortType::ATOM, context.offset()); - _queue->read(sizeof(LV2_Atom) + obj.size, (LV2_Atom*)data); - srcs[num_srcs++] = buf; - } else if (must_mix()) { - // Mixing down voices: every src voice mixed into every dst voice - for (uint32_t v = 0; v < _tail->poly(); ++v) { - assert(num_srcs < max_num_srcs); - srcs[num_srcs++] = _tail->buffer(v).get(); - } - } else { - // Matching polyphony: each src voice mixed into corresponding dst voice - assert(_tail->poly() == _head->poly()); - assert(num_srcs < max_num_srcs); - srcs[num_srcs++] = _tail->buffer(voice).get(); - } -} - -void -ConnectionImpl::queue(Context& context) -{ - if (!must_queue()) - return; - - const Ingen::Shared::URIs& uris = _tail->bufs().uris(); - - boost::intrusive_ptr src_buf = _tail->buffer(0); - if (src_buf->atom()->type != uris.atom_Sequence) { - Raul::error << "Queued edge source is not a Sequence" << std::endl; - return; - } - - LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)src_buf->atom(); - LV2_ATOM_SEQUENCE_FOREACH(seq, ev) { - _queue->write(sizeof(LV2_Atom) + ev->body.size, &ev->body); - context.engine().message_context()->run( - _head->parent_node(), context.start() + ev->time.frames); - - } -} - -BufferRef -ConnectionImpl::buffer(uint32_t voice) const -{ - assert(!must_mix()); - assert(!must_queue()); - assert(_tail->poly() == 1 || _tail->poly() > voice); - if (_tail->poly() == 1) { - return _tail->buffer(0); - } else { - return _tail->buffer(voice); - } -} - -bool -ConnectionImpl::must_mix() const -{ - return _tail->poly() > _head->poly(); -} - -bool -ConnectionImpl::must_queue() const -{ - return _tail->parent_node()->context() - != _head->parent_node()->context(); -} - -bool -ConnectionImpl::can_connect(const OutputPort* src, const InputPort* dst) -{ - const Ingen::Shared::URIs& uris = src->bufs().uris(); - return ( - // (Audio | Control | CV) => (Audio | Control | CV) - ( (src->is_a(PortType::CONTROL) || - src->is_a(PortType::AUDIO) || - src->is_a(PortType::CV)) - && (dst->is_a(PortType::CONTROL) - || dst->is_a(PortType::AUDIO) - || dst->is_a(PortType::CV))) - - // Equal types - || (src->type() == dst->type() && - src->buffer_type() == dst->buffer_type()) - - // Control => atom:Float Value - || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float)) - - // Audio => atom:Sound Value - || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound)) - - // atom:Float Value => Control - || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL)) - - // atom:Sound Value => Audio - || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO))); -} - -} // namespace Server -} // namespace Ingen - diff --git a/src/server/ConnectionImpl.hpp b/src/server/ConnectionImpl.hpp deleted file mode 100644 index 395e749d..00000000 --- a/src/server/ConnectionImpl.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2012 David Robillard - - Ingen is free software: you can redistribute it and/or modify it under the - terms of the GNU Affero General Public License as published by the Free - Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. - - You should have received a copy of the GNU Affero General Public License - along with Ingen. If not, see . -*/ - -#ifndef INGEN_ENGINE_CONNECTIONIMPL_HPP -#define INGEN_ENGINE_CONNECTIONIMPL_HPP - -#include - -#include -#include -#include - -#include "ingen/Connection.hpp" -#include "lv2/lv2plug.in/ns/ext/atom/atom.h" -#include "raul/Deletable.hpp" -#include "raul/log.hpp" - -#include "BufferFactory.hpp" -#include "Context.hpp" - -namespace Ingen { -namespace Server { - -class PortImpl; -class OutputPort; -class InputPort; -class Buffer; -class BufferFactory; - -/** Represents a single inbound connection for an InputPort. - * - * This can be a group of ports (ie coming from a polyphonic Node) or - * a single Port. This class exists basically as an abstraction of mixing - * down polyphonic inputs, so InputPort can just deal with mixing down - * multiple connections (oblivious to the polyphonic situation of the - * connection itself). - * - * This is stored in an intrusive slist in InputPort. - * - * \ingroup engine - */ -class ConnectionImpl - : public Raul::Deletable - , private Raul::Noncopyable - , public Connection - , public boost::intrusive::slist_base_hook< - boost::intrusive::link_mode > -{ -public: - ConnectionImpl(PortImpl* tail, PortImpl* head); - - PortImpl* tail() const { return _tail; } - PortImpl* head() const { return _head; } - - const Raul::Path& tail_path() const; - const Raul::Path& head_path() const; - - void queue(Context& context); - - void get_sources(Context& context, - uint32_t voice, - boost::intrusive_ptr* srcs, - uint32_t max_num_srcs, - uint32_t& num_srcs); - - /** Get the buffer for a particular voice. - * A Connection is smart - it knows the destination port requesting the - * buffer, and will return accordingly (e.g. the same buffer for every - * voice in a mono->poly connection). - */ - BufferRef buffer(uint32_t voice) const; - - /** Whether this connection must mix down voices into a local buffer */ - bool must_mix() const; - - /** Whether this connection crosses contexts and must buffer */ - bool must_queue() const; - - static bool can_connect(const OutputPort* src, const InputPort* dst); - -protected: - void dump() const; - - PortImpl* const _tail; - PortImpl* const _head; - Raul::RingBuffer* _queue; -}; - -} // namespace Server -} // namespace Ingen - -#endif // INGEN_ENGINE_CONNECTIONIMPL_HPP diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index e63de6e2..1a62d562 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -21,7 +21,6 @@ #include "ingen/shared/URIs.hpp" #include "Buffer.hpp" -#include "ConnectionImpl.hpp" #include "DuplexPort.hpp" #include "NodeImpl.hpp" #include "OutputPort.hpp" diff --git a/src/server/EdgeImpl.cpp b/src/server/EdgeImpl.cpp new file mode 100644 index 00000000..a5c63d4a --- /dev/null +++ b/src/server/EdgeImpl.cpp @@ -0,0 +1,192 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#include +#include + +#include "ingen/shared/URIs.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/util.h" +#include "raul/Maid.hpp" +#include "raul/log.hpp" + +#include "AudioBuffer.hpp" +#include "BufferFactory.hpp" +#include "EdgeImpl.hpp" +#include "Engine.hpp" +#include "InputPort.hpp" +#include "MessageContext.hpp" +#include "NodeImpl.hpp" +#include "OutputPort.hpp" +#include "PortImpl.hpp" +#include "ProcessContext.hpp" +#include "mix.hpp" +#include "util.hpp" + +namespace Ingen { +namespace Server { + +/** Constructor for a edge from a node's output port. + * + * This handles both polyphonic and monophonic nodes, transparently to the + * user (InputPort). + */ +EdgeImpl::EdgeImpl(PortImpl* tail, PortImpl* head) + : _tail(tail) + , _head(head) + , _queue(NULL) +{ + assert(tail); + assert(head); + assert(tail != head); + assert(tail->path() != head->path()); + + if (must_queue()) + _queue = new Raul::RingBuffer(tail->buffer_size() * 2); +} + +void +EdgeImpl::dump() const +{ + Raul::debug << _tail->path() << " -> " << _head->path() + << (must_mix() ? " (MIX) " : " (DIRECT) ") + << (must_queue() ? " (QUEUE)" : " (NOQUEUE) ") + << "POLY: " << _tail->poly() << " => " << _head->poly() + << std::endl; +} + +const Raul::Path& +EdgeImpl::tail_path() const +{ + return _tail->path(); +} + +const Raul::Path& +EdgeImpl::head_path() const +{ + return _head->path(); +} + +void +EdgeImpl::get_sources(Context& context, + uint32_t voice, + boost::intrusive_ptr* srcs, + uint32_t max_num_srcs, + uint32_t& num_srcs) +{ + if (must_queue() && _queue->read_space() > 0) { + LV2_Atom obj; + _queue->peek(sizeof(LV2_Atom), &obj); + BufferRef buf = context.engine().buffer_factory()->get( + head()->buffer_type(), sizeof(LV2_Atom) + obj.size); + void* data = buf->port_data(PortType::ATOM, context.offset()); + _queue->read(sizeof(LV2_Atom) + obj.size, (LV2_Atom*)data); + srcs[num_srcs++] = buf; + } else if (must_mix()) { + // Mixing down voices: every src voice mixed into every dst voice + for (uint32_t v = 0; v < _tail->poly(); ++v) { + assert(num_srcs < max_num_srcs); + srcs[num_srcs++] = _tail->buffer(v).get(); + } + } else { + // Matching polyphony: each src voice mixed into corresponding dst voice + assert(_tail->poly() == _head->poly()); + assert(num_srcs < max_num_srcs); + srcs[num_srcs++] = _tail->buffer(voice).get(); + } +} + +void +EdgeImpl::queue(Context& context) +{ + if (!must_queue()) + return; + + const Ingen::Shared::URIs& uris = _tail->bufs().uris(); + + boost::intrusive_ptr src_buf = _tail->buffer(0); + if (src_buf->atom()->type != uris.atom_Sequence) { + Raul::error << "Queued edge source is not a Sequence" << std::endl; + return; + } + + LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)src_buf->atom(); + LV2_ATOM_SEQUENCE_FOREACH(seq, ev) { + _queue->write(sizeof(LV2_Atom) + ev->body.size, &ev->body); + context.engine().message_context()->run( + _head->parent_node(), context.start() + ev->time.frames); + + } +} + +BufferRef +EdgeImpl::buffer(uint32_t voice) const +{ + assert(!must_mix()); + assert(!must_queue()); + assert(_tail->poly() == 1 || _tail->poly() > voice); + if (_tail->poly() == 1) { + return _tail->buffer(0); + } else { + return _tail->buffer(voice); + } +} + +bool +EdgeImpl::must_mix() const +{ + return _tail->poly() > _head->poly(); +} + +bool +EdgeImpl::must_queue() const +{ + return _tail->parent_node()->context() + != _head->parent_node()->context(); +} + +bool +EdgeImpl::can_connect(const OutputPort* src, const InputPort* dst) +{ + const Ingen::Shared::URIs& uris = src->bufs().uris(); + return ( + // (Audio | Control | CV) => (Audio | Control | CV) + ( (src->is_a(PortType::CONTROL) || + src->is_a(PortType::AUDIO) || + src->is_a(PortType::CV)) + && (dst->is_a(PortType::CONTROL) + || dst->is_a(PortType::AUDIO) + || dst->is_a(PortType::CV))) + + // Equal types + || (src->type() == dst->type() && + src->buffer_type() == dst->buffer_type()) + + // Control => atom:Float Value + || (src->is_a(PortType::CONTROL) && dst->supports(uris.atom_Float)) + + // Audio => atom:Sound Value + || (src->is_a(PortType::AUDIO) && dst->supports(uris.atom_Sound)) + + // atom:Float Value => Control + || (src->supports(uris.atom_Float) && dst->is_a(PortType::CONTROL)) + + // atom:Sound Value => Audio + || (src->supports(uris.atom_Sound) && dst->is_a(PortType::AUDIO))); +} + +} // namespace Server +} // namespace Ingen + diff --git a/src/server/EdgeImpl.hpp b/src/server/EdgeImpl.hpp new file mode 100644 index 00000000..3d39e492 --- /dev/null +++ b/src/server/EdgeImpl.hpp @@ -0,0 +1,105 @@ +/* + This file is part of Ingen. + Copyright 2007-2012 David Robillard + + Ingen is free software: you can redistribute it and/or modify it under the + terms of the GNU Affero General Public License as published by the Free + Software Foundation, either version 3 of the License, or 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 Affero General Public License for details. + + You should have received a copy of the GNU Affero General Public License + along with Ingen. If not, see . +*/ + +#ifndef INGEN_ENGINE_EDGE_IMPL_HPP +#define INGEN_ENGINE_EDGE_IMPL_HPP + +#include + +#include +#include +#include + +#include "ingen/Edge.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" +#include "raul/Deletable.hpp" +#include "raul/log.hpp" + +#include "BufferFactory.hpp" +#include "Context.hpp" + +namespace Ingen { +namespace Server { + +class PortImpl; +class OutputPort; +class InputPort; +class Buffer; +class BufferFactory; + +/** Represents a single inbound connection for an InputPort. + * + * This can be a group of ports (ie coming from a polyphonic Node) or + * a single Port. This class exists basically as an abstraction of mixing + * down polyphonic inputs, so InputPort can just deal with mixing down + * multiple connections (oblivious to the polyphonic situation of the + * connection itself). + * + * This is stored in an intrusive slist in InputPort. + * + * \ingroup engine + */ +class EdgeImpl + : public Raul::Deletable + , private Raul::Noncopyable + , public Edge + , public boost::intrusive::slist_base_hook< + boost::intrusive::link_mode > +{ +public: + EdgeImpl(PortImpl* tail, PortImpl* head); + + PortImpl* tail() const { return _tail; } + PortImpl* head() const { return _head; } + + const Raul::Path& tail_path() const; + const Raul::Path& head_path() const; + + void queue(Context& context); + + void get_sources(Context& context, + uint32_t voice, + boost::intrusive_ptr* srcs, + uint32_t max_num_srcs, + uint32_t& num_srcs); + + /** Get the buffer for a particular voice. + * An Edge is smart - it knows the destination port requesting the + * buffer, and will return accordingly (e.g. the same buffer for every + * voice in a mono->poly edge). + */ + BufferRef buffer(uint32_t voice) const; + + /** Whether this edge must mix down voices into a local buffer */ + bool must_mix() const; + + /** Whether this edge crosses contexts and must buffer */ + bool must_queue() const; + + static bool can_connect(const OutputPort* src, const InputPort* dst); + +protected: + void dump() const; + + PortImpl* const _tail; + PortImpl* const _head; + Raul::RingBuffer* _queue; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_EDGEIMPL_HPP diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 3f3dcdd0..33e8e913 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -21,7 +21,7 @@ #include "AudioBuffer.hpp" #include "BufferFactory.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "Engine.hpp" #include "InputPort.hpp" #include "NodeImpl.hpp" @@ -48,7 +48,7 @@ InputPort::InputPort(BufferFactory& bufs, const Raul::Atom& value, size_t buffer_size) : PortImpl(bufs, parent, symbol, index, poly, type, buffer_type, value, buffer_size) - , _num_connections(0) + , _num_edges(0) { const Ingen::Shared::URIs& uris = bufs.uris(); @@ -82,22 +82,22 @@ InputPort::get_buffers(BufferFactory& bufs, Raul::Array* buffers, uint32_t poly) const { - size_t num_connections = (ThreadManager::thread_is(THREAD_PROCESS)) - ? _connections.size() : _num_connections; + size_t num_edges = (ThreadManager::thread_is(THREAD_PROCESS)) + ? _edges.size() : _num_edges; - if (is_a(PortType::AUDIO) && num_connections == 0) { - // Audio input with no connections, use shared zero buffer + if (is_a(PortType::AUDIO) && num_edges == 0) { + // Audio input with no edges, use shared zero buffer for (uint32_t v = 0; v < poly; ++v) buffers->at(v) = bufs.silent_buffer(); return false; - } else if (num_connections == 1) { + } else if (num_edges == 1) { if (ThreadManager::thread_is(THREAD_PROCESS)) { - if (!_connections.front().must_mix() && - !_connections.front().must_queue()) { + if (!_edges.front().must_mix() && + !_edges.front().must_queue()) { // Single non-mixing conneciton, use buffers directly for (uint32_t v = 0; v < poly; ++v) - buffers->at(v) = _connections.front().buffer(v); + buffers->at(v) = _edges.front().buffer(v); return false; } } @@ -111,52 +111,52 @@ InputPort::get_buffers(BufferFactory& bufs, return true; } -/** Add a connection. Realtime safe. +/** Add a edge. Realtime safe. * - * The buffer of this port will be set directly to the connection's buffer - * if there is only one connection, since no copying/mixing needs to take place. + * The buffer of this port will be set directly to the edge's buffer + * if there is only one edge, since no copying/mixing needs to take place. * * Note that setup_buffers must be called after this before the change * will audibly take effect. */ void -InputPort::add_connection(ConnectionImpl* c) +InputPort::add_edge(EdgeImpl* c) { ThreadManager::assert_thread(THREAD_PROCESS); - _connections.push_front(*c); + _edges.push_front(*c); // Broadcast value/activity of connected input _broadcast = true; } -/** Remove a connection. Realtime safe. +/** Remove a edge. Realtime safe. * * Note that setup_buffers must be called after this before the change * will audibly take effect. */ -ConnectionImpl* -InputPort::remove_connection(ProcessContext& context, const OutputPort* tail) +EdgeImpl* +InputPort::remove_edge(ProcessContext& context, const OutputPort* tail) { ThreadManager::assert_thread(THREAD_PROCESS); - ConnectionImpl* connection = NULL; - for (Connections::iterator i = _connections.begin(); i != _connections.end(); ++i) { + EdgeImpl* edge = NULL; + for (Edges::iterator i = _edges.begin(); i != _edges.end(); ++i) { if (i->tail() == tail) { - connection = &*i; - _connections.erase(i); + edge = &*i; + _edges.erase(i); break; } } - if (!connection) { - Raul::error << "[InputPort::remove_connection] Connection not found!" + if (!edge) { + Raul::error << "[InputPort::remove_edge] Edge not found!" << std::endl; return NULL; } // Turn off broadcasting if we're no longer connected - if (_connections.empty()) { + if (_edges.empty()) { if (is_a(PortType::AUDIO)) { // Send an update peak of 0.0 to reset to silence const Notification note = Notification::make( @@ -167,7 +167,7 @@ InputPort::remove_connection(ProcessContext& context, const OutputPort* tail) _broadcast = false; } - return connection; + return edge; } /** Prepare buffer for access, mixing if necessary. Realtime safe. @@ -179,19 +179,19 @@ InputPort::pre_process(Context& context) if (_set_by_user) return; - if (_connections.empty()) { + if (_edges.empty()) { for (uint32_t v = 0; v < _poly; ++v) { buffer(v)->prepare_read(context); } } else if (direct_connect()) { for (uint32_t v = 0; v < _poly; ++v) { - _buffers->at(v) = _connections.front().buffer(v); + _buffers->at(v) = _edges.front().buffer(v); _buffers->at(v)->prepare_read(context); } } else { uint32_t max_num_srcs = 0; - for (Connections::const_iterator c = _connections.begin(); - c != _connections.end(); ++c) { + for (Edges::const_iterator c = _edges.begin(); + c != _edges.end(); ++c) { max_num_srcs += c->tail()->poly(); } @@ -199,8 +199,8 @@ InputPort::pre_process(Context& context) for (uint32_t v = 0; v < _poly; ++v) { uint32_t num_srcs = 0; - for (Connections::iterator c = _connections.begin(); - c != _connections.end(); ++c) { + for (Edges::iterator c = _edges.begin(); + c != _edges.end(); ++c) { c->get_sources(context, v, srcs, max_num_srcs, num_srcs); } @@ -230,9 +230,9 @@ InputPort::post_process(Context& context) bool InputPort::direct_connect() const { - return _connections.size() == 1 - && !_connections.front().must_mix() - && !_connections.front().must_queue(); + return _edges.size() == 1 + && !_edges.front().must_mix() + && !_edges.front().must_queue(); } } // namespace Server diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp index 5d7269da..ea52b15e 100644 --- a/src/server/InputPort.hpp +++ b/src/server/InputPort.hpp @@ -26,12 +26,12 @@ #include "raul/SharedPtr.hpp" #include "PortImpl.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" namespace Ingen { namespace Server { -class ConnectionImpl; +class EdgeImpl; class Context; class NodeImpl; class OutputPort; @@ -40,10 +40,10 @@ class ProcessContext; /** An input port on a Node or Patch. * * All ports have a Buffer, but the actual contents (data) of that buffer may be - * set directly to the incoming connection's buffer if there's only one inbound - * connection, to eliminate the need to copy/mix. + * set directly to the incoming edge's buffer if there's only one inbound + * edge, to eliminate the need to copy/mix. * - * If a port has multiple connections, they will be mixed down into the local + * If a port has multiple edges, they will be mixed down into the local * buffer and it will be used. * * \ingroup engine @@ -63,13 +63,13 @@ public: virtual ~InputPort() {} - typedef boost::intrusive::slist - > Connections; + > Edges; - void add_connection(ConnectionImpl* c); - ConnectionImpl* remove_connection(ProcessContext& context, - const OutputPort* tail); + void add_edge(EdgeImpl* c); + EdgeImpl* remove_edge(ProcessContext& context, + const OutputPort* tail); bool apply_poly(Raul::Maid& maid, uint32_t poly); @@ -80,9 +80,9 @@ public: void pre_process(Context& context); void post_process(Context& context); - size_t num_connections() const { return _num_connections; } ///< Pre-process thread - void increment_num_connections() { ++_num_connections; } - void decrement_num_connections() { --_num_connections; } + size_t num_edges() const { return _num_edges; } ///< Pre-process thread + void increment_num_edges() { ++_num_edges; } + void decrement_num_edges() { --_num_edges; } bool is_input() const { return true; } bool is_output() const { return false; } @@ -90,8 +90,8 @@ public: bool direct_connect() const; protected: - size_t _num_connections; ///< Pre-process thread - Connections _connections; + size_t _num_edges; ///< Pre-process thread + Edges _edges; }; } // namespace Server diff --git a/src/server/MessageContext.cpp b/src/server/MessageContext.cpp index d59452d7..4a476bd6 100644 --- a/src/server/MessageContext.cpp +++ b/src/server/MessageContext.cpp @@ -17,7 +17,7 @@ #include #include "lv2/lv2plug.in/ns/ext/worker/worker.h" #include "raul/log.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "Engine.hpp" #include "MessageContext.hpp" #include "NodeImpl.hpp" diff --git a/src/server/ObjectSender.cpp b/src/server/ObjectSender.cpp index 167ffb1f..7dc8ca39 100644 --- a/src/server/ObjectSender.cpp +++ b/src/server/ObjectSender.cpp @@ -21,7 +21,7 @@ #include "PatchImpl.hpp" #include "NodeImpl.hpp" #include "PortImpl.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "NodeFactory.hpp" #include "PortType.hpp" #include "AudioBuffer.hpp" @@ -86,9 +86,9 @@ ObjectSender::send_patch(Interface* client, send_port(client, port, false); } - // Send connections - for (PatchImpl::Connections::const_iterator j = patch->connections().begin(); - j != patch->connections().end(); ++j) + // Send edges + for (PatchImpl::Edges::const_iterator j = patch->edges().begin(); + j != patch->edges().end(); ++j) client->connect(j->second->tail_path(), j->second->head_path()); } diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index f24ab574..112e2a49 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -22,7 +22,7 @@ #include "ingen/shared/World.hpp" #include "raul/log.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "Driver.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" @@ -170,9 +170,9 @@ PatchImpl::process(ProcessContext& context) } } - // Queue any cross-context connections - for (CompiledPatch::QueuedConnections::iterator i = _compiled_patch->queued_connections.begin(); - i != _compiled_patch->queued_connections.end(); ++i) { + // Queue any cross-context edges + for (CompiledPatch::QueuedEdges::iterator i = _compiled_patch->queued_edges.begin(); + i != _compiled_patch->queued_edges.end(); ++i) { (*i)->queue(context); } @@ -295,36 +295,36 @@ PatchImpl::remove_node(const Raul::Symbol& symbol) } void -PatchImpl::add_connection(SharedPtr c) +PatchImpl::add_edge(SharedPtr c) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - _connections.insert(make_pair(make_pair(c->tail(), c->head()), c)); + _edges.insert(make_pair(make_pair(c->tail(), c->head()), c)); } -/** Remove a connection. +/** Remove a edge. * Preprocessing thread only. */ -SharedPtr -PatchImpl::remove_connection(const PortImpl* tail, const PortImpl* dst_port) +SharedPtr +PatchImpl::remove_edge(const PortImpl* tail, const PortImpl* dst_port) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Connections::iterator i = _connections.find(make_pair(tail, dst_port)); - if (i != _connections.end()) { - SharedPtr c = PtrCast(i->second); - _connections.erase(i); + Edges::iterator i = _edges.find(make_pair(tail, dst_port)); + if (i != _edges.end()) { + SharedPtr c = PtrCast(i->second); + _edges.erase(i); return c; } else { - Raul::error << "[PatchImpl::remove_connection] Connection not found" << endl; - return SharedPtr(); + Raul::error << "[PatchImpl::remove_edge] Edge not found" << endl; + return SharedPtr(); } } bool -PatchImpl::has_connection(const PortImpl* tail, const PortImpl* dst_port) const +PatchImpl::has_edge(const PortImpl* tail, const PortImpl* dst_port) const { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Connections::const_iterator i = _connections.find(make_pair(tail, dst_port)); - return (i != _connections.end()); + Edges::const_iterator i = _edges.find(make_pair(tail, dst_port)); + return (i != _edges.end()); } uint32_t @@ -468,13 +468,13 @@ PatchImpl::compile() const compile_recursive(node, compiled_patch); } - // Add any queued connections that must be run after a cycle - for (Connections::const_iterator i = _connections.begin(); - i != _connections.end(); ++i) { - SharedPtr c = PtrCast(i->second); + // Add any queued edges that must be run after a cycle + for (Edges::const_iterator i = _edges.begin(); + i != _edges.end(); ++i) { + SharedPtr c = PtrCast(i->second); if (c->tail()->parent_node()->context() == Context::AUDIO && c->head()->parent_node()->context() == Context::MESSAGE) { - compiled_patch->queued_connections.push_back(c.get()); + compiled_patch->queued_edges.push_back(c.get()); } } diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp index 85b53351..872993ce 100644 --- a/src/server/PatchImpl.hpp +++ b/src/server/PatchImpl.hpp @@ -31,12 +31,12 @@ namespace Ingen { -class Connection; +class Edge; namespace Server { class CompiledPatch; -class ConnectionImpl; +class EdgeImpl; class Context; class Engine; class ProcessContext; @@ -99,11 +99,11 @@ public: void add_node(Nodes::Node* tn); Nodes::Node* remove_node(const Raul::Symbol& symbol); - Nodes& nodes() { return _nodes; } - Connections& connections() { return _connections; } + Nodes& nodes() { return _nodes; } + Edges& edges() { return _edges; } - const Nodes& nodes() const { return _nodes; } - const Connections& connections() const { return _connections; } + const Nodes& nodes() const { return _nodes; } + const Edges& edges() const { return _edges; } uint32_t num_ports() const; @@ -130,12 +130,12 @@ public: Ports::Node* remove_port(const std::string& name); void clear_ports(); - void add_connection(SharedPtr c); + void add_edge(SharedPtr c); - SharedPtr remove_connection(const PortImpl* tail, - const PortImpl* head); + SharedPtr remove_edge(const PortImpl* tail, + const PortImpl* head); - bool has_connection(const PortImpl* tail, const PortImpl* head) const; + bool has_edge(const PortImpl* tail, const PortImpl* head) const; CompiledPatch* compiled_patch() { return _compiled_patch; } void compiled_patch(CompiledPatch* cp) { _compiled_patch = cp; } @@ -161,7 +161,7 @@ private: Engine& _engine; uint32_t _internal_poly; CompiledPatch* _compiled_patch; ///< Process thread only - Connections _connections; ///< Pre-process thread only + Edges _edges; ///< Pre-process thread only Ports _inputs; ///< Pre-process thread only Ports _outputs; ///< Pre-process thread only Nodes _nodes; ///< Pre-process thread only diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 1fe88c22..7f28c3e6 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -24,7 +24,7 @@ #include "ClientBroadcaster.hpp" #include "Connect.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" #include "EngineStore.hpp" @@ -92,13 +92,13 @@ Connect::pre_process() return; } - if (!ConnectionImpl::can_connect(_src_output_port, _dst_input_port)) { + if (!EdgeImpl::can_connect(_src_output_port, _dst_input_port)) { _status = TYPE_MISMATCH; Event::pre_process(); return; } - // Connection to a patch port from inside the patch + // Edge to a patch port from inside the patch if (src_node->parent_patch() != dst_node->parent_patch()) { assert(src_node->parent() == dst_node || dst_node->parent() == src_node); if (src_node->parent() == dst_node) @@ -106,30 +106,30 @@ Connect::pre_process() else _patch = dynamic_cast(src_node); - // Connection from a patch input to a patch output (pass through) + // Edge from a patch input to a patch output (pass through) } else if (src_node == dst_node && dynamic_cast(src_node)) { _patch = dynamic_cast(src_node); - // Normal connection between nodes with the same parent + // Normal edge between nodes with the same parent } else { _patch = src_node->parent_patch(); } - if (_patch->has_connection(_src_output_port, _dst_input_port)) { + if (_patch->has_edge(_src_output_port, _dst_input_port)) { _status = EXISTS; Event::pre_process(); return; } - _connection = SharedPtr( - new ConnectionImpl(_src_output_port, _dst_input_port)); + _edge = SharedPtr( + new EdgeImpl(_src_output_port, _dst_input_port)); rlock.release(); { Glib::RWLock::ReaderLock wlock(_engine.engine_store()->lock()); - /* Need to be careful about patch port connections here and adding a + /* Need to be careful about patch port edges here and adding a node's parent as a dependant/provider, or adding a patch as its own provider... */ @@ -138,8 +138,8 @@ Connect::pre_process() src_node->dependants().push_back(dst_node); } - _patch->add_connection(_connection); - _dst_input_port->increment_num_connections(); + _patch->add_edge(_edge); + _dst_input_port->increment_num_edges(); } _buffers = new Raul::Array(_dst_input_port->poly()); @@ -159,7 +159,7 @@ Connect::execute(ProcessContext& context) if (_status == SUCCESS) { // This must be inserted here, since they're actually used by the audio thread - _dst_input_port->add_connection(_connection.get()); + _dst_input_port->add_edge(_edge.get()); assert(_buffers); _engine.maid()->push(_dst_input_port->set_buffers(_buffers)); _dst_input_port->connect_buffers(); diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp index d3c2bea6..9d807503 100644 --- a/src/server/events/Connect.hpp +++ b/src/server/events/Connect.hpp @@ -33,7 +33,7 @@ namespace Server { class PatchImpl; class NodeImpl; -class ConnectionImpl; +class EdgeImpl; class PortImpl; class InputPort; class OutputPort; @@ -41,7 +41,7 @@ class CompiledPatch; namespace Events { -/** Make a Connection between two Ports. +/** Make an Edge between two Ports. * * \ingroup engine */ @@ -69,7 +69,7 @@ private: CompiledPatch* _compiled_patch; ///< New process order for Patch - SharedPtr _connection; + SharedPtr _edge; Raul::Array* _buffers; }; diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index e7ed572f..6d3ae31f 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -22,7 +22,7 @@ #include "AudioBuffer.hpp" #include "ClientBroadcaster.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" #include "EngineStore.hpp" @@ -63,7 +63,7 @@ Disconnect::Impl::Impl(Engine& e, , _src_output_port(s) , _dst_input_port(d) , _patch(patch) - , _connection(patch->remove_connection(_src_output_port, _dst_input_port)) + , _edge(patch->remove_edge(_src_output_port, _dst_input_port)) , _buffers(NULL) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); @@ -87,9 +87,9 @@ Disconnect::Impl::Impl(Engine& e, } } - _dst_input_port->decrement_num_connections(); + _dst_input_port->decrement_num_edges(); - if (_dst_input_port->num_connections() == 0) { + if (_dst_input_port->num_edges() == 0) { _buffers = new Raul::Array(_dst_input_port->poly()); _dst_input_port->get_buffers(*_engine.buffer_factory(), _buffers, _dst_input_port->poly()); @@ -132,27 +132,25 @@ Disconnect::pre_process() NodeImpl* const src_node = _tail->parent_node(); NodeImpl* const dst_node = _head->parent_node(); - // Connection to a patch port from inside the patch if (src_node->parent_patch() != dst_node->parent_patch()) { - + // Edge 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) + if (src_node->parent() == dst_node) { _patch = dynamic_cast(dst_node); - else + } else { _patch = dynamic_cast(src_node); - - // Connection from a patch input to a patch output (pass through) + } } else if (src_node == dst_node && dynamic_cast(src_node)) { + // Edge from a patch input to a patch output (pass through) _patch = dynamic_cast(src_node); - - // Normal connection between nodes with the same parent } else { + // Normal edge between nodes with the same parent _patch = src_node->parent_patch(); } assert(_patch); - if (!_patch->has_connection(_tail, _head)) { + if (!_patch->has_edge(_tail, _head)) { _status = NOT_FOUND; Event::pre_process(); return; @@ -180,9 +178,9 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers) { ThreadManager::assert_thread(THREAD_PROCESS); - ConnectionImpl* const port_connection - = _dst_input_port->remove_connection(context, _src_output_port); - if (!port_connection) { + EdgeImpl* const port_edge = + _dst_input_port->remove_edge(context, _src_output_port); + if (!port_edge) { return false; } @@ -198,8 +196,8 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers) _dst_input_port->recycle_buffers(); } - assert(_connection); - assert(port_connection == _connection.get()); + assert(_edge); + assert(port_edge == _edge.get()); return true; } diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index cf4e6f18..8f955311 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -38,7 +38,7 @@ class PortImpl; namespace Events { -/** Make a Connection between two Ports. +/** Remove an Edge between two Ports. * * \ingroup engine */ @@ -68,12 +68,12 @@ public: InputPort* head() { return _dst_input_port; } private: - Engine& _engine; - OutputPort* _src_output_port; - InputPort* _dst_input_port; - PatchImpl* _patch; - SharedPtr _connection; - Raul::Array* _buffers; + Engine& _engine; + OutputPort* _src_output_port; + InputPort* _dst_input_port; + PatchImpl* _patch; + SharedPtr _edge; + Raul::Array* _buffers; }; private: diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index f869c5d3..04527212 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -24,7 +24,7 @@ #include "raul/Path.hpp" #include "ClientBroadcaster.hpp" -#include "ConnectionImpl.hpp" +#include "EdgeImpl.hpp" #include "Engine.hpp" #include "EngineStore.hpp" #include "InputPort.hpp" @@ -116,11 +116,11 @@ DisconnectAll::pre_process() assert((_node || _port) && !(_node && _port)); } - // Find set of connections to remove - std::set to_remove; - for (Patch::Connections::const_iterator i = _parent->connections().begin(); - i != _parent->connections().end(); ++i) { - ConnectionImpl* const c = (ConnectionImpl*)i->second.get(); + // Find set of edges to remove + std::set to_remove; + for (Patch::Edges::const_iterator i = _parent->edges().begin(); + i != _parent->edges().end(); ++i) { + EdgeImpl* const c = (EdgeImpl*)i->second.get(); if (_node) { if (c->tail()->parent_node() == _node || c->head()->parent_node() == _node) { @@ -134,8 +134,8 @@ DisconnectAll::pre_process() } } - // Create disconnect events (which erases from _parent->connections()) - for (std::set::const_iterator i = to_remove.begin(); + // Create disconnect events (which erases from _parent->edges()) + for (std::set::const_iterator i = to_remove.begin(); i != to_remove.end(); ++i) { _impls.push_back(new Disconnect::Impl( _engine, _parent, diff --git a/src/server/wscript b/src/server/wscript index a043c0fa..1d3d8b56 100644 --- a/src/server/wscript +++ b/src/server/wscript @@ -7,9 +7,9 @@ def build(bld): Buffer.cpp BufferFactory.cpp ClientBroadcaster.cpp - ConnectionImpl.cpp ControlBindings.cpp DuplexPort.cpp + EdgeImpl.cpp Engine.cpp EngineStore.cpp Event.cpp diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp index c79181ff..b3f005f1 100644 --- a/src/shared/Builder.cpp +++ b/src/shared/Builder.cpp @@ -14,7 +14,7 @@ along with Ingen. If not, see . */ -#include "ingen/Connection.hpp" +#include "ingen/Edge.hpp" #include "ingen/Interface.hpp" #include "ingen/Node.hpp" #include "ingen/Patch.hpp" @@ -51,10 +51,10 @@ Builder::build(SharedPtr object) } build_object(object); - /*for (Patch::Connections::const_iterator i = patch->connections().begin(); - i != patch->connections().end(); ++i) { - _interface.connect((*i)->src_port_path(), (*i)->dst_port_path()); - }*/ + /*for (Patch::Edges::const_iterator i = patch->edges().begin(); + i != patch->edges().end(); ++i) { + _interface.connect((*i)->src_port_path(), (*i)->dst_port_path()); + }*/ return; } @@ -82,8 +82,8 @@ Builder::connect(SharedPtr object) { SharedPtr patch = PtrCast(object); if (patch) { - for (Patch::Connections::const_iterator i = patch->connections().begin(); - i != patch->connections().end(); ++i) { + for (Patch::Edges::const_iterator i = patch->edges().begin(); + i != patch->edges().end(); ++i) { _interface.connect(i->second->tail_path(), i->second->head_path()); } return; diff --git a/src/shared/World.cpp b/src/shared/World.cpp index 9873246f..d5c29e9c 100644 --- a/src/shared/World.cpp +++ b/src/shared/World.cpp @@ -104,8 +104,8 @@ public: , argv(a_argv) , lv2_features(NULL) , rdf_world(new Sord::World()) - , forge(new Ingen::Forge(*uri_map)) , uri_map(new Ingen::Shared::URIMap(map, unmap)) + , forge(new Ingen::Forge(*uri_map)) , uris(new Shared::URIs(*forge, uri_map)) , lilv_world(lilv_world_new()) { @@ -144,9 +144,9 @@ public: delete rdf_world; delete lv2_features; + delete uris; delete forge; delete uri_map; - delete uris; } typedef std::map< const std::string, SharedPtr > Modules; @@ -164,8 +164,8 @@ public: Shared::Configuration conf; LV2Features* lv2_features; Sord::World* rdf_world; - Ingen::Forge* forge; URIMap* uri_map; + Ingen::Forge* forge; URIs* uris; SharedPtr interface; SharedPtr engine; -- cgit v1.2.1