summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-07-30 23:00:13 +0000
committerDavid Robillard <d@drobilla.net>2012-07-30 23:00:13 +0000
commit0e1bf6ddfc77866ff6477a3f394c030c2a5e1b39 (patch)
treeafcba1a0ba16837f7b6f1a4822b7164deccb61e7
parent921881813d7fb2e46a0e65d1e888f6cd9a928945 (diff)
downloadingen-0e1bf6ddfc77866ff6477a3f394c030c2a5e1b39.tar.gz
ingen-0e1bf6ddfc77866ff6477a3f394c030c2a5e1b39.tar.bz2
ingen-0e1bf6ddfc77866ff6477a3f394c030c2a5e1b39.zip
Eliminate pure virtual base classes Patch, Node, and Port, and the virtual inheritance they imposed.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4576 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ingen/Edge.hpp6
-rw-r--r--ingen/GraphObject.hpp32
-rw-r--r--ingen/Node.hpp48
-rw-r--r--ingen/Patch.hpp49
-rw-r--r--ingen/Port.hpp46
-rw-r--r--ingen/client/NodeModel.hpp11
-rw-r--r--ingen/client/PatchModel.hpp22
-rw-r--r--ingen/client/PortModel.hpp5
-rw-r--r--ingen/serialisation/Serialiser.hpp7
-rw-r--r--ingen/shared/LV2Features.hpp6
-rw-r--r--ingen/shared/URIMap.hpp2
-rw-r--r--src/client/NodeModel.cpp16
-rw-r--r--src/client/PatchModel.cpp24
-rw-r--r--src/serialisation/Serialiser.cpp123
-rw-r--r--src/server/Context.hpp4
-rw-r--r--src/server/EdgeImpl.hpp3
-rw-r--r--src/server/InputPort.cpp5
-rw-r--r--src/server/JackDriver.cpp2
-rw-r--r--src/server/LV2ResizeFeature.hpp2
-rw-r--r--src/server/NodeImpl.cpp2
-rw-r--r--src/server/NodeImpl.hpp10
-rw-r--r--src/server/OutputPort.cpp6
-rw-r--r--src/server/PatchImpl.hpp11
-rw-r--r--src/server/PortImpl.hpp6
-rw-r--r--src/server/Worker.cpp2
-rw-r--r--src/server/Worker.hpp2
-rw-r--r--src/server/events/DisconnectAll.cpp2
-rw-r--r--src/shared/Builder.cpp8
-rw-r--r--src/shared/LV2Features.cpp2
-rw-r--r--src/shared/Store.cpp10
30 files changed, 157 insertions, 317 deletions
diff --git a/ingen/Edge.hpp b/ingen/Edge.hpp
index 74a544e8..a586783b 100644
--- a/ingen/Edge.hpp
+++ b/ingen/Edge.hpp
@@ -17,6 +17,8 @@
#ifndef INGEN_EDGE_HPP
#define INGEN_EDGE_HPP
+#include "raul/Deletable.hpp"
+
namespace Raul { class Path; }
namespace Ingen {
@@ -25,11 +27,9 @@ namespace Ingen {
*
* @ingroup Ingen
*/
-class Edge
+class Edge : public Raul::Deletable
{
public:
- virtual ~Edge() {}
-
virtual const Raul::Path& tail_path() const = 0;
virtual const Raul::Path& head_path() const = 0;
};
diff --git a/ingen/GraphObject.hpp b/ingen/GraphObject.hpp
index b2165972..a0d5ec22 100644
--- a/ingen/GraphObject.hpp
+++ b/ingen/GraphObject.hpp
@@ -17,9 +17,9 @@
#ifndef INGEN_GRAPHOBJECT_HPP
#define INGEN_GRAPHOBJECT_HPP
-#include "raul/Deletable.hpp"
-
#include "ingen/Resource.hpp"
+#include "raul/Deletable.hpp"
+#include "raul/SharedPtr.hpp"
namespace Raul {
class Atom;
@@ -29,10 +29,11 @@ class Symbol;
namespace Ingen {
+class Edge;
+class Plugin;
+
/** An object on the audio graph - Patch, Node, Port, etc.
*
- * Purely virtual (except for the destructor).
- *
* @ingroup Ingen
*/
class GraphObject : public Raul::Deletable
@@ -41,9 +42,32 @@ class GraphObject : public Raul::Deletable
public:
virtual void set_path(const Raul::Path& path) = 0;
+ enum GraphType {
+ PATCH,
+ NODE,
+ PORT
+ };
+
+ typedef std::pair<const GraphObject*, const GraphObject*> EdgesKey;
+ typedef std::map< EdgesKey, SharedPtr<Edge> > Edges;
+
+ // Patches only
+ Edges& edges() { return _edges; }
+ const Edges& edges() const { return _edges; }
+
+ // Nodes and patches only
+ virtual uint32_t num_ports() const { return 0; }
+ virtual GraphObject* port(uint32_t index) const { return NULL; }
+ virtual const Plugin* plugin() const { return NULL; }
+
+ // All objects
+ virtual GraphType graph_type() const = 0;
virtual const Raul::Path& path() const = 0;
virtual const Raul::Symbol& symbol() const = 0;
virtual GraphObject* graph_parent() const = 0;
+
+protected:
+ Edges _edges; ///< Patches only
};
} // namespace Ingen
diff --git a/ingen/Node.hpp b/ingen/Node.hpp
deleted file mode 100644
index 1eb9968e..00000000
--- a/ingen/Node.hpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INGEN_NODE_HPP
-#define INGEN_NODE_HPP
-
-#include <stdint.h>
-
-#include "ingen/GraphObject.hpp"
-
-namespace Ingen {
-
-class Port;
-class Plugin;
-
-/** A Node (or "module") in a Patch (which is also a Node).
- *
- * A Node is a unit with input/output ports, a process() method, and some other
- * things.
- *
- * Purely virtual (except for the destructor).
- *
- * @ingroup Ingen
- */
-class Node : public virtual GraphObject
-{
-public:
- virtual uint32_t num_ports() const = 0;
- virtual Port* port(uint32_t index) const = 0;
- virtual const Plugin* plugin() const = 0;
-};
-
-} // namespace Ingen
-
-#endif // INGEN_NODE_HPP
diff --git a/ingen/Patch.hpp b/ingen/Patch.hpp
deleted file mode 100644
index 61db0b42..00000000
--- a/ingen/Patch.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INGEN_PATCH_HPP
-#define INGEN_PATCH_HPP
-
-#include <map>
-#include <utility>
-
-#include "raul/SharedPtr.hpp"
-
-#include "ingen/Node.hpp"
-
-namespace Ingen {
-
-class Edge;
-
-/** A Patch (graph of Nodes/Edges)
- *
- * @ingroup Ingen
- */
-class Patch : virtual public Node
-{
-public:
- typedef std::pair<const Port*, const Port*> EdgesKey;
- typedef std::map< EdgesKey, SharedPtr<Edge> > Edges;
-
- virtual const Edges& edges() const = 0;
-
- virtual bool enabled() const = 0;
- virtual uint32_t internal_poly() const = 0;
-};
-
-} // namespace Ingen
-
-#endif // INGEN_PATCH_HPP
diff --git a/ingen/Port.hpp b/ingen/Port.hpp
deleted file mode 100644
index 715fd96e..00000000
--- a/ingen/Port.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- This file is part of Ingen.
- Copyright 2007-2012 David Robillard <http://drobilla.net/>
-
- 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 <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef INGEN_PORT_HPP
-#define INGEN_PORT_HPP
-
-#include <stdint.h>
-
-#include "ingen/GraphObject.hpp"
-
-namespace Raul { class Atom; }
-
-namespace Ingen {
-
-/** A Port on a Node.
- *
- * Purely virtual (except for the destructor).
- *
- * @ingroup Ingen
- */
-class Port : public virtual GraphObject
-{
-public:
- virtual bool supports(const Raul::URI& value_type) const = 0;
-
- virtual uint32_t index() const = 0;
- virtual bool is_input() const = 0;
- virtual const Raul::Atom& value() const = 0;
-};
-
-} // namespace Ingen
-
-#endif // INGEN_PORT_HPP
diff --git a/ingen/client/NodeModel.hpp b/ingen/client/NodeModel.hpp
index cc41070c..07810eed 100644
--- a/ingen/client/NodeModel.hpp
+++ b/ingen/client/NodeModel.hpp
@@ -22,9 +22,7 @@
#include <vector>
#include "raul/SharedPtr.hpp"
-
-#include "ingen/Node.hpp"
-#include "ingen/Port.hpp"
+#include "ingen/GraphObject.hpp"
#include "ingen/client/ObjectModel.hpp"
#include "ingen/client/PortModel.hpp"
#include "ingen/client/PluginModel.hpp"
@@ -44,18 +42,19 @@ class ClientStore;
*
* @ingroup IngenClient
*/
-class NodeModel : public ObjectModel,
- virtual public Ingen::Node
+class NodeModel : public ObjectModel
{
public:
NodeModel(const NodeModel& copy);
virtual ~NodeModel();
+ GraphType graph_type() const { return GraphObject::PATCH; }
+
typedef std::vector< SharedPtr<const PortModel> > Ports;
SharedPtr<const PortModel> get_port(const Raul::Symbol& symbol) const;
- Port* port(uint32_t index) const;
+ GraphObject* port(uint32_t index) const;
const Raul::URI& plugin_uri() const { return _plugin_uri; }
const Plugin* plugin() const { return _plugin.get(); }
diff --git a/ingen/client/PatchModel.hpp b/ingen/client/PatchModel.hpp
index 9d4e7752..1ad55c78 100644
--- a/ingen/client/PatchModel.hpp
+++ b/ingen/client/PatchModel.hpp
@@ -17,15 +17,10 @@
#ifndef INGEN_CLIENT_PATCHMODEL_HPP
#define INGEN_CLIENT_PATCHMODEL_HPP
-#include "raul/SharedPtr.hpp"
-
-#include "ingen/Patch.hpp"
#include "ingen/client/NodeModel.hpp"
+#include "raul/SharedPtr.hpp"
namespace Ingen {
-
-class Port;
-
namespace Client {
class ClientStore;
@@ -35,15 +30,15 @@ class EdgeModel;
*
* @ingroup IngenClient
*/
-class PatchModel : public NodeModel, public Ingen::Patch
+class PatchModel : public NodeModel
{
public:
/* WARNING: Copy constructor creates a shallow copy WRT connections */
- const Edges& edges() const { return *_edges.get(); }
+ GraphType graph_type() const { return GraphObject::PATCH; }
- SharedPtr<EdgeModel> get_edge(const Ingen::Port* tail,
- const Ingen::Port* head);
+ SharedPtr<EdgeModel> get_edge(const Ingen::GraphObject* tail,
+ const Ingen::GraphObject* head);
bool enabled() const;
bool polyphonic() const;
@@ -60,7 +55,6 @@ private:
PatchModel(Shared::URIs& uris, const Raul::Path& patch_path)
: NodeModel(uris, "http://drobilla.net/ns/ingen#Patch", patch_path)
- , _edges(new Edges())
{
}
@@ -69,10 +63,8 @@ private:
bool remove_child(SharedPtr<ObjectModel> c);
void add_edge(SharedPtr<EdgeModel> cm);
- void remove_edge(const Ingen::Port* tail,
- const Ingen::Port* head);
-
- SharedPtr<Edges> _edges;
+ void remove_edge(const Ingen::GraphObject* tail,
+ const Ingen::GraphObject* head);
};
} // namespace Client
diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp
index 477186fb..99cd85be 100644
--- a/ingen/client/PortModel.hpp
+++ b/ingen/client/PortModel.hpp
@@ -26,7 +26,6 @@
#include "lv2/lv2plug.in/ns/ext/port-props/port-props.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
-#include "ingen/Port.hpp"
#include "ingen/client/ObjectModel.hpp"
namespace Raul { class Path; }
@@ -38,11 +37,13 @@ namespace Client {
*
* @ingroup IngenClient
*/
-class PortModel : public ObjectModel, public Ingen::Port
+class PortModel : public ObjectModel
{
public:
enum Direction { INPUT, OUTPUT };
+ GraphType graph_type() const { return GraphObject::PORT; }
+
bool supports(const Raul::URI& value_type) const;
inline uint32_t index() const { return _index; }
diff --git a/ingen/serialisation/Serialiser.hpp b/ingen/serialisation/Serialiser.hpp
index ab080a3d..2dbc99b7 100644
--- a/ingen/serialisation/Serialiser.hpp
+++ b/ingen/serialisation/Serialiser.hpp
@@ -31,9 +31,6 @@ namespace Ingen {
class Plugin;
class GraphObject;
-class Patch;
-class Node;
-class Port;
class Edge;
namespace Shared {
@@ -59,8 +56,8 @@ public:
virtual void to_file(SharedPtr<const GraphObject> object,
const std::string& filename);
- virtual void write_bundle(SharedPtr<const Patch> patch,
- const std::string& path);
+ virtual void write_bundle(SharedPtr<const GraphObject> patch,
+ const std::string& path);
virtual std::string to_string(SharedPtr<const GraphObject> object,
const std::string& base_uri);
diff --git a/ingen/shared/LV2Features.hpp b/ingen/shared/LV2Features.hpp
index 76d64b42..822df818 100644
--- a/ingen/shared/LV2Features.hpp
+++ b/ingen/shared/LV2Features.hpp
@@ -26,7 +26,7 @@
namespace Ingen {
-class Node;
+class GraphObject;
namespace Shared {
@@ -44,7 +44,7 @@ public:
virtual ~Feature() {}
virtual SharedPtr<LV2_Feature> feature(Shared::World* world,
- Node* node) = 0;
+ GraphObject* node) = 0;
};
class FeatureArray : public Raul::Noncopyable {
@@ -65,7 +65,7 @@ public:
void add_feature(SharedPtr<Feature> feature);
SharedPtr<FeatureArray> lv2_features(Shared::World* world,
- Node* node) const;
+ GraphObject* node) const;
private:
typedef std::vector< SharedPtr<Feature> > Features;
diff --git a/ingen/shared/URIMap.hpp b/ingen/shared/URIMap.hpp
index bb3e55be..d30b843d 100644
--- a/ingen/shared/URIMap.hpp
+++ b/ingen/shared/URIMap.hpp
@@ -46,7 +46,7 @@ public:
_feature.data = data;
}
- SharedPtr<LV2_Feature> feature(Shared::World*, Node*) {
+ SharedPtr<LV2_Feature> feature(Shared::World*, GraphObject*) {
return SharedPtr<LV2_Feature>(&_feature, NullDeleter<LV2_Feature>);
}
diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp
index a92d5aae..2a88b4db 100644
--- a/src/client/NodeModel.cpp
+++ b/src/client/NodeModel.cpp
@@ -18,7 +18,6 @@
#include <cmath>
#include <string>
-#include "ingen/Port.hpp"
#include "ingen/client/NodeModel.hpp"
#include "ingen/shared/URIs.hpp"
#include "ingen/shared/World.hpp"
@@ -29,8 +28,7 @@ namespace Client {
NodeModel::NodeModel(Shared::URIs& uris,
SharedPtr<PluginModel> plugin,
const Raul::Path& path)
- : Node()
- , ObjectModel(uris, path)
+ : ObjectModel(uris, path)
, _plugin_uri(plugin->uri())
, _plugin(plugin)
, _num_values(0)
@@ -42,8 +40,7 @@ NodeModel::NodeModel(Shared::URIs& uris,
NodeModel::NodeModel(Shared::URIs& uris,
const Raul::URI& plugin_uri,
const Raul::Path& path)
- : Node()
- , ObjectModel(uris, path)
+ : ObjectModel(uris, path)
, _plugin_uri(plugin_uri)
, _num_values(0)
, _min_values(0)
@@ -52,8 +49,7 @@ NodeModel::NodeModel(Shared::URIs& uris,
}
NodeModel::NodeModel(const NodeModel& copy)
- : Node(copy)
- , ObjectModel(copy)
+ : ObjectModel(copy)
, _plugin_uri(copy._plugin_uri)
, _num_values(copy._num_values)
, _min_values((float*)malloc(sizeof(float) * _num_values))
@@ -153,12 +149,12 @@ NodeModel::get_port(const Raul::Symbol& symbol) const
return SharedPtr<PortModel>();
}
-Ingen::Port*
+Ingen::GraphObject*
NodeModel::port(uint32_t index) const
{
assert(index < num_ports());
- return const_cast<Ingen::Port*>(
- dynamic_cast<const Ingen::Port*>(_ports[index].get()));
+ return const_cast<Ingen::GraphObject*>(
+ dynamic_cast<const Ingen::GraphObject*>(_ports[index].get()));
}
void
diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp
index df6f63c0..7acb8aec 100644
--- a/src/client/PatchModel.cpp
+++ b/src/client/PatchModel.cpp
@@ -53,7 +53,7 @@ PatchModel::remove_child(SharedPtr<ObjectModel> 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();) {
+ for (Edges::iterator j = _edges.begin(); j != _edges.end();) {
Edges::iterator next = j;
++next;
@@ -65,7 +65,7 @@ PatchModel::remove_child(SharedPtr<ObjectModel> o)
|| cm->head_path().parent() == o->path()
|| cm->head_path() == o->path()) {
_signal_removed_edge.emit(cm);
- _edges->erase(j); // cuts our reference
+ _edges.erase(j); // cuts our reference
}
j = next;
}
@@ -84,19 +84,19 @@ PatchModel::remove_child(SharedPtr<ObjectModel> o)
void
PatchModel::clear()
{
- _edges->clear();
+ _edges.clear();
NodeModel::clear();
- assert(_edges->empty());
+ assert(_edges.empty());
assert(_ports.empty());
}
SharedPtr<EdgeModel>
-PatchModel::get_edge(const Port* tail, const Ingen::Port* head)
+PatchModel::get_edge(const GraphObject* tail, const GraphObject* head)
{
- Edges::iterator i = _edges->find(make_pair(tail, head));
- if (i != _edges->end())
+ Edges::iterator i = _edges.find(make_pair(tail, head));
+ if (i != _edges.end())
return PtrCast<EdgeModel>(i->second);
else
return SharedPtr<EdgeModel>();
@@ -131,20 +131,20 @@ PatchModel::add_edge(SharedPtr<EdgeModel> cm)
assert(cm->tail() == existing->tail());
assert(cm->head() == existing->head());
} else {
- _edges->insert(make_pair(make_pair(cm->tail().get(),
+ _edges.insert(make_pair(make_pair(cm->tail().get(),
cm->head().get()), cm));
_signal_new_edge.emit(cm);
}
}
void
-PatchModel::remove_edge(const Port* tail, const Ingen::Port* head)
+PatchModel::remove_edge(const GraphObject* tail, const GraphObject* head)
{
- Edges::iterator i = _edges->find(make_pair(tail, head));
- if (i != _edges->end()) {
+ Edges::iterator i = _edges.find(make_pair(tail, head));
+ if (i != _edges.end()) {
SharedPtr<EdgeModel> c = PtrCast<EdgeModel>(i->second);
_signal_removed_edge.emit(c);
- _edges->erase(i);
+ _edges.erase(i);
} else {
Raul::warn(Raul::fmt("Failed to remove patch connection %1% => %2%\n")
% tail->path() % head->path());
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 8f82ed5f..d0ed16ca 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -27,11 +27,9 @@
#include <glibmm/module.h>
#include "ingen/Edge.hpp"
+#include "ingen/GraphObject.hpp"
#include "ingen/Interface.hpp"
-#include "ingen/Node.hpp"
-#include "ingen/Patch.hpp"
#include "ingen/Plugin.hpp"
-#include "ingen/Port.hpp"
#include "ingen/Resource.hpp"
#include "ingen/serialisation/Serialiser.hpp"
#include "ingen/shared/Store.hpp"
@@ -72,28 +70,28 @@ struct Serialiser::Impl {
void start_to_filename(const std::string& filename);
- void serialise_patch(SharedPtr<const Patch> p,
- const Sord::Node& id);
+ void serialise_patch(SharedPtr<const GraphObject> p,
+ const Sord::Node& id);
- void serialise_node(SharedPtr<const Node> n,
- const Sord::Node& class_id,
- const Sord::Node& id);
+ void serialise_node(SharedPtr<const GraphObject> n,
+ const Sord::Node& class_id,
+ const Sord::Node& id);
- void serialise_port(const Port* p,
- Resource::Graph context,
- const Sord::Node& id);
+ void serialise_port(const GraphObject* p,
+ Resource::Graph context,
+ const Sord::Node& id);
void serialise_properties(Sord::Node id,
const Resource::Properties& props);
- void write_bundle(SharedPtr<const Patch> patch,
- const std::string& uri);
+ void write_bundle(SharedPtr<const GraphObject> patch,
+ const std::string& uri);
Sord::Node path_rdf_node(const Raul::Path& path);
- void write_manifest(const std::string& bundle_path,
- SharedPtr<const Patch> patch,
- const std::string& patch_symbol);
+ void write_manifest(const std::string& bundle_path,
+ SharedPtr<const GraphObject> patch,
+ const std::string& patch_symbol);
void serialise_edge(const Sord::Node& parent,
SharedPtr<const Edge> c)
@@ -130,9 +128,9 @@ Serialiser::to_file(SharedPtr<const GraphObject> object,
}
void
-Serialiser::Impl::write_manifest(const std::string& bundle_path,
- SharedPtr<const Patch> patch,
- const std::string& patch_symbol)
+Serialiser::Impl::write_manifest(const std::string& bundle_path,
+ SharedPtr<const GraphObject> patch,
+ const std::string& patch_symbol)
{
const string manifest_path(Glib::build_filename(bundle_path, "manifest.ttl"));
const string binary_path(Glib::Module::build_path("", "ingen_lv2"));
@@ -181,15 +179,15 @@ normal_bundle_uri(const std::string& uri)
}
void
-Serialiser::write_bundle(SharedPtr<const Patch> patch,
- const std::string& path)
+Serialiser::write_bundle(SharedPtr<const GraphObject> patch,
+ const std::string& path)
{
me->write_bundle(patch, path);
}
void
-Serialiser::Impl::write_bundle(SharedPtr<const Patch> patch,
- const std::string& a_path)
+Serialiser::Impl::write_bundle(SharedPtr<const GraphObject> patch,
+ const std::string& a_path)
{
std::string path = Glib::filename_from_uri(a_path);
if (Glib::file_test(path, Glib::FILE_TEST_EXISTS)
@@ -307,32 +305,24 @@ Serialiser::serialise(SharedPtr<const GraphObject> object) throw (std::logic_err
if (!me->_model)
throw std::logic_error("serialise called without serialisation in progress");
- SharedPtr<const Patch> patch = PtrCast<const Patch>(object);
- if (patch) {
- me->serialise_patch(patch, me->path_rdf_node(patch->path()));
- return;
- }
-
- SharedPtr<const Node> node = PtrCast<const Node>(object);
- if (node) {
- const Sord::URI plugin_id(me->_model->world(), node->plugin()->uri().str());
- me->serialise_node(node, plugin_id, me->path_rdf_node(node->path()));
- return;
- }
-
- SharedPtr<const Port> port = PtrCast<const Port>(object);
- if (port) {
- me->serialise_port(port.get(), Resource::DEFAULT, me->path_rdf_node(port->path()));
- return;
+ if (object->graph_type() == GraphObject::PATCH) {
+ me->serialise_patch(object, me->path_rdf_node(object->path()));
+ } else if (object->graph_type() == GraphObject::NODE) {
+ const Sord::URI plugin_id(me->_model->world(), object->plugin()->uri().str());
+ me->serialise_node(object, plugin_id, me->path_rdf_node(object->path()));
+ } else if (object->graph_type() == GraphObject::PORT) {
+ me->serialise_port(object.get(),
+ Resource::DEFAULT,
+ me->path_rdf_node(object->path()));
+ } else {
+ LOG(warn) << "Unsupported object type, "
+ << object->path() << " not serialised." << endl;
}
-
- LOG(warn) << "Unsupported object type, "
- << object->path() << " not serialised." << endl;
}
void
-Serialiser::Impl::serialise_patch(SharedPtr<const Patch> patch,
- const Sord::Node& patch_id)
+Serialiser::Impl::serialise_patch(SharedPtr<const GraphObject> patch,
+ const Sord::Node& patch_id)
{
assert(_model);
Sord::World& world = _model->world();
@@ -386,9 +376,9 @@ Serialiser::Impl::serialise_patch(SharedPtr<const Patch> patch,
if (n->first.parent() != patch->path())
continue;
- SharedPtr<Patch> subpatch = PtrCast<Patch>(n->second);
- SharedPtr<Node> node = PtrCast<Node>(n->second);
- if (subpatch) {
+ if (n->second->graph_type() == GraphObject::PATCH) {
+ SharedPtr<GraphObject> subpatch = n->second;
+
SerdURI base_uri;
serd_uri_parse((const uint8_t*)_base_uri.c_str(), &base_uri);
@@ -419,7 +409,9 @@ Serialiser::Impl::serialise_patch(SharedPtr<const Patch> patch,
Sord::Curie(world, "ingen:node"),
node_id);
serialise_node(subpatch, subpatch_id, node_id);
- } else if (node) {
+ } else if (n->second->graph_type() == GraphObject::NODE) {
+ SharedPtr<const GraphObject> node = n->second;
+
const Sord::URI class_id(world, node->plugin()->uri().str());
const Sord::Node node_id(path_rdf_node(n->second->path()));
_model->add_statement(patch_id,
@@ -430,7 +422,7 @@ Serialiser::Impl::serialise_patch(SharedPtr<const Patch> patch,
}
for (uint32_t i = 0; i < patch->num_ports(); ++i) {
- Port* p = patch->port(i);
+ GraphObject* p = patch->port(i);
const Sord::Node port_id = path_rdf_node(p->path());
// Ensure lv2:name always exists so Patch is a valid LV2 plugin
@@ -444,16 +436,16 @@ Serialiser::Impl::serialise_patch(SharedPtr<const Patch> patch,
serialise_port(p, Resource::INTERNAL, port_id);
}
- for (Patch::Edges::const_iterator c = patch->edges().begin();
+ for (GraphObject::Edges::const_iterator c = patch->edges().begin();
c != patch->edges().end(); ++c) {
serialise_edge(patch_id, c->second);
}
}
void
-Serialiser::Impl::serialise_node(SharedPtr<const Node> node,
- const Sord::Node& class_id,
- const Sord::Node& node_id)
+Serialiser::Impl::serialise_node(SharedPtr<const GraphObject> node,
+ const Sord::Node& class_id,
+ const Sord::Node& node_id)
{
_model->add_statement(node_id,
Sord::Curie(_model->world(), "rdf:type"),
@@ -469,8 +461,8 @@ Serialiser::Impl::serialise_node(SharedPtr<const Node> node,
serialise_properties(node_id, props);
for (uint32_t i = 0; i < node->num_ports(); ++i) {
- Port* const p = node->port(i);
- const Sord::Node port_id = path_rdf_node(p->path());
+ GraphObject* const p = node->port(i);
+ const Sord::Node port_id = path_rdf_node(p->path());
serialise_port(p, Resource::EXTERNAL, port_id);
_model->add_statement(node_id,
Sord::Curie(_model->world(), "lv2:port"),
@@ -479,29 +471,20 @@ Serialiser::Impl::serialise_node(SharedPtr<const Node> node,
}
void
-Serialiser::Impl::serialise_port(const Port* port,
- Resource::Graph context,
- const Sord::Node& port_id)
+Serialiser::Impl::serialise_port(const GraphObject* port,
+ Resource::Graph context,
+ const Sord::Node& port_id)
{
Sord::World& world = _model->world();
- if (port->is_input()) {
- _model->add_statement(port_id,
- Sord::Curie(world, "rdf:type"),
- Sord::Curie(world, "lv2:InputPort"));
- } else {
- _model->add_statement(port_id,
- Sord::Curie(world, "rdf:type"),
- Sord::Curie(world, "lv2:OutputPort"));
- }
-
_model->add_statement(port_id,
Sord::Curie(world, "lv2:symbol"),
Sord::Literal(world, port->path().symbol()));
GraphObject::Properties props = port->properties(context);
if (context == Resource::INTERNAL) {
- props.insert(make_pair(_world.uris().lv2_default, port->value()));
+ props.insert(make_pair(_world.uris().lv2_default,
+ _world.uris().ingen_value));
}
serialise_properties(port_id, props);
diff --git a/src/server/Context.hpp b/src/server/Context.hpp
index caebd7a4..70bf9949 100644
--- a/src/server/Context.hpp
+++ b/src/server/Context.hpp
@@ -17,9 +17,9 @@
#ifndef INGEN_ENGINE_CONTEXT_HPP
#define INGEN_ENGINE_CONTEXT_HPP
-#include "raul/RingBuffer.hpp"
-
#include "ingen/shared/World.hpp"
+#include "raul/Atom.hpp"
+#include "raul/RingBuffer.hpp"
#include "types.hpp"
diff --git a/src/server/EdgeImpl.hpp b/src/server/EdgeImpl.hpp
index b93d65f6..23a22ba3 100644
--- a/src/server/EdgeImpl.hpp
+++ b/src/server/EdgeImpl.hpp
@@ -52,8 +52,7 @@ class BufferFactory;
* \ingroup engine
*/
class EdgeImpl
- : public Raul::Deletable
- , private Raul::Noncopyable
+ : private Raul::Noncopyable
, public Edge
, public boost::intrusive::slist_base_hook<
boost::intrusive::link_mode<boost::intrusive::auto_unlink> >
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 70d3662c..90d01cca 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -17,8 +17,6 @@
#include <cstdlib>
#include <cassert>
-#include "ingen/Patch.hpp"
-
#include "BufferFactory.hpp"
#include "EdgeImpl.hpp"
#include "Engine.hpp"
@@ -48,8 +46,9 @@ InputPort::InputPort(BufferFactory& bufs,
{
const Ingen::Shared::URIs& uris = bufs.uris();
- if (!dynamic_cast<Patch*>(parent))
+ if (parent->graph_type() != GraphObject::PATCH) {
add_property(uris.rdf_type, uris.lv2_InputPort);
+ }
// Set default control range
if (type == PortType::CONTROL || type == PortType::CV) {
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 0316c401..3dcf6072 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -468,7 +468,7 @@ JackDriver::_session_cb(jack_session_event_t* event)
SharedPtr<Serialisation::Serialiser> serialiser = _engine.world()->serialiser();
if (serialiser) {
- SharedPtr<Patch> root(_engine.root_patch(), NullDeleter<Patch>);
+ SharedPtr<GraphObject> root(_engine.root_patch(), NullDeleter<GraphObject>);
serialiser->write_bundle(root, string("file://") + event->session_dir);
}
diff --git a/src/server/LV2ResizeFeature.hpp b/src/server/LV2ResizeFeature.hpp
index a2d9e8b6..978a1c8f 100644
--- a/src/server/LV2ResizeFeature.hpp
+++ b/src/server/LV2ResizeFeature.hpp
@@ -46,7 +46,7 @@ struct ResizeFeature : public Ingen::Shared::LV2Features::Feature {
free(feature);
}
- SharedPtr<LV2_Feature> feature(Shared::World* w, Node* n) {
+ SharedPtr<LV2_Feature> feature(Shared::World* w, GraphObject* n) {
NodeImpl* node = dynamic_cast<NodeImpl*>(n);
if (!node)
return SharedPtr<LV2_Feature>();
diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp
index 39affd63..2b465b76 100644
--- a/src/server/NodeImpl.cpp
+++ b/src/server/NodeImpl.cpp
@@ -62,7 +62,7 @@ NodeImpl::~NodeImpl()
delete _ports;
}
-Port*
+GraphObject*
NodeImpl::port(uint32_t index) const
{
return (*_ports)[index];
diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp
index 995450f3..f9509e49 100644
--- a/src/server/NodeImpl.hpp
+++ b/src/server/NodeImpl.hpp
@@ -20,7 +20,6 @@
#include <list>
#include <string>
-#include "ingen/Node.hpp"
#include "raul/Array.hpp"
#include "raul/AtomicInt.hpp"
#include "raul/Semaphore.hpp"
@@ -39,7 +38,6 @@ class Maid;
namespace Ingen {
class Plugin;
-class Port;
namespace Server {
@@ -59,7 +57,7 @@ class ProcessContext;
*
* \ingroup engine
*/
-class NodeImpl : public GraphObjectImpl, virtual public Node
+class NodeImpl : public GraphObjectImpl
{
public:
NodeImpl(PluginImpl* plugin,
@@ -70,6 +68,8 @@ public:
virtual ~NodeImpl();
+ virtual GraphType graph_type() const { return NODE; }
+
/** Activate this Node.
*
* This function must be called in a non-realtime thread before it is
@@ -142,8 +142,8 @@ public:
BufferRef buf,
SampleCount offset);
- virtual Port* port(uint32_t index) const;
- virtual PortImpl* port_impl(uint32_t index) const { return (*_ports)[index]; }
+ virtual GraphObject* port(uint32_t index) const;
+ virtual PortImpl* port_impl(uint32_t index) const { return (*_ports)[index]; }
/** Nodes that are connected to this Node's inputs. */
std::list<NodeImpl*>& providers() { return _providers; }
diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp
index eee852f5..30650f90 100644
--- a/src/server/OutputPort.cpp
+++ b/src/server/OutputPort.cpp
@@ -14,14 +14,13 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "ingen/Patch.hpp"
+#include "ingen/shared/URIs.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
#include "Engine.hpp"
#include "NodeImpl.hpp"
#include "OutputPort.hpp"
-#include "ingen/shared/URIs.hpp"
using namespace std;
@@ -39,8 +38,9 @@ OutputPort::OutputPort(BufferFactory& bufs,
size_t buffer_size)
: PortImpl(bufs, parent, symbol, index, poly, type, buffer_type, value, buffer_size)
{
- if (!dynamic_cast<Patch*>(parent))
+ if (parent->graph_type() != GraphObject::PATCH) {
add_property(bufs.uris().rdf_type, bufs.uris().lv2_OutputPort);
+ }
_broadcast = true;
diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp
index 0a8d5547..1d8cef08 100644
--- a/src/server/PatchImpl.hpp
+++ b/src/server/PatchImpl.hpp
@@ -21,7 +21,6 @@
#include <list>
#include <string>
-#include "ingen/Patch.hpp"
#include "raul/List.hpp"
#include "CompiledPatch.hpp"
@@ -50,7 +49,7 @@ class ProcessContext;
*
* \ingroup engine
*/
-class PatchImpl : public NodeImpl, public Patch
+class PatchImpl : public NodeImpl
{
public:
PatchImpl(Engine& engine,
@@ -62,6 +61,8 @@ public:
virtual ~PatchImpl();
+ virtual GraphType graph_type() const { return PATCH; }
+
void activate(BufferFactory& bufs);
void deactivate();
@@ -100,11 +101,8 @@ public:
void add_node(Nodes::Node* tn);
Nodes::Node* remove_node(const Raul::Symbol& symbol);
- Nodes& nodes() { return _nodes; }
- Edges& edges() { return _edges; }
-
+ Nodes& nodes() { return _nodes; }
const Nodes& nodes() const { return _nodes; }
- const Edges& edges() const { return _edges; }
uint32_t num_ports_non_rt() const;
@@ -165,7 +163,6 @@ private:
uint32_t _poly_pre; ///< Pre-process thread only
uint32_t _poly_process; ///< Process thread only
CompiledPatch* _compiled_patch; ///< 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/PortImpl.hpp b/src/server/PortImpl.hpp
index 690461cc..63efb64f 100644
--- a/src/server/PortImpl.hpp
+++ b/src/server/PortImpl.hpp
@@ -23,8 +23,6 @@
#include "raul/Array.hpp"
#include "raul/Atom.hpp"
-#include "ingen/Port.hpp"
-
#include "Buffer.hpp"
#include "BufferRef.hpp"
#include "Context.hpp"
@@ -48,11 +46,13 @@ class BufferFactory;
*
* \ingroup engine
*/
-class PortImpl : public GraphObjectImpl, public Port
+class PortImpl : public GraphObjectImpl
{
public:
~PortImpl();
+ virtual GraphType graph_type() const { return PORT; }
+
/** A port's parent is always a node, so static cast should be safe */
NodeImpl* parent_node() const { return (NodeImpl*)_parent; }
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 006b45d4..58cf6104 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -80,7 +80,7 @@ delete_feature(LV2_Feature* feature)
}
SharedPtr<LV2_Feature>
-Worker::Schedule::feature(Shared::World* world, Node* n)
+Worker::Schedule::feature(Shared::World* world, GraphObject* n)
{
LV2Node* node = dynamic_cast<LV2Node*>(n);
if (!node) {
diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp
index c390564e..785c8fa2 100644
--- a/src/server/Worker.hpp
+++ b/src/server/Worker.hpp
@@ -34,7 +34,7 @@ public:
Worker(uint32_t buffer_size);
struct Schedule : public Shared::LV2Features::Feature {
- SharedPtr<LV2_Feature> feature(Shared::World* world, Node* n);
+ SharedPtr<LV2_Feature> feature(Shared::World* world, GraphObject* n);
};
LV2_Worker_Status request(LV2Node* node,
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 13d6e00f..33cd236b 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -111,7 +111,7 @@ DisconnectAll::pre_process()
// Find set of edges to remove
std::set<EdgeImpl*> to_remove;
- for (Patch::Edges::const_iterator i = _parent->edges().begin();
+ for (GraphObject::Edges::const_iterator i = _parent->edges().begin();
i != _parent->edges().end(); ++i) {
EdgeImpl* const c = (EdgeImpl*)i->second.get();
if (_node) {
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp
index 944b00ce..dadd2989 100644
--- a/src/shared/Builder.cpp
+++ b/src/shared/Builder.cpp
@@ -15,6 +15,7 @@
*/
#include "ingen/Edge.hpp"
+#include "ingen/GraphObject.hpp"
#include "ingen/Interface.hpp"
#include "ingen/shared/Builder.hpp"
#include "ingen/shared/URIs.hpp"
@@ -41,10 +42,9 @@ Builder::build(SharedPtr<const GraphObject> object)
void
Builder::connect(SharedPtr<const GraphObject> object)
{
- SharedPtr<const Patch> patch = PtrCast<const Patch>(object);
- if (patch) {
- for (Patch::Edges::const_iterator i = patch->edges().begin();
- i != patch->edges().end(); ++i) {
+ if (object->graph_type() == GraphObject::PATCH) {
+ for (GraphObject::Edges::const_iterator i = object->edges().begin();
+ i != object->edges().end(); ++i) {
_interface.connect(i->second->tail_path(), i->second->head_path());
}
return;
diff --git a/src/shared/LV2Features.cpp b/src/shared/LV2Features.cpp
index 24b3f6fa..7061ff76 100644
--- a/src/shared/LV2Features.cpp
+++ b/src/shared/LV2Features.cpp
@@ -49,7 +49,7 @@ LV2Features::FeatureArray::~FeatureArray()
}
SharedPtr<LV2Features::FeatureArray>
-LV2Features::lv2_features(Shared::World* world, Node* node) const
+LV2Features::lv2_features(Shared::World* world, GraphObject* node) const
{
FeatureArray::FeatureVector vec;
for (Features::const_iterator f = _features.begin(); f != _features.end(); ++f) {
diff --git a/src/shared/Store.cpp b/src/shared/Store.cpp
index 821322e7..ad950fd7 100644
--- a/src/shared/Store.cpp
+++ b/src/shared/Store.cpp
@@ -17,8 +17,7 @@
#include <sstream>
#include <string>
-#include "ingen/Node.hpp"
-#include "ingen/Port.hpp"
+#include "ingen/GraphObject.hpp"
#include "ingen/shared/Store.hpp"
#include "raul/PathTable.hpp"
#include "raul/TableImpl.hpp"
@@ -39,11 +38,8 @@ Store::add(GraphObject* o)
insert(make_pair(o->path(), o));
- Node* node = dynamic_cast<Node*>(o);
- if (node) {
- for (uint32_t i=0; i < node->num_ports(); ++i) {
- add(node->port(i));
- }
+ for (uint32_t i = 0; i < o->num_ports(); ++i) {
+ add(o->port(i));
}
}