From 79275fc579c0dbe1ce4ca109edb95f2c1e0802a5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 29 Dec 2012 20:34:32 +0000 Subject: "edge" => "arc". git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4897 a436a847-0d15-0410-975c-d299462d15a1 --- src/AtomReader.cpp | 8 +-- src/AtomWriter.cpp | 18 +++--- src/Builder.cpp | 6 +- src/URIs.cpp | 4 +- src/client/ClientStore.cpp | 36 ++++++------ src/client/GraphModel.cpp | 93 ++++++++++++++++--------------- src/gui/Arc.cpp | 33 +++++++++++ src/gui/Arc.hpp | 53 ++++++++++++++++++ src/gui/Edge.cpp | 33 ----------- src/gui/Edge.hpp | 53 ------------------ src/gui/GraphCanvas.cpp | 56 +++++++++---------- src/gui/GraphCanvas.hpp | 6 +- src/gui/wscript | 2 +- src/serialisation/Parser.cpp | 54 ++++++++++-------- src/serialisation/Serialiser.cpp | 42 +++++++------- src/server/ArcImpl.cpp | 107 ++++++++++++++++++++++++++++++++++++ src/server/ArcImpl.hpp | 86 +++++++++++++++++++++++++++++ src/server/EdgeImpl.cpp | 107 ------------------------------------ src/server/EdgeImpl.hpp | 86 ----------------------------- src/server/GraphImpl.cpp | 30 +++++----- src/server/GraphImpl.hpp | 12 ++-- src/server/InputPort.cpp | 82 +++++++++++++-------------- src/server/InputPort.hpp | 28 +++++----- src/server/events/Connect.cpp | 22 ++++---- src/server/events/Connect.hpp | 8 +-- src/server/events/Disconnect.cpp | 22 ++++---- src/server/events/Disconnect.hpp | 4 +- src/server/events/DisconnectAll.cpp | 16 +++--- src/server/events/Get.cpp | 6 +- src/server/wscript | 2 +- 30 files changed, 561 insertions(+), 554 deletions(-) create mode 100644 src/gui/Arc.cpp create mode 100644 src/gui/Arc.hpp delete mode 100644 src/gui/Edge.cpp delete mode 100644 src/gui/Edge.hpp create mode 100644 src/server/ArcImpl.cpp create mode 100644 src/server/ArcImpl.hpp delete mode 100644 src/server/EdgeImpl.cpp delete mode 100644 src/server/EdgeImpl.hpp (limited to 'src') diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp index c12ce3d7..63f493a7 100644 --- a/src/AtomReader.cpp +++ b/src/AtomReader.cpp @@ -138,7 +138,7 @@ AtomReader::write(const LV2_Atom* msg) if (subject_uri && !body) { _iface.del(Raul::URI(subject_uri)); return true; - } else if (body && body->body.otype == _uris.ingen_Edge) { + } else if (body && body->body.otype == _uris.ingen_Arc) { const LV2_Atom* tail = NULL; const LV2_Atom* head = NULL; const LV2_Atom* incidentTo = NULL; @@ -172,7 +172,7 @@ AtomReader::write(const LV2_Atom* msg) return false; } - if (body->body.otype == _uris.ingen_Edge) { + if (body->body.otype == _uris.ingen_Arc) { LV2_Atom* tail = NULL; LV2_Atom* head = NULL; lv2_atom_object_get(body, @@ -180,7 +180,7 @@ AtomReader::write(const LV2_Atom* msg) (LV2_URID)_uris.ingen_head, &head, NULL); if (!tail || !head) { - _log.warn("Edge has no tail or head\n"); + _log.warn("Arc has no tail or head\n"); return false; } @@ -189,7 +189,7 @@ AtomReader::write(const LV2_Atom* msg) if (tail_path && head_path) { _iface.connect(*tail_path, *head_path); } else { - _log.warn(Raul::fmt("Edge %1% => %2% has non-path tail or head\n") + _log.warn(Raul::fmt("Arc %1% => %2% has non-path tail or head\n") % atom_to_uri(tail) % atom_to_uri(head)); } } else { diff --git a/src/AtomWriter.cpp b/src/AtomWriter.cpp index f102c8a8..05e5d64d 100644 --- a/src/AtomWriter.cpp +++ b/src/AtomWriter.cpp @@ -108,15 +108,15 @@ AtomWriter::forge_properties(const Resource::Properties& properties) } void -AtomWriter::forge_edge(const Raul::Path& tail, const Raul::Path& head) +AtomWriter::forge_arc(const Raul::Path& tail, const Raul::Path& head) { - LV2_Atom_Forge_Frame edge; - lv2_atom_forge_blank(&_forge, &edge, 0, _uris.ingen_Edge); + LV2_Atom_Forge_Frame arc; + lv2_atom_forge_blank(&_forge, &arc, 0, _uris.ingen_Arc); lv2_atom_forge_property_head(&_forge, _uris.ingen_tail, 0); forge_uri(Node::path_to_uri(tail)); lv2_atom_forge_property_head(&_forge, _uris.ingen_head, 0); forge_uri(Node::path_to_uri(head)); - lv2_atom_forge_pop(&_forge, &edge); + lv2_atom_forge_pop(&_forge, &arc); } void @@ -195,7 +195,7 @@ AtomWriter::connect(const Raul::Path& tail, lv2_atom_forge_property_head(&_forge, _uris.patch_subject, 0); forge_uri(Node::path_to_uri(Raul::Path::lca(tail, head))); lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); - forge_edge(tail, head); + forge_arc(tail, head); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); } @@ -207,7 +207,7 @@ AtomWriter::disconnect(const Raul::Path& tail, LV2_Atom_Forge_Frame msg; lv2_atom_forge_blank(&_forge, &msg, next_id(), _uris.patch_Delete); lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); - forge_edge(tail, head); + forge_arc(tail, head); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); } @@ -223,11 +223,11 @@ AtomWriter::disconnect_all(const Raul::Path& graph, forge_uri(Node::path_to_uri(graph)); lv2_atom_forge_property_head(&_forge, _uris.patch_body, 0); - LV2_Atom_Forge_Frame edge; - lv2_atom_forge_blank(&_forge, &edge, 0, _uris.ingen_Edge); + LV2_Atom_Forge_Frame arc; + lv2_atom_forge_blank(&_forge, &arc, 0, _uris.ingen_Arc); lv2_atom_forge_property_head(&_forge, _uris.ingen_incidentTo, 0); forge_uri(Node::path_to_uri(path)); - lv2_atom_forge_pop(&_forge, &edge); + lv2_atom_forge_pop(&_forge, &arc); lv2_atom_forge_pop(&_forge, &msg); finish_msg(); diff --git a/src/Builder.cpp b/src/Builder.cpp index 023f22cd..fc7d855d 100644 --- a/src/Builder.cpp +++ b/src/Builder.cpp @@ -14,8 +14,8 @@ along with Ingen. If not, see . */ +#include "ingen/Arc.hpp" #include "ingen/Builder.hpp" -#include "ingen/Edge.hpp" #include "ingen/Interface.hpp" #include "ingen/Node.hpp" #include "ingen/URIs.hpp" @@ -42,8 +42,8 @@ void Builder::connect(SharedPtr object) { if (object->graph_type() == Node::GRAPH) { - for (Node::Edges::const_iterator i = object->edges().begin(); - i != object->edges().end(); ++i) { + for (Node::Arcs::const_iterator i = object->arcs().begin(); + i != object->arcs().end(); ++i) { _interface.connect(i->second->tail_path(), i->second->head_path()); } return; diff --git a/src/URIs.cpp b/src/URIs.cpp index 0fd39849..8dbf87a6 100644 --- a/src/URIs.cpp +++ b/src/URIs.cpp @@ -61,18 +61,18 @@ URIs::URIs(Forge& f, URIMap* map) , bufsz_minBlockLength (forge, map, LV2_BUF_SIZE__minBlockLength) , bufsz_sequenceSize (forge, map, LV2_BUF_SIZE__sequenceSize) , doap_name (forge, map, "http://usefulinc.com/ns/doap#name") + , ingen_Arc (forge, map, NS_INGEN "Arc") , ingen_Block (forge, map, NS_INGEN "Block") - , ingen_Edge (forge, map, NS_INGEN "Edge") , ingen_Graph (forge, map, NS_INGEN "Graph") , ingen_Internal (forge, map, NS_INGEN "Internal") , ingen_activity (forge, map, NS_INGEN "activity") + , ingen_arc (forge, map, NS_INGEN "arc") , ingen_block (forge, map, NS_INGEN "block") , ingen_broadcast (forge, map, NS_INGEN "broadcast") , ingen_canvasX (forge, map, NS_INGEN "canvasX") , ingen_canvasY (forge, map, NS_INGEN "canvasY") , ingen_controlBinding (forge, map, NS_INGEN "controlBinding") , ingen_document (forge, map, NS_INGEN "document") - , ingen_edge (forge, map, NS_INGEN "edge") , ingen_enabled (forge, map, NS_INGEN "enabled") , ingen_engine (forge, map, NS_INGEN "engine") , ingen_head (forge, map, NS_INGEN "head") diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index fe79336b..6b2c1540 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -15,11 +15,11 @@ */ #include "ingen/Log.hpp" -#include "ingen/client/ClientStore.hpp" -#include "ingen/client/EdgeModel.hpp" +#include "ingen/client/ArcModel.hpp" #include "ingen/client/BlockModel.hpp" -#include "ingen/client/ObjectModel.hpp" +#include "ingen/client/ClientStore.hpp" #include "ingen/client/GraphModel.hpp" +#include "ingen/client/ObjectModel.hpp" #include "ingen/client/PluginModel.hpp" #include "ingen/client/PortModel.hpp" #include "ingen/client/SigClientInterface.hpp" @@ -391,7 +391,7 @@ ClientStore::connection_graph(const Raul::Path& tail_path, graph = PtrCast(_object(tail_path.parent().parent())); if (!graph) - _log.error(Raul::fmt("Unable to find graph for edge %1% => %2%\n") + _log.error(Raul::fmt("Unable to find graph for arc %1% => %2%\n") % tail_path % head_path); return graph; @@ -406,12 +406,12 @@ ClientStore::attempt_connection(const Raul::Path& tail_path, if (tail && head) { SharedPtr graph = connection_graph(tail_path, head_path); - SharedPtr cm(new EdgeModel(tail, head)); + SharedPtr arc(new ArcModel(tail, head)); tail->connected_to(head); head->connected_to(tail); - graph->add_edge(cm); + graph->add_arc(arc); return true; } else { _log.warn(Raul::fmt("Failed to connect %1% => %2%\n") @@ -442,7 +442,7 @@ ClientStore::disconnect(const Raul::Path& src_path, SharedPtr graph = connection_graph(src_path, dst_path); if (graph) - graph->remove_edge(tail.get(), head.get()); + graph->remove_arc(tail.get(), head.get()); } void @@ -458,17 +458,17 @@ ClientStore::disconnect_all(const Raul::Path& parent_graph, return; } - const GraphModel::Edges edges = graph->edges(); - for (GraphModel::Edges::const_iterator i = edges.begin(); - i != edges.end(); ++i) { - SharedPtr c = PtrCast(i->second); - if (c->tail()->parent() == object - || c->head()->parent() == object - || c->tail()->path() == path - || c->head()->path() == path) { - c->tail()->disconnected_from(c->head()); - c->head()->disconnected_from(c->tail()); - graph->remove_edge(c->tail().get(), c->head().get()); + const GraphModel::Arcs arcs = graph->arcs(); + for (GraphModel::Arcs::const_iterator i = arcs.begin(); + i != arcs.end(); ++i) { + SharedPtr arc = PtrCast(i->second); + if (arc->tail()->parent() == object + || arc->head()->parent() == object + || arc->tail()->path() == path + || arc->head()->path() == path) { + arc->tail()->disconnected_from(arc->head()); + arc->head()->disconnected_from(arc->tail()); + graph->remove_arc(arc->tail().get(), arc->head().get()); } } } diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index fe838725..98155138 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -17,9 +17,9 @@ #include #include "ingen/URIs.hpp" +#include "ingen/client/ArcModel.hpp" #include "ingen/client/BlockModel.hpp" #include "ingen/client/ClientStore.hpp" -#include "ingen/client/EdgeModel.hpp" #include "ingen/client/GraphModel.hpp" using namespace std; @@ -52,19 +52,17 @@ GraphModel::remove_child(SharedPtr o) // Remove any connections which referred to this object, // since they can't possibly exist anymore - for (Edges::iterator j = _edges.begin(); j != _edges.end();) { - Edges::iterator next = j; + for (Arcs::iterator j = _arcs.begin(); j != _arcs.end();) { + Arcs::iterator next = j; ++next; - SharedPtr cm = PtrCast(j->second); - assert(cm); - - if (cm->tail_path().parent() == o->path() - || cm->tail_path() == o->path() - || cm->head_path().parent() == o->path() - || cm->head_path() == o->path()) { - _signal_removed_edge.emit(cm); - _edges.erase(j); // cuts our reference + SharedPtr arc = PtrCast(j->second); + if (arc->tail_path().parent() == o->path() + || arc->tail_path() == o->path() + || arc->head_path().parent() == o->path() + || arc->head_path() == o->path()) { + _signal_removed_arc.emit(arc); + _arcs.erase(j); // cuts our reference } j = next; } @@ -84,67 +82,68 @@ GraphModel::remove_child(SharedPtr o) void GraphModel::clear() { - _edges.clear(); + _arcs.clear(); BlockModel::clear(); - assert(_edges.empty()); + assert(_arcs.empty()); assert(_ports.empty()); } -SharedPtr -GraphModel::get_edge(const Node* tail, const Node* head) +SharedPtr +GraphModel::get_arc(const Node* tail, const Node* head) { - Edges::iterator i = _edges.find(make_pair(tail, head)); - if (i != _edges.end()) - return PtrCast(i->second); + Arcs::iterator i = _arcs.find(make_pair(tail, head)); + if (i != _arcs.end()) + return PtrCast(i->second); else - return SharedPtr(); + return SharedPtr(); } /** Add a connection to this graph. * - * A reference to @a cm is taken, released on deletion or removal. - * If @a cm only contains paths (not pointers to the actual ports), the ports + * A reference to @p arc is taken, released on deletion or removal. + * If @p arc only contains paths (not pointers to the actual ports), the ports * will be found and set. The ports referred to not existing as children of * this graph is a fatal error. */ void -GraphModel::add_edge(SharedPtr cm) +GraphModel::add_arc(SharedPtr arc) { // Store should have 'resolved' the connection already - assert(cm); - assert(cm->tail()); - assert(cm->head()); - assert(cm->tail()->parent()); - assert(cm->head()->parent()); - assert(cm->tail_path() != cm->head_path()); - assert(cm->tail()->parent().get() == this - || cm->tail()->parent()->parent().get() == this); - assert(cm->head()->parent().get() == this - || cm->head()->parent()->parent().get() == this); - - SharedPtr existing = get_edge( - cm->tail().get(), cm->head().get()); + assert(arc); + assert(arc->tail()); + assert(arc->head()); + assert(arc->tail()->parent()); + assert(arc->head()->parent()); + assert(arc->tail_path() != arc->head_path()); + assert(arc->tail()->parent().get() == this + || arc->tail()->parent()->parent().get() == this); + assert(arc->head()->parent().get() == this + || arc->head()->parent()->parent().get() == this); + + SharedPtr existing = get_arc( + arc->tail().get(), arc->head().get()); if (existing) { - assert(cm->tail() == existing->tail()); - assert(cm->head() == existing->head()); + assert(arc->tail() == existing->tail()); + assert(arc->head() == existing->head()); } else { - _edges.insert(make_pair(make_pair(cm->tail().get(), - cm->head().get()), cm)); - _signal_new_edge.emit(cm); + _arcs.insert(make_pair(make_pair(arc->tail().get(), + arc->head().get()), + arc)); + _signal_new_arc.emit(arc); } } void -GraphModel::remove_edge(const Node* tail, const Node* head) +GraphModel::remove_arc(const Node* tail, const Node* head) { - Edges::iterator i = _edges.find(make_pair(tail, head)); - if (i != _edges.end()) { - SharedPtr c = PtrCast(i->second); - _signal_removed_edge.emit(c); - _edges.erase(i); + Arcs::iterator i = _arcs.find(make_pair(tail, head)); + if (i != _arcs.end()) { + SharedPtr arc = PtrCast(i->second); + _signal_removed_arc.emit(arc); + _arcs.erase(i); } } diff --git a/src/gui/Arc.cpp b/src/gui/Arc.cpp new file mode 100644 index 00000000..b75f30ae --- /dev/null +++ b/src/gui/Arc.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 "Arc.hpp" + +namespace Ingen { +namespace GUI { + +Arc::Arc(Ganv::Canvas& canvas, + boost::shared_ptr model, + Ganv::Node* src, + Ganv::Node* dst, + uint32_t color) + : Ganv::Edge(canvas, src, dst, color) + , _arc_model(model) +{ +} + +} // namespace GUI +} // namespace Ingen diff --git a/src/gui/Arc.hpp b/src/gui/Arc.hpp new file mode 100644 index 00000000..df6dfbfb --- /dev/null +++ b/src/gui/Arc.hpp @@ -0,0 +1,53 @@ +/* + 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_ARC_HPP +#define INGEN_GUI_ARC_HPP + +#include + +#include "ganv/Edge.hpp" +#include "raul/SharedPtr.hpp" + +namespace Ingen { + +namespace Client { class ArcModel; } + +namespace GUI { + +/** An Arc (directed edge) in a Graph. + * + * \ingroup GUI + */ +class Arc : public Ganv::Edge +{ +public: + Arc(Ganv::Canvas& canvas, + boost::shared_ptr model, + Ganv::Node* src, + Ganv::Node* dst, + uint32_t color); + + SharedPtr model() const { return _arc_model; } + +private: + SharedPtr _arc_model; +}; + +} // namespace GUI +} // namespace Ingen + +#endif // INGEN_GUI_EDGE_HPP diff --git a/src/gui/Edge.cpp b/src/gui/Edge.cpp deleted file mode 100644 index 9916959e..00000000 --- a/src/gui/Edge.cpp +++ /dev/null @@ -1,33 +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 "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 deleted file mode 100644 index cf1dafe8..00000000 --- a/src/gui/Edge.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_EDGE_HPP -#define INGEN_GUI_EDGE_HPP - -#include - -#include "ganv/Edge.hpp" -#include "raul/SharedPtr.hpp" - -namespace Ingen { - -namespace Client { class EdgeModel; } - -namespace GUI { - -/** An Edge in a Graph. - * - * \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/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp index 86b21cc2..d35e678f 100644 --- a/src/gui/GraphCanvas.cpp +++ b/src/gui/GraphCanvas.cpp @@ -38,7 +38,7 @@ #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "App.hpp" -#include "Edge.hpp" +#include "Arc.hpp" #include "GraphCanvas.hpp" #include "GraphPortModule.hpp" #include "GraphWindow.hpp" @@ -142,9 +142,9 @@ GraphCanvas::GraphCanvas(App& app, sigc::mem_fun(this, &GraphCanvas::add_port)); _graph->signal_removed_port().connect( sigc::mem_fun(this, &GraphCanvas::remove_port)); - _graph->signal_new_edge().connect( + _graph->signal_new_arc().connect( sigc::mem_fun(this, &GraphCanvas::connection)); - _graph->signal_removed_edge().connect( + _graph->signal_removed_arc().connect( sigc::mem_fun(this, &GraphCanvas::disconnection)); _app.store()->signal_new_plugin().connect( @@ -321,10 +321,10 @@ GraphCanvas::build() add_port(*i); } - // Create edges - for (GraphModel::Edges::const_iterator i = _graph->edges().begin(); - i != _graph->edges().end(); ++i) { - connection(PtrCast(i->second)); + // Create arcs + for (GraphModel::Arcs::const_iterator i = _graph->arcs().begin(); + i != _graph->arcs().end(); ++i) { + connection(PtrCast(i->second)); } } @@ -500,30 +500,30 @@ GraphCanvas::get_port_view(SharedPtr port) } void -GraphCanvas::connection(SharedPtr cm) +GraphCanvas::connection(SharedPtr arc) { - Ganv::Port* const tail = get_port_view(cm->tail()); - Ganv::Port* const head = get_port_view(cm->head()); + Ganv::Port* const tail = get_port_view(arc->tail()); + Ganv::Port* const head = get_port_view(arc->head()); if (tail && head) { - new GUI::Edge(*this, cm, tail, head, tail->get_fill_color()); + new GUI::Arc(*this, arc, tail, head, tail->get_fill_color()); } else { _app.log().error(Raul::fmt("Unable to find ports to connect %1% => %2%\n") - % cm->tail_path() % cm->head_path()); + % arc->tail_path() % arc->head_path()); } } void -GraphCanvas::disconnection(SharedPtr cm) +GraphCanvas::disconnection(SharedPtr arc) { - Ganv::Port* const src = get_port_view(cm->tail()); - Ganv::Port* const dst = get_port_view(cm->head()); + Ganv::Port* const src = get_port_view(arc->tail()); + Ganv::Port* const dst = get_port_view(arc->head()); if (src && dst) { remove_edge(src, dst); } else { _app.log().error(Raul::fmt("Unable to find ports to disconnect %1% => %2%\n") - % cm->tail_path() % cm->head_path()); + % arc->tail_path() % arc->head_path()); } } @@ -647,13 +647,13 @@ destroy_node(GanvNode* node, void* data) } static void -destroy_edge(GanvEdge* edge, void* data) +destroy_arc(GanvEdge* arc, void* data) { - App* app = (App*)data; - Ganv::Edge* edgemm = Glib::wrap(edge); + App* app = (App*)data; + Ganv::Edge* arcmm = Glib::wrap(arc); - Port* tail = dynamic_cast(edgemm->get_tail()); - Port* head = dynamic_cast(edgemm->get_head()); + Port* tail = dynamic_cast(arcmm->get_tail()); + Port* head = dynamic_cast(arcmm->get_head()); app->interface()->disconnect(tail->model()->path(), head->model()->path()); } @@ -661,7 +661,7 @@ void GraphCanvas::destroy_selection() { for_each_selected_node(destroy_node, &_app); - for_each_selected_edge(destroy_edge, &_app); + for_each_selected_edge(destroy_arc, &_app); } static void @@ -686,16 +686,16 @@ serialise_node(GanvNode* node, void* data) } static void -serialise_edge(GanvEdge* edge, void* data) +serialise_arc(GanvEdge* arc, void* data) { Serialisation::Serialiser* serialiser = (Serialisation::Serialiser*)data; - if (!GANV_IS_EDGE(edge)) { + if (!GANV_IS_EDGE(arc)) { return; } - GUI::Edge* gedge = dynamic_cast(Glib::wrap(GANV_EDGE(edge))); - if (gedge) { - serialiser->serialise_edge(Sord::Node(), gedge->model()); + GUI::Arc* garc = dynamic_cast(Glib::wrap(GANV_EDGE(arc))); + if (garc) { + serialiser->serialise_arc(Sord::Node(), garc->model()); } } @@ -707,7 +707,7 @@ GraphCanvas::copy_selection() serialiser.start_to_string(_graph->path(), base_uri); for_each_selected_node(serialise_node, &serialiser); - for_each_selected_edge(serialise_edge, &serialiser); + for_each_selected_edge(serialise_arc, &serialiser); const std::string result = serialiser.finish(); _paste_count = 0; diff --git a/src/gui/GraphCanvas.hpp b/src/gui/GraphCanvas.hpp index 3fb00619..1d04e582 100644 --- a/src/gui/GraphCanvas.hpp +++ b/src/gui/GraphCanvas.hpp @@ -32,7 +32,7 @@ #include "NodeModule.hpp" #include "ingen/Node.hpp" -#include "ingen/client/EdgeModel.hpp" +#include "ingen/client/ArcModel.hpp" namespace Ingen { @@ -68,8 +68,8 @@ public: void remove_block(SharedPtr bm); void add_port(SharedPtr pm); void remove_port(SharedPtr pm); - void connection(SharedPtr cm); - void disconnection(SharedPtr cm); + void connection(SharedPtr am); + void disconnection(SharedPtr am); void get_new_module_location(double& x, double& y); diff --git a/src/gui/wscript b/src/gui/wscript index 4732e56f..1f0a567f 100644 --- a/src/gui/wscript +++ b/src/gui/wscript @@ -28,9 +28,9 @@ def build(bld): obj.source = ''' App.cpp + Arc.cpp BreadCrumbs.cpp ConnectWindow.cpp - Edge.cpp GraphBox.cpp GraphCanvas.cpp GraphPortModule.cpp diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 0c15b0b4..3a283641 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -87,6 +87,7 @@ skip_property(const Sord::Node& predicate) { return (predicate.to_string() == "http://drobilla.net/ns/ingen#node" || predicate.to_string() == "http://drobilla.net/ns/ingen#edge" + || predicate.to_string() == "http://drobilla.net/ns/ingen#arc" || predicate.to_string() == LV2_CORE__port); } @@ -207,7 +208,7 @@ parse_properties( boost::optional data = boost::optional()); static bool -parse_edges( +parse_arcs( World* world, Interface* target, Sord::Model& model, @@ -378,17 +379,17 @@ parse_graph(Ingen::World* world, i->second.second); } - parse_edges(world, target, model, subject_node, graph_path); + parse_arcs(world, target, model, subject_node, graph_path); return graph_path; } static bool -parse_edge(Ingen::World* world, - Ingen::Interface* target, - Sord::Model& model, - const Sord::Node& subject, - const Raul::Path& graph) +parse_arc(Ingen::World* world, + Ingen::Interface* target, + Sord::Model& model, + const Sord::Node& subject, + const Raul::Path& graph) { URIs& uris = world->uris(); @@ -402,32 +403,32 @@ parse_edge(Ingen::World* world, const Glib::ustring& base_uri = model.base_uri().to_string(); if (t.end()) { - world->log().error("Edge has no tail"); + world->log().error("Arc has no tail"); return false; } else if (h.end()) { - world->log().error("Edge has no head"); + world->log().error("Arc has no head"); return false; } const std::string tail_str = relative_uri( base_uri, t.get_object().to_string(), true); if (!Raul::Path::is_valid(tail_str)) { - world->log().error("Edge tail has invalid URI"); + world->log().error("Arc tail has invalid URI"); return false; } const std::string head_str = relative_uri( base_uri, h.get_object().to_string(), true); if (!Raul::Path::is_valid(head_str)) { - world->log().error("Edge head has invalid URI"); + world->log().error("Arc head has invalid URI"); return false; } if (!(++t).end()) { - world->log().error("Edge has multiple tails"); + world->log().error("Arc has multiple tails"); return false; } else if (!(++h).end()) { - world->log().error("Edge has multiple heads"); + world->log().error("Arc has multiple heads"); return false; } @@ -438,17 +439,24 @@ parse_edge(Ingen::World* world, } static bool -parse_edges(Ingen::World* world, - Ingen::Interface* target, - Sord::Model& model, - const Sord::Node& subject, - const Raul::Path& graph) +parse_arcs(Ingen::World* world, + Ingen::Interface* target, + Sord::Model& model, + const Sord::Node& subject, + const Raul::Path& graph) { - const Sord::URI ingen_edge(*world->rdf_world(), world->uris().ingen_edge); + const Sord::URI ingen_arc(*world->rdf_world(), world->uris().ingen_arc); const Sord::Node nil; + for (Sord::Iter i = model.find(subject, ingen_arc, nil); !i.end(); ++i) { + parse_arc(world, target, model, i.get_object(), graph); + } + + // Backwards compatibility, support ingen:edge predicate + const Sord::URI ingen_edge(*world->rdf_world(), + "http://drobilla.net/ns/ingen#edge"); for (Sord::Iter i = model.find(subject, ingen_edge, nil); !i.end(); ++i) { - parse_edge(world, target, model, i.get_object(), graph); + parse_arc(world, target, model, i.get_object(), graph); } return true; @@ -487,7 +495,7 @@ parse(Ingen::World* world, const Sord::URI graph_class (*world->rdf_world(), uris.ingen_Graph); const Sord::URI block_class (*world->rdf_world(), uris.ingen_Block); - const Sord::URI edge_class (*world->rdf_world(), uris.ingen_Edge); + const Sord::URI arc_class (*world->rdf_world(), uris.ingen_Arc); const Sord::URI internal_class(*world->rdf_world(), uris.ingen_Internal); const Sord::URI in_port_class (*world->rdf_world(), LV2_CORE__InputPort); const Sord::URI out_port_class(*world->rdf_world(), LV2_CORE__OutputPort); @@ -534,9 +542,9 @@ parse(Ingen::World* world, parse_properties( world, target, model, s, Node::path_to_uri(path), data); ret = path; - } else if (types.find(edge_class) != types.end()) { + } else if (types.find(arc_class) != types.end()) { Raul::Path parent_path(parent ? parent.get() : Raul::Path("/")); - parse_edge(world, target, model, s, parent_path); + parse_arc(world, target, model, s, parent_path); } else { world->log().error("Subject has no known types\n"); } diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index e3781a01..85ecbfb4 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -26,7 +26,7 @@ #include #include -#include "ingen/Edge.hpp" +#include "ingen/Arc.hpp" #include "ingen/Interface.hpp" #include "ingen/Log.hpp" #include "ingen/Node.hpp" @@ -89,8 +89,8 @@ struct Serialiser::Impl { SharedPtr graph, const std::string& graph_symbol); - void serialise_edge(const Sord::Node& parent, - SharedPtr c) + void serialise_arc(const Sord::Node& parent, + SharedPtr a) throw (std::logic_error); std::string finish(); @@ -413,9 +413,9 @@ Serialiser::Impl::serialise_graph(SharedPtr graph, serialise_port(p, Resource::INTERNAL, port_id); } - for (Node::Edges::const_iterator c = graph->edges().begin(); - c != graph->edges().end(); ++c) { - serialise_edge(graph_id, c->second); + for (Node::Arcs::const_iterator a = graph->arcs().begin(); + a != graph->arcs().end(); ++a) { + serialise_arc(graph_id, a->second); } } @@ -481,43 +481,43 @@ Serialiser::Impl::serialise_port(const Node* port, } void -Serialiser::serialise_edge(const Sord::Node& parent, - SharedPtr edge) +Serialiser::serialise_arc(const Sord::Node& parent, + SharedPtr arc) throw (std::logic_error) { - return me->serialise_edge(parent, edge); + return me->serialise_arc(parent, arc); } void -Serialiser::Impl::serialise_edge(const Sord::Node& parent, - SharedPtr edge) +Serialiser::Impl::serialise_arc(const Sord::Node& parent, + SharedPtr arc) throw (std::logic_error) { if (!_model) throw std::logic_error( - "serialise_edge called without serialisation in progress"); + "serialise_arc called without serialisation in progress"); Sord::World& world = _model->world(); const URIs& uris = _world.uris(); - 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, + const Sord::Node src = path_rdf_node(arc->tail_path()); + const Sord::Node dst = path_rdf_node(arc->head_path()); + const Sord::Node arc_id = Sord::Node::blank_id(*_world.rdf_world()); + _model->add_statement(arc_id, Sord::URI(world, uris.ingen_tail), src); - _model->add_statement(edge_id, + _model->add_statement(arc_id, Sord::URI(world, uris.ingen_head), dst); if (parent.is_valid()) { _model->add_statement(parent, - Sord::URI(world, uris.ingen_edge), - edge_id); + Sord::URI(world, uris.ingen_arc), + arc_id); } else { - _model->add_statement(edge_id, + _model->add_statement(arc_id, Sord::URI(world, uris.rdf_type), - Sord::URI(world, uris.ingen_Edge)); + Sord::URI(world, uris.ingen_Arc)); } } diff --git a/src/server/ArcImpl.cpp b/src/server/ArcImpl.cpp new file mode 100644 index 00000000..debd2c1e --- /dev/null +++ b/src/server/ArcImpl.cpp @@ -0,0 +1,107 @@ +/* + 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 "ingen/URIs.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/util.h" + +#include "ArcImpl.hpp" +#include "BlockImpl.hpp" +#include "Buffer.hpp" +#include "BufferFactory.hpp" +#include "Engine.hpp" +#include "InputPort.hpp" +#include "OutputPort.hpp" +#include "PortImpl.hpp" + +namespace Ingen { +namespace Server { + +/** Constructor for an arc from a block's output port. + * + * This handles both polyphonic and monophonic blocks, transparently to the + * user (InputPort). + */ +ArcImpl::ArcImpl(PortImpl* tail, PortImpl* head) + : _tail(tail) + , _head(head) +{ + assert(tail != head); + assert(tail->path() != head->path()); +} + +const Raul::Path& +ArcImpl::tail_path() const +{ + return _tail->path(); +} + +const Raul::Path& +ArcImpl::head_path() const +{ + return _head->path(); +} + +BufferRef +ArcImpl::buffer(uint32_t voice) const +{ + assert(!must_mix()); + assert(_tail->poly() == 1 || _tail->poly() > voice); + if (_tail->poly() == 1) { + return _tail->buffer(0); + } else { + return _tail->buffer(voice); + } +} + +bool +ArcImpl::must_mix() const +{ + return _tail->poly() > _head->poly(); +} + +bool +ArcImpl::can_connect(const OutputPort* src, const InputPort* dst) +{ + const Ingen::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/ArcImpl.hpp b/src/server/ArcImpl.hpp new file mode 100644 index 00000000..a28616da --- /dev/null +++ b/src/server/ArcImpl.hpp @@ -0,0 +1,86 @@ +/* + 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_ARC_IMPL_HPP +#define INGEN_ENGINE_ARC_IMPL_HPP + +#include + +#include +#include + +#include "ingen/Arc.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" +#include "raul/Deletable.hpp" + +#include "BufferRef.hpp" +#include "Context.hpp" + +namespace Ingen { +namespace Server { + +class PortImpl; +class OutputPort; +class InputPort; + +/** Represents a single inbound connection for an InputPort. + * + * This can be a group of ports (coming from a polyphonic Block) 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 ArcImpl + : private Raul::Noncopyable + , public Arc + , public boost::intrusive::slist_base_hook< + boost::intrusive::link_mode > +{ +public: + ArcImpl(PortImpl* tail, PortImpl* head); + + inline PortImpl* tail() const { return _tail; } + inline PortImpl* head() const { return _head; } + + const Raul::Path& tail_path() const; + const Raul::Path& head_path() const; + + /** Get the buffer for a particular voice. + * An Arc 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 arc). + */ + BufferRef buffer(uint32_t voice) const; + + /** Whether this arc must mix down voices into a local buffer */ + bool must_mix() const; + + static bool can_connect(const OutputPort* src, const InputPort* dst); + +protected: + PortImpl* const _tail; + PortImpl* const _head; +}; + +} // namespace Server +} // namespace Ingen + +#endif // INGEN_ENGINE_ARC_IMPL_HPP diff --git a/src/server/EdgeImpl.cpp b/src/server/EdgeImpl.cpp deleted file mode 100644 index 08096d45..00000000 --- a/src/server/EdgeImpl.cpp +++ /dev/null @@ -1,107 +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 "ingen/URIs.hpp" -#include "lv2/lv2plug.in/ns/ext/atom/util.h" - -#include "BlockImpl.hpp" -#include "Buffer.hpp" -#include "BufferFactory.hpp" -#include "EdgeImpl.hpp" -#include "Engine.hpp" -#include "InputPort.hpp" -#include "OutputPort.hpp" -#include "PortImpl.hpp" - -namespace Ingen { -namespace Server { - -/** Constructor for a edge from a block's output port. - * - * This handles both polyphonic and monophonic blocks, transparently to the - * user (InputPort). - */ -EdgeImpl::EdgeImpl(PortImpl* tail, PortImpl* head) - : _tail(tail) - , _head(head) -{ - assert(tail != head); - assert(tail->path() != head->path()); -} - -const Raul::Path& -EdgeImpl::tail_path() const -{ - return _tail->path(); -} - -const Raul::Path& -EdgeImpl::head_path() const -{ - return _head->path(); -} - -BufferRef -EdgeImpl::buffer(uint32_t voice) const -{ - assert(!must_mix()); - 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::can_connect(const OutputPort* src, const InputPort* dst) -{ - const Ingen::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 deleted file mode 100644 index 0627a7ba..00000000 --- a/src/server/EdgeImpl.hpp +++ /dev/null @@ -1,86 +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_EDGE_IMPL_HPP -#define INGEN_ENGINE_EDGE_IMPL_HPP - -#include - -#include -#include - -#include "ingen/Edge.hpp" -#include "lv2/lv2plug.in/ns/ext/atom/atom.h" -#include "raul/Deletable.hpp" - -#include "BufferRef.hpp" -#include "Context.hpp" - -namespace Ingen { -namespace Server { - -class PortImpl; -class OutputPort; -class InputPort; - -/** Represents a single inbound connection for an InputPort. - * - * This can be a group of ports (coming from a polyphonic Block) 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 - : private Raul::Noncopyable - , public Edge - , public boost::intrusive::slist_base_hook< - boost::intrusive::link_mode > -{ -public: - EdgeImpl(PortImpl* tail, PortImpl* head); - - inline PortImpl* tail() const { return _tail; } - inline PortImpl* head() const { return _head; } - - const Raul::Path& tail_path() const; - const Raul::Path& head_path() const; - - /** 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; - - static bool can_connect(const OutputPort* src, const InputPort* dst); - -protected: - PortImpl* const _tail; - PortImpl* const _head; -}; - -} // namespace Server -} // namespace Ingen - -#endif // INGEN_ENGINE_EDGEIMPL_HPP diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp index 2353b977..5859d071 100644 --- a/src/server/GraphImpl.cpp +++ b/src/server/GraphImpl.cpp @@ -21,10 +21,10 @@ #include "ingen/World.hpp" #include "raul/Maid.hpp" +#include "ArcImpl.hpp" #include "BlockImpl.hpp" #include "BufferFactory.hpp" #include "DuplexPort.hpp" -#include "EdgeImpl.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "GraphPlugin.hpp" @@ -198,35 +198,35 @@ GraphImpl::remove_block(BlockImpl& block) } void -GraphImpl::add_edge(SharedPtr c) +GraphImpl::add_arc(SharedPtr a) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - _edges.insert(make_pair(make_pair(c->tail(), c->head()), c)); + _arcs.insert(make_pair(make_pair(a->tail(), a->head()), a)); } -/** Remove a edge. +/** Remove an arc. * Preprocessing thread only. */ -SharedPtr -GraphImpl::remove_edge(const PortImpl* tail, const PortImpl* dst_port) +SharedPtr +GraphImpl::remove_arc(const PortImpl* tail, const PortImpl* dst_port) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Edges::iterator i = _edges.find(make_pair(tail, dst_port)); - if (i != _edges.end()) { - SharedPtr c = PtrCast(i->second); - _edges.erase(i); - return c; + Arcs::iterator i = _arcs.find(make_pair(tail, dst_port)); + if (i != _arcs.end()) { + SharedPtr arc = PtrCast(i->second); + _arcs.erase(i); + return arc; } else { - return SharedPtr(); + return SharedPtr(); } } bool -GraphImpl::has_edge(const PortImpl* tail, const PortImpl* dst_port) const +GraphImpl::has_arc(const PortImpl* tail, const PortImpl* dst_port) const { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - Edges::const_iterator i = _edges.find(make_pair(tail, dst_port)); - return (i != _edges.end()); + Arcs::const_iterator i = _arcs.find(make_pair(tail, dst_port)); + return (i != _arcs.end()); } void diff --git a/src/server/GraphImpl.hpp b/src/server/GraphImpl.hpp index 9ef707fc..2e534ca7 100644 --- a/src/server/GraphImpl.hpp +++ b/src/server/GraphImpl.hpp @@ -28,13 +28,13 @@ namespace Ingen { -class Edge; +class Arc; namespace Server { +class ArcImpl; class CompiledGraph; class Context; -class EdgeImpl; class Engine; class ProcessContext; @@ -128,12 +128,12 @@ public: void remove_port(DuplexPort& port); void clear_ports(); - void add_edge(SharedPtr c); + void add_arc(SharedPtr arc); - SharedPtr remove_edge(const PortImpl* tail, - const PortImpl* head); + SharedPtr remove_arc(const PortImpl* tail, + const PortImpl* head); - bool has_edge(const PortImpl* tail, const PortImpl* head) const; + bool has_arc(const PortImpl* tail, const PortImpl* head) const; void set_compiled_graph(CompiledGraph* cp); diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index a272b305..9ab3cbfe 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -20,10 +20,10 @@ #include "ingen/Log.hpp" #include "ingen/URIs.hpp" +#include "ArcImpl.hpp" #include "BlockImpl.hpp" #include "Buffer.hpp" #include "BufferFactory.hpp" -#include "EdgeImpl.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "InputPort.hpp" @@ -46,7 +46,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_edges(0) + , _num_arcs(0) { const Ingen::URIs& uris = bufs.uris(); @@ -82,21 +82,21 @@ InputPort::get_buffers(BufferFactory& bufs, uint32_t poly, bool real_time) const { - const size_t num_edges = real_time ? _edges.size() : _num_edges; + const size_t num_arcs = real_time ? _arcs.size() : _num_arcs; - if (is_a(PortType::AUDIO) && num_edges == 0) { - // Audio input with no edges, use shared zero buffer + if (is_a(PortType::AUDIO) && num_arcs == 0) { + // Audio input with no arcs, use shared zero buffer for (uint32_t v = 0; v < poly; ++v) { buffers->at(v) = bufs.silent_buffer(); } return false; - } else if (num_edges == 1) { + } else if (num_arcs == 1) { if (real_time) { - if (!_edges.front().must_mix()) { + if (!_arcs.front().must_mix()) { // Single non-mixing connection, use buffers directly for (uint32_t v = 0; v < poly; ++v) { - buffers->at(v) = _edges.front().buffer(v); + buffers->at(v) = _arcs.front().buffer(v); } return false; } @@ -112,50 +112,50 @@ InputPort::get_buffers(BufferFactory& bufs, return true; } -/** Add a edge. Realtime safe. +/** Add an arc. Realtime safe. * - * 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. + * The buffer of this port will be set directly to the arc's buffer + * if there is only one arc, 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_edge(ProcessContext& context, EdgeImpl* c) +InputPort::add_arc(ProcessContext& context, ArcImpl* c) { - _edges.push_front(*c); + _arcs.push_front(*c); if (_type != PortType::CV) { _broadcast = true; // Broadcast value/activity of connected input } } -/** Remove a edge. Realtime safe. +/** Remove a arc. Realtime safe. * * Note that setup_buffers must be called after this before the change * will audibly take effect. */ -EdgeImpl* -InputPort::remove_edge(ProcessContext& context, const OutputPort* tail) +ArcImpl* +InputPort::remove_arc(ProcessContext& context, const OutputPort* tail) { - EdgeImpl* edge = NULL; - for (Edges::iterator i = _edges.begin(); i != _edges.end(); ++i) { + ArcImpl* arc = NULL; + for (Arcs::iterator i = _arcs.begin(); i != _arcs.end(); ++i) { if (i->tail() == tail) { - edge = &*i; - _edges.erase(i); + arc = &*i; + _arcs.erase(i); break; } } - if (!edge) { - context.engine().log().error("Attempt to remove non-existent edge\n"); + if (!arc) { + context.engine().log().error("Attempt to remove non-existent arc\n"); return NULL; } - if (_edges.empty()) { + if (_arcs.empty()) { _broadcast = false; // Turn off broadcasting if no longer connected } - return edge; + return arc; } uint32_t @@ -165,24 +165,24 @@ InputPort::max_tail_poly(Context& context) const } static void -get_sources(const Context& context, - const EdgeImpl& edge, - uint32_t voice, - const Buffer** srcs, - uint32_t max_num_srcs, - uint32_t& num_srcs) +get_sources(const Context& context, + const ArcImpl& arc, + uint32_t voice, + const Buffer** srcs, + uint32_t max_num_srcs, + uint32_t& num_srcs) { - if (edge.must_mix()) { + if (arc.must_mix()) { // Mixing down voices: all tail voices => one head voice - for (uint32_t v = 0; v < edge.tail()->poly(); ++v) { + for (uint32_t v = 0; v < arc.tail()->poly(); ++v) { assert(num_srcs < max_num_srcs); - srcs[num_srcs++] = edge.tail()->buffer(v).get(); + srcs[num_srcs++] = arc.tail()->buffer(v).get(); } } else { // Matching polyphony: each tail voice => corresponding head voice - assert(edge.tail()->poly() == edge.head()->poly()); + assert(arc.tail()->poly() == arc.head()->poly()); assert(num_srcs < max_num_srcs); - srcs[num_srcs++] = edge.tail()->buffer(voice).get(); + srcs[num_srcs++] = arc.tail()->buffer(voice).get(); } } @@ -195,23 +195,23 @@ InputPort::pre_process(Context& context) if (_set_by_user) return; - if (_edges.empty()) { + if (_arcs.empty()) { for (uint32_t v = 0; v < _poly; ++v) { update_set_state(context, v); } } else if (direct_connect()) { for (uint32_t v = 0; v < _poly; ++v) { - _buffers->at(v) = _edges.front().buffer(v); + _buffers->at(v) = _arcs.front().buffer(v); } } else { const uint32_t src_poly = max_tail_poly(context); - const uint32_t max_num_srcs = _edges.size() * src_poly; + const uint32_t max_num_srcs = _arcs.size() * src_poly; const Buffer* srcs[max_num_srcs]; for (uint32_t v = 0; v < _poly; ++v) { // Get all the sources for this voice uint32_t num_srcs = 0; - for (Edges::iterator e = _edges.begin(); e != _edges.end(); ++e) { + for (Arcs::iterator e = _arcs.begin(); e != _arcs.end(); ++e) { get_sources(context, *e, v, srcs, max_num_srcs, num_srcs); } @@ -241,9 +241,9 @@ InputPort::post_process(Context& context) bool InputPort::direct_connect() const { - return _edges.size() == 1 + return _arcs.size() == 1 && !_parent->path().is_root() - && !_edges.front().must_mix(); + && !_arcs.front().must_mix(); } } // namespace Server diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp index 7a4c7669..faf323f0 100644 --- a/src/server/InputPort.hpp +++ b/src/server/InputPort.hpp @@ -24,13 +24,13 @@ #include "raul/SharedPtr.hpp" +#include "ArcImpl.hpp" #include "PortImpl.hpp" -#include "EdgeImpl.hpp" namespace Ingen { namespace Server { -class EdgeImpl; +class ArcImpl; class Context; class BlockImpl; class OutputPort; @@ -39,10 +39,10 @@ class ProcessContext; /** An input port on a Block or Graph. * * All ports have a Buffer, but the actual contents (data) of that buffer may be - * set directly to the incoming edge's buffer if there's only one inbound - * edge, to eliminate the need to copy/mix. + * set directly to the incoming arc's buffer if there's only one inbound + * arc, to eliminate the need to copy/mix. * - * If a port has multiple edges, they will be mixed down into the local + * If a port has multiple arcs, they will be mixed down into the local * buffer and it will be used. * * \ingroup engine @@ -62,15 +62,15 @@ public: virtual ~InputPort() {} - typedef boost::intrusive::slist - > Edges; + > Arcs; /** Return the maximum polyphony of an output connected to this input. */ virtual uint32_t max_tail_poly(Context& context) const; - void add_edge(ProcessContext& context, EdgeImpl* c); - EdgeImpl* remove_edge(ProcessContext& context, + void add_arc(ProcessContext& context, ArcImpl* c); + ArcImpl* remove_arc(ProcessContext& context, const OutputPort* tail); bool apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly); @@ -83,9 +83,9 @@ public: void pre_process(Context& context); void post_process(Context& context); - size_t num_edges() const { return _num_edges; } ///< Pre-process thread - void increment_num_edges() { ++_num_edges; } - void decrement_num_edges() { --_num_edges; } + size_t num_arcs() const { return _num_arcs; } ///< Pre-process thread + void increment_num_arcs() { ++_num_arcs; } + void decrement_num_arcs() { --_num_arcs; } bool is_input() const { return true; } bool is_output() const { return false; } @@ -93,8 +93,8 @@ public: bool direct_connect() const; protected: - size_t _num_edges; ///< Pre-process thread - Edges _edges; ///< Audio thread + size_t _num_arcs; ///< Pre-process thread + Arcs _arcs; ///< Audio thread }; } // namespace Server diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index a496bbb4..0559ec39 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -20,9 +20,9 @@ #include "raul/Maid.hpp" #include "raul/Path.hpp" +#include "ArcImpl.hpp" #include "Broadcaster.hpp" #include "Connect.hpp" -#include "EdgeImpl.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "InputPort.hpp" @@ -82,12 +82,12 @@ Connect::pre_process() return Event::pre_process_done(PARENT_DIFFERS, _head_path); } - if (!EdgeImpl::can_connect(tail_output, _head)) { + if (!ArcImpl::can_connect(tail_output, _head)) { return Event::pre_process_done(TYPE_MISMATCH, _head_path); } if (tail_block->parent_graph() != head_block->parent_graph()) { - // Edge to a graph port from inside the graph + // Arc to a graph port from inside the graph assert(tail_block->parent() == head_block || head_block->parent() == tail_block); if (tail_block->parent() == head_block) { _graph = dynamic_cast(head_block); @@ -95,25 +95,25 @@ Connect::pre_process() _graph = dynamic_cast(tail_block); } } else if (tail_block == head_block && dynamic_cast(tail_block)) { - // Edge from a graph input to a graph output (pass through) + // Arc from a graph input to a graph output (pass through) _graph = dynamic_cast(tail_block); } else { - // Normal edge between blocks with the same parent + // Normal arc between blocks with the same parent _graph = tail_block->parent_graph(); } - if (_graph->has_edge(tail_output, _head)) { + if (_graph->has_arc(tail_output, _head)) { return Event::pre_process_done(EXISTS, _head_path); } - _edge = SharedPtr(new EdgeImpl(tail_output, _head)); + _arc = SharedPtr(new ArcImpl(tail_output, _head)); rlock.release(); { Glib::RWLock::ReaderLock wlock(_engine.store()->lock()); - /* Need to be careful about graph port edges here and adding a + /* Need to be careful about graph port arcs here and adding a block's parent as a dependant/provider, or adding a graph as its own provider... */ @@ -122,8 +122,8 @@ Connect::pre_process() tail_block->dependants().push_back(head_block); } - _graph->add_edge(_edge); - _head->increment_num_edges(); + _graph->add_arc(_arc); + _head->increment_num_arcs(); } _buffers = new Raul::Array(_head->poly()); @@ -143,7 +143,7 @@ void Connect::execute(ProcessContext& context) { if (!_status) { - _head->add_edge(context, _edge.get()); + _head->add_arc(context, _arc.get()); _engine.maid()->dispose(_head->set_buffers(context, _buffers)); _head->connect_buffers(); _graph->set_compiled_graph(_compiled_graph); diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp index 445ee80e..a84b9fcf 100644 --- a/src/server/events/Connect.hpp +++ b/src/server/events/Connect.hpp @@ -30,15 +30,15 @@ template class Array; namespace Ingen { namespace Server { +class ArcImpl; class CompiledGraph; -class EdgeImpl; +class GraphImpl; class InputPort; class OutputPort; -class GraphImpl; namespace Events { -/** Make an Edge between two Ports. +/** Make an Arc between two Ports. * * \ingroup engine */ @@ -62,7 +62,7 @@ private: GraphImpl* _graph; InputPort* _head; CompiledGraph* _compiled_graph; - SharedPtr _edge; + SharedPtr _arc; Raul::Array* _buffers; }; diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 645d89c5..829500f5 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -22,10 +22,10 @@ #include "raul/Maid.hpp" #include "raul/Path.hpp" +#include "ArcImpl.hpp" #include "Broadcaster.hpp" #include "Buffer.hpp" #include "DuplexPort.hpp" -#include "EdgeImpl.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "InputPort.hpp" @@ -62,7 +62,7 @@ Disconnect::Impl::Impl(Engine& e, , _src_output_port(s) , _dst_input_port(d) , _graph(graph) - , _edge(graph->remove_edge(_src_output_port, _dst_input_port)) + , _arc(graph->remove_arc(_src_output_port, _dst_input_port)) , _buffers(NULL) { ThreadManager::assert_thread(THREAD_PRE_PROCESS); @@ -86,9 +86,9 @@ Disconnect::Impl::Impl(Engine& e, } } - _dst_input_port->decrement_num_edges(); + _dst_input_port->decrement_num_arcs(); - if (_dst_input_port->num_edges() == 0) { + if (_dst_input_port->num_arcs() == 0) { _buffers = new Raul::Array(_dst_input_port->poly()); _dst_input_port->get_buffers(*_engine.buffer_factory(), _buffers, @@ -134,7 +134,7 @@ Disconnect::pre_process() BlockImpl* const dst_block = head->parent_block(); if (src_block->parent_graph() != dst_block->parent_graph()) { - // Edge to a graph port from inside the graph + // Arc to a graph port from inside the graph assert(src_block->parent() == dst_block || dst_block->parent() == src_block); if (src_block->parent() == dst_block) { _graph = dynamic_cast(dst_block); @@ -142,16 +142,16 @@ Disconnect::pre_process() _graph = dynamic_cast(src_block); } } else if (src_block == dst_block && dynamic_cast(src_block)) { - // Edge from a graph input to a graph output (pass through) + // Arc from a graph input to a graph output (pass through) _graph = dynamic_cast(src_block); } else { - // Normal edge between blocks with the same parent + // Normal arc between blocks with the same parent _graph = src_block->parent_graph(); } if (!_graph) { return Event::pre_process_done(INTERNAL_ERROR, _head_path); - } else if (!_graph->has_edge(tail, head)) { + } else if (!_graph->has_arc(tail, head)) { return Event::pre_process_done(NOT_FOUND, _head_path); } @@ -173,9 +173,9 @@ Disconnect::pre_process() bool Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers) { - EdgeImpl* const port_edge = - _dst_input_port->remove_edge(context, _src_output_port); - if (!port_edge) { + ArcImpl* const port_arc = + _dst_input_port->remove_arc(context, _src_output_port); + if (!port_arc) { return false; } diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index feb1d17f..b0c9408c 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -38,7 +38,7 @@ class PortImpl; namespace Events { -/** Remove an Edge between two Ports. +/** Remove an Arc between two Ports. * * \ingroup engine */ @@ -72,7 +72,7 @@ public: OutputPort* _src_output_port; InputPort* _dst_input_port; GraphImpl* _graph; - SharedPtr _edge; + SharedPtr _arc; Raul::Array* _buffers; }; diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index b3e24e3f..c2475b45 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -24,9 +24,9 @@ #include "raul/Maid.hpp" #include "raul/Path.hpp" +#include "ArcImpl.hpp" #include "BlockImpl.hpp" #include "Broadcaster.hpp" -#include "EdgeImpl.hpp" #include "Engine.hpp" #include "GraphImpl.hpp" #include "InputPort.hpp" @@ -112,11 +112,11 @@ DisconnectAll::pre_process() } } - // Find set of edges to remove - std::set to_remove; - for (Node::Edges::const_iterator i = _parent->edges().begin(); - i != _parent->edges().end(); ++i) { - EdgeImpl* const c = (EdgeImpl*)i->second.get(); + // Find set of arcs to remove + std::set to_remove; + for (Node::Arcs::const_iterator i = _parent->arcs().begin(); + i != _parent->arcs().end(); ++i) { + ArcImpl* const c = (ArcImpl*)i->second.get(); if (_block) { if (c->tail()->parent_block() == _block || c->head()->parent_block() == _block) { @@ -129,8 +129,8 @@ DisconnectAll::pre_process() } } - // Create disconnect events (which erases from _parent->edges()) - for (std::set::const_iterator i = to_remove.begin(); + // Create disconnect events (which erases from _parent->arcs()) + 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/events/Get.cpp b/src/server/events/Get.cpp index b65b47bf..93af8bf2 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -119,9 +119,9 @@ send_graph(Interface* client, const GraphImpl* graph) send_port(client, graph->port_impl(i)); } - // Send edges - for (GraphImpl::Edges::const_iterator j = graph->edges().begin(); - j != graph->edges().end(); ++j) { + // Send arcs + for (GraphImpl::Arcs::const_iterator j = graph->arcs().begin(); + j != graph->arcs().end(); ++j) { client->connect(j->second->tail_path(), j->second->head_path()); } } diff --git a/src/server/wscript b/src/server/wscript index 107db69d..47090d90 100644 --- a/src/server/wscript +++ b/src/server/wscript @@ -3,6 +3,7 @@ from waflib.extras import autowaf as autowaf def build(bld): core_source = ''' + ArcImpl.cpp BlockFactory.cpp BlockImpl.cpp Broadcaster.cpp @@ -11,7 +12,6 @@ def build(bld): Context.cpp ControlBindings.cpp DuplexPort.cpp - EdgeImpl.cpp Engine.cpp EventWriter.cpp GraphImpl.cpp -- cgit v1.2.1