summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-07-30 23:22:44 +0000
committerDavid Robillard <d@drobilla.net>2012-07-30 23:22:44 +0000
commit9088edb2534a616b757197662d77abcb0291470b (patch)
treefc3c86d6a7af39642768d4b864dd38438f9a2e48 /ingen
parent0e1bf6ddfc77866ff6477a3f394c030c2a5e1b39 (diff)
downloadingen-9088edb2534a616b757197662d77abcb0291470b.tar.gz
ingen-9088edb2534a616b757197662d77abcb0291470b.tar.bz2
ingen-9088edb2534a616b757197662d77abcb0291470b.zip
Merge Resource and ResourceImpl, eliminating more virtual inheritance.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4577 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'ingen')
-rw-r--r--ingen/GraphObject.hpp8
-rw-r--r--ingen/Plugin.hpp6
-rw-r--r--ingen/Resource.hpp62
-rw-r--r--ingen/client/ObjectModel.hpp5
-rw-r--r--ingen/client/PluginModel.hpp5
-rw-r--r--ingen/shared/ResourceImpl.hpp97
6 files changed, 67 insertions, 116 deletions
diff --git a/ingen/GraphObject.hpp b/ingen/GraphObject.hpp
index a0d5ec22..a8bee0b0 100644
--- a/ingen/GraphObject.hpp
+++ b/ingen/GraphObject.hpp
@@ -19,6 +19,7 @@
#include "ingen/Resource.hpp"
#include "raul/Deletable.hpp"
+#include "raul/Path.hpp"
#include "raul/SharedPtr.hpp"
namespace Raul {
@@ -36,8 +37,7 @@ class Plugin;
*
* @ingroup Ingen
*/
-class GraphObject : public Raul::Deletable
- , public virtual Resource
+class GraphObject : public Resource
{
public:
virtual void set_path(const Raul::Path& path) = 0;
@@ -67,6 +67,10 @@ public:
virtual GraphObject* graph_parent() const = 0;
protected:
+ GraphObject(Shared::URIs& uris, const Raul::Path& path)
+ : Resource(uris, path)
+ {}
+
Edges _edges; ///< Patches only
};
diff --git a/ingen/Plugin.hpp b/ingen/Plugin.hpp
index 41de5a2a..30c70963 100644
--- a/ingen/Plugin.hpp
+++ b/ingen/Plugin.hpp
@@ -28,9 +28,13 @@ namespace Ingen {
/** A plugin which instantiates to a Node.
* @ingroup Ingen
*/
-class Plugin : virtual public Resource
+class Plugin : public Resource
{
public:
+ Plugin(Shared::URIs& uris, const Raul::URI& uri)
+ : Resource(uris, uri)
+ {}
+
enum Type { NIL, LV2, Internal, Patch };
virtual Type type() const = 0;
diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp
index 1815bc26..4aed2f6d 100644
--- a/ingen/Resource.hpp
+++ b/ingen/Resource.hpp
@@ -21,9 +21,12 @@
#include <string>
#include "raul/Atom.hpp"
+#include "raul/Deletable.hpp"
#include "raul/URI.hpp"
#include "raul/log.hpp"
+#include "ingen/shared/URIs.hpp"
+
#define NS_INGEN "http://drobilla.net/ns/ingen#"
namespace Ingen {
@@ -31,9 +34,14 @@ namespace Ingen {
/** An object with a URI described by properties.
* @ingroup Ingen
*/
-class Resource
+class Resource : public Raul::Deletable
{
public:
+ Resource(Shared::URIs& uris, const Raul::URI& uri)
+ : _uris(uris)
+ , _uri(uri)
+ {}
+
enum Graph {
DEFAULT,
EXTERNAL,
@@ -86,7 +94,10 @@ public:
virtual ~Resource() {}
- virtual const Raul::URI& uri() const = 0;
+ Shared::URIs& uris() const { return _uris; }
+
+ virtual void set_uri(const Raul::URI& uri) { _uri = uri; }
+ virtual const Raul::URI& uri() const { return _uri; }
typedef std::multimap<Raul::URI, Property> Properties;
@@ -96,22 +107,53 @@ public:
}
}
- virtual Properties properties(Resource::Graph ctx) const = 0;
+ Properties properties(Resource::Graph ctx) const;
- virtual const Properties& properties() const = 0;
- virtual Properties& properties() = 0;
- virtual const Raul::Atom& get_property(const Raul::URI& uri) const = 0;
+ virtual const Properties& properties() const { return _properties; }
+ virtual Properties& properties() { return _properties; }
+ virtual const Raul::Atom& get_property(const Raul::URI& uri) const;
virtual const Raul::Atom& set_property(const Raul::URI& uri,
const Raul::Atom& value,
- Graph ctx=DEFAULT) = 0;
+ Graph ctx=DEFAULT);
virtual void add_property(const Raul::URI& uri,
const Raul::Atom& value,
- Graph ctx=DEFAULT) = 0;
+ Graph ctx=DEFAULT);
+ virtual void remove_property(const Raul::URI& uri,
+ const Raul::Atom& value);
virtual bool has_property(const Raul::URI& uri,
- const Raul::Atom& value) const = 0;
+ const Raul::Atom& value) const;
+
+ void set_properties(const Properties& p);
+ void add_properties(const Properties& p);
+ void remove_properties(const Properties& p);
+
+ /** Hook called whenever a property is added.
+ * This can be used by derived classes to implement special behaviour for
+ * particular properties (e.g. ingen:value for ports).
+ */
+ virtual void on_property(const Raul::URI& uri, const Raul::Atom& value) {}
+
+ /** Get the ingen type from a set of Properties.
+ * If some coherent ingen type is found, true is returned and the appropriate
+ * output parameter set to true. Otherwise false is returned.
+ */
+ static bool type(const Shared::URIs& uris,
+ const Properties& properties,
+ bool& patch,
+ bool& node,
+ bool& port,
+ bool& is_output);
+
+protected:
+ const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const;
+
+ Shared::URIs& _uris;
+
+private:
+ Raul::URI _uri;
+ mutable Properties _properties;
};
} // namespace Ingen
#endif // INGEN_RESOURCE_HPP
-
diff --git a/ingen/client/ObjectModel.hpp b/ingen/client/ObjectModel.hpp
index 2d060a0e..2ff8f898 100644
--- a/ingen/client/ObjectModel.hpp
+++ b/ingen/client/ObjectModel.hpp
@@ -30,8 +30,8 @@
#include "raul/URI.hpp"
#include "ingen/GraphObject.hpp"
+#include "ingen/Resource.hpp"
#include "ingen/client/signal.hpp"
-#include "ingen/shared/ResourceImpl.hpp"
namespace Ingen {
@@ -52,8 +52,7 @@ class ClientStore;
*
* @ingroup IngenClient
*/
-class ObjectModel : virtual public GraphObject
- , public Ingen::Shared::ResourceImpl
+class ObjectModel : public GraphObject
{
public:
virtual ~ObjectModel();
diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp
index 395157ae..0449cb51 100644
--- a/ingen/client/PluginModel.hpp
+++ b/ingen/client/PluginModel.hpp
@@ -26,10 +26,10 @@
#include "raul/Symbol.hpp"
#include "sord/sordmm.hpp"
-#include "ingen/Plugin.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Plugin.hpp"
+#include "ingen/Resource.hpp"
#include "ingen/client/signal.hpp"
-#include "ingen/shared/ResourceImpl.hpp"
#include "ingen/shared/World.hpp"
namespace Ingen {
@@ -47,7 +47,6 @@ class PluginUI;
* @ingroup IngenClient
*/
class PluginModel : public Ingen::Plugin
- , public Ingen::Shared::ResourceImpl
{
public:
PluginModel(Shared::URIs& uris,
diff --git a/ingen/shared/ResourceImpl.hpp b/ingen/shared/ResourceImpl.hpp
deleted file mode 100644
index 157c0365..00000000
--- a/ingen/shared/ResourceImpl.hpp
+++ /dev/null
@@ -1,97 +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_SHARED_RESOURCEIMPL_HPP
-#define INGEN_SHARED_RESOURCEIMPL_HPP
-
-#include "ingen/Resource.hpp"
-#include "ingen/shared/URIs.hpp"
-#include "raul/SharedPtr.hpp"
-#include "raul/URI.hpp"
-
-namespace Ingen {
-namespace Shared {
-
-class URIs;
-
-/** Implementation of a Resource.
- * @ingroup IngenShared
- */
-class ResourceImpl : virtual public Resource
-{
-public:
- ResourceImpl(URIs& uris, const Raul::URI& uri)
- : _uris(uris)
- , _uri(uri)
- {}
-
- URIs& uris() const { return _uris; }
-
- virtual void set_uri(const Raul::URI& uri) { _uri = uri; }
- virtual const Raul::URI& uri() const { return _uri; }
-
- const Properties& properties() const { return _properties; }
- Properties& properties() { return _properties; }
-
- Properties properties(Resource::Graph ctx) const;
-
- const Raul::Atom& get_property(const Raul::URI& uri) const;
-
- const Raul::Atom& set_property(const Raul::URI& uri,
- const Raul::Atom& value,
- Resource::Graph ctx=Resource::DEFAULT);
-
- /** Hook called whenever a property is added.
- * This can be used by derived classes to implement special behaviour for
- * particular properties (e.g. ingen:value for ports).
- */
- virtual void on_property(const Raul::URI& uri, const Raul::Atom& value) {}
-
- void remove_property(const Raul::URI& uri, const Raul::Atom& value);
- bool has_property(const Raul::URI& uri, const Raul::Atom& value) const;
- void add_property(const Raul::URI& uri,
- const Raul::Atom& value,
- Graph ctx = DEFAULT);
- void set_properties(const Properties& p);
- void add_properties(const Properties& p);
- void remove_properties(const Properties& p);
-
- /** Get the ingen type from a set of Properties.
- * If some coherent ingen type is found, true is returned and the appropriate
- * output parameter set to true. Otherwise false is returned.
- */
- static bool type(const URIs& uris,
- const Properties& properties,
- bool& patch,
- bool& node,
- bool& port,
- bool& is_output);
-
-protected:
- const Raul::Atom& set_property(const Raul::URI& uri, const Raul::Atom& value) const;
-
- URIs& _uris;
-
-private:
- Raul::URI _uri;
- mutable Properties _properties;
-};
-
-} // namespace Shared
-} // namespace Ingen
-
-#endif // INGEN_SHARED_RESOURCEIMPL_HPP
-