summaryrefslogtreecommitdiffstats
path: root/ingen
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 /ingen
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
Diffstat (limited to 'ingen')
-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
11 files changed, 52 insertions, 182 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>);
}