summaryrefslogtreecommitdiffstats
path: root/ingen
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-02-15 23:18:59 +0100
committerDavid Robillard <d@drobilla.net>2017-02-15 23:26:03 +0100
commitfa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0 (patch)
treee69cd957486b3fe8a82c0b56f26aec0a23b8235c /ingen
parent2ba09e4b41b01cbd8f8756eb0e3b7e33136e06b3 (diff)
downloadingen-fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0.tar.gz
ingen-fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0.tar.bz2
ingen-fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0.zip
Move Properties out of Resource
Diffstat (limited to 'ingen')
-rw-r--r--ingen/AtomReader.hpp4
-rw-r--r--ingen/AtomWriter.hpp14
-rw-r--r--ingen/Interface.hpp12
-rw-r--r--ingen/Parser.hpp2
-rw-r--r--ingen/Properties.hpp92
-rw-r--r--ingen/Resource.hpp63
-rw-r--r--ingen/Tee.hpp12
-rw-r--r--ingen/client/ClientStore.hpp12
-rw-r--r--ingen/client/PluginModel.hpp8
-rw-r--r--ingen/client/SigClientInterface.hpp16
-rw-r--r--ingen/client/ThreadedSigClientInterface.hpp15
11 files changed, 141 insertions, 109 deletions
diff --git a/ingen/AtomReader.hpp b/ingen/AtomReader.hpp
index 1c1dea5b..8a1a80aa 100644
--- a/ingen/AtomReader.hpp
+++ b/ingen/AtomReader.hpp
@@ -52,8 +52,8 @@ private:
boost::optional<Raul::URI> atom_to_uri(const LV2_Atom* atom);
boost::optional<Raul::Path> atom_to_path(const LV2_Atom* atom);
- void get_props(const LV2_Atom_Object* obj,
- Ingen::Resource::Properties& props);
+ void get_props(const LV2_Atom_Object* obj,
+ Ingen::Properties& props);
URIMap& _map;
URIs& _uris;
diff --git a/ingen/AtomWriter.hpp b/ingen/AtomWriter.hpp
index 4246e884..35db84a4 100644
--- a/ingen/AtomWriter.hpp
+++ b/ingen/AtomWriter.hpp
@@ -46,13 +46,13 @@ public:
void bundle_end();
- void put(const Raul::URI& uri,
- const Resource::Properties& properties,
- Resource::Graph ctx = Resource::Graph::DEFAULT);
+ void put(const Raul::URI& uri,
+ const Properties& properties,
+ Resource::Graph ctx = Resource::Graph::DEFAULT);
- void delta(const Raul::URI& uri,
- const Resource::Properties& remove,
- const Resource::Properties& add);
+ void delta(const Raul::URI& uri,
+ const Properties& remove,
+ const Properties& add);
void copy(const Raul::URI& old_uri,
const Raul::URI& new_uri);
@@ -89,7 +89,7 @@ public:
private:
void forge_uri(const Raul::URI& uri);
- void forge_properties(const Resource::Properties& properties);
+ void forge_properties(const Properties& properties);
void forge_arc(const Raul::Path& tail, const Raul::Path& head);
void forge_request(LV2_Atom_Forge_Frame* frame, LV2_URID type);
diff --git a/ingen/Interface.hpp b/ingen/Interface.hpp
index 8a79f269..e37888f9 100644
--- a/ingen/Interface.hpp
+++ b/ingen/Interface.hpp
@@ -64,13 +64,13 @@ public:
/** End a transaction. */
virtual void bundle_end() = 0;
- virtual void put(const Raul::URI& uri,
- const Resource::Properties& properties,
- Resource::Graph ctx=Resource::Graph::DEFAULT) = 0;
+ virtual void put(const Raul::URI& uri,
+ const Properties& properties,
+ Resource::Graph ctx = Resource::Graph::DEFAULT) = 0;
- virtual void delta(const Raul::URI& uri,
- const Resource::Properties& remove,
- const Resource::Properties& add) = 0;
+ virtual void delta(const Raul::URI& uri,
+ const Properties& remove,
+ const Properties& add) = 0;
virtual void copy(const Raul::URI& old_uri,
const Raul::URI& new_uri) = 0;
diff --git a/ingen/Parser.hpp b/ingen/Parser.hpp
index d6065e59..dd3bfb46 100644
--- a/ingen/Parser.hpp
+++ b/ingen/Parser.hpp
@@ -44,8 +44,6 @@ public:
virtual ~Parser() {}
- typedef Node::Properties Properties;
-
/** Record of a resource listed in a bundle manifest. */
struct ResourceRecord {
inline ResourceRecord(const std::string& u, const std::string& f)
diff --git a/ingen/Properties.hpp b/ingen/Properties.hpp
new file mode 100644
index 00000000..ef608574
--- /dev/null
+++ b/ingen/Properties.hpp
@@ -0,0 +1,92 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2017 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_PROPERTIES_HPP
+#define INGEN_PROPERTIES_HPP
+
+#include <map>
+
+#include "ingen/Atom.hpp"
+#include "ingen/URIs.hpp"
+#include "raul/URI.hpp"
+
+namespace Ingen {
+
+/** A property value (an Atom with a context). */
+class Property : public Atom {
+public:
+ enum class Graph {
+ DEFAULT,
+ EXTERNAL,
+ INTERNAL
+ };
+
+ Property(const Atom& atom, Graph ctx=Graph::DEFAULT)
+ : Atom(atom)
+ , _ctx(ctx)
+ {}
+
+ Property(const URIs::Quark& quark, Graph ctx=Graph::DEFAULT)
+ : Atom(quark.urid)
+ , _ctx(ctx)
+ {}
+
+ Graph context() const { return _ctx; }
+ void set_context(Graph ctx) { _ctx = ctx; }
+
+private:
+ Graph _ctx;
+};
+
+class Properties : public std::multimap<Raul::URI, Property> {
+public:
+ using Graph = Property::Graph;
+
+ Properties() {}
+
+ Properties(const Properties& copy)
+ : std::multimap<Raul::URI, Property>(copy)
+ {}
+
+ Properties(std::initializer_list<value_type> l)
+ : std::multimap<Raul::URI, Property>(l)
+ {}
+
+ void put(const Raul::URI& key,
+ const Atom& value,
+ Graph ctx = Graph::DEFAULT) {
+ insert(std::make_pair(key, Property(value, ctx)));
+ }
+
+ void put(const Raul::URI& key,
+ const URIs::Quark& value,
+ Graph ctx = Graph::DEFAULT) {
+ insert(std::make_pair(key, Property(value, ctx)));
+ }
+
+ bool contains(const Raul::URI& key, const Atom& value) {
+ for (const_iterator i = find(key); i != end() && i->first == key; ++i) {
+ if (i->second == value) {
+ return true;
+ }
+ }
+ return false;
+ }
+};
+
+} // namespace Ingen
+
+#endif // INGEN_PROPERTIES_HPP
diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp
index 39452522..3eb1349f 100644
--- a/ingen/Resource.hpp
+++ b/ingen/Resource.hpp
@@ -21,6 +21,7 @@
#include <string>
#include "ingen/Atom.hpp"
+#include "ingen/Properties.hpp"
#include "ingen/URIs.hpp"
#include "ingen/ingen.h"
#include "raul/Deletable.hpp"
@@ -38,6 +39,8 @@ namespace Ingen {
class INGEN_API Resource : public Raul::Deletable
{
public:
+ using Graph = Property::Graph;
+
Resource(const URIs& uris, const Raul::URI& uri)
: _uris(uris)
, _uri(uri)
@@ -52,12 +55,6 @@ public:
return *this;
}
- enum class Graph {
- DEFAULT,
- EXTERNAL,
- INTERNAL
- };
-
static Raul::URI graph_to_uri(Graph g) {
switch (g) {
case Graph::DEFAULT: return Raul::URI(INGEN_NS "defaultContext");
@@ -81,62 +78,8 @@ public:
}
}
- /** A property value (an Atom with a context). */
- class Property : public Atom {
- public:
- Property(const Atom& atom, Graph ctx=Graph::DEFAULT)
- : Atom(atom)
- , _ctx(ctx)
- {}
-
- Property(const URIs::Quark& quark, Graph ctx=Graph::DEFAULT)
- : Atom(quark.urid)
- , _ctx(ctx)
- {}
-
- Graph context() const { return _ctx; }
- void set_context(Graph ctx) { _ctx = ctx; }
-
- private:
- Graph _ctx;
- };
-
virtual ~Resource() {}
- class Properties : public std::multimap<Raul::URI, Property> {
- public:
- Properties() {}
-
- Properties(const Properties& copy)
- : std::multimap<Raul::URI, Property>(copy)
- {}
-
- Properties(std::initializer_list<value_type> l)
- : std::multimap<Raul::URI, Property>(l)
- {}
-
- void put(const Raul::URI& key,
- const Atom& value,
- Graph ctx = Graph::DEFAULT) {
- insert(std::make_pair(key, Property(value, ctx)));
- }
-
- void put(const Raul::URI& key,
- const URIs::Quark& value,
- Graph ctx = Graph::DEFAULT) {
- insert(std::make_pair(key, Property(value, ctx)));
- }
-
- bool contains(const Raul::URI& key, const Atom& value) {
- for (const_iterator i = find(key); i != end() && i->first == key; ++i) {
- if (i->second == value) {
- return true;
- }
- }
- return false;
- }
- };
-
/** Get a single property value.
*
* This is only useful for properties with a single value. If the
diff --git a/ingen/Tee.hpp b/ingen/Tee.hpp
index 1577f6dd..2cbd84d6 100644
--- a/ingen/Tee.hpp
+++ b/ingen/Tee.hpp
@@ -63,15 +63,15 @@ public:
void bundle_begin() { BROADCAST(bundle_begin); }
void bundle_end() { BROADCAST(bundle_end); }
- void put(const Raul::URI& uri,
- const Resource::Properties& properties,
- Resource::Graph ctx=Resource::Graph::DEFAULT) {
+ void put(const Raul::URI& uri,
+ const Properties& properties,
+ Resource::Graph ctx = Resource::Graph::DEFAULT) {
BROADCAST(put, uri, properties);
}
- void delta(const Raul::URI& uri,
- const Resource::Properties& remove,
- const Resource::Properties& add) {
+ void delta(const Raul::URI& uri,
+ const Properties& remove,
+ const Properties& add) {
BROADCAST(delta, uri, remove, add);
}
diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp
index de603458..84a95b7b 100644
--- a/ingen/client/ClientStore.hpp
+++ b/ingen/client/ClientStore.hpp
@@ -73,13 +73,13 @@ public:
URIs& uris() { return _uris; }
- void put(const Raul::URI& uri,
- const Resource::Properties& properties,
- Resource::Graph ctx=Resource::Graph::DEFAULT);
+ void put(const Raul::URI& uri,
+ const Properties& properties,
+ Resource::Graph ctx = Resource::Graph::DEFAULT);
- void delta(const Raul::URI& uri,
- const Resource::Properties& remove,
- const Resource::Properties& add);
+ void delta(const Raul::URI& uri,
+ const Properties& remove,
+ const Properties& add);
void copy(const Raul::URI& old_uri,
const Raul::URI& new_uri);
diff --git a/ingen/client/PluginModel.hpp b/ingen/client/PluginModel.hpp
index e468aede..ad425904 100644
--- a/ingen/client/PluginModel.hpp
+++ b/ingen/client/PluginModel.hpp
@@ -48,10 +48,10 @@ class PluginUI;
class INGEN_API PluginModel : public Ingen::Resource
{
public:
- PluginModel(URIs& uris,
- const Raul::URI& uri,
- const Atom& type,
- const Ingen::Resource::Properties& properties);
+ PluginModel(URIs& uris,
+ const Raul::URI& uri,
+ const Atom& type,
+ const Ingen::Properties& properties);
const Atom& type() const { return _type; }
const Raul::URI type_uri() const {
diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp
index 33430480..a65806f4 100644
--- a/ingen/client/SigClientInterface.hpp
+++ b/ingen/client/SigClientInterface.hpp
@@ -52,8 +52,8 @@ public:
INGEN_SIGNAL(bundle_begin, void)
INGEN_SIGNAL(bundle_end, void)
INGEN_SIGNAL(error, void, std::string)
- INGEN_SIGNAL(put, void, Raul::URI, Resource::Properties, Resource::Graph)
- INGEN_SIGNAL(delta, void, Raul::URI, Resource::Properties, Resource::Properties)
+ INGEN_SIGNAL(put, void, Raul::URI, Properties, Resource::Graph)
+ INGEN_SIGNAL(delta, void, Raul::URI, Properties, Properties)
INGEN_SIGNAL(object_copied, void, Raul::URI, Raul::URI)
INGEN_SIGNAL(object_moved, void, Raul::Path, Raul::Path)
INGEN_SIGNAL(object_deleted, void, Raul::URI)
@@ -83,14 +83,14 @@ protected:
void error(const std::string& msg)
{ EMIT(error, msg); }
- void put(const Raul::URI& uri,
- const Resource::Properties& properties,
- Resource::Graph ctx=Resource::Graph::DEFAULT)
+ void put(const Raul::URI& uri,
+ const Properties& properties,
+ Resource::Graph ctx = Resource::Graph::DEFAULT)
{ EMIT(put, uri, properties, ctx); }
- void delta(const Raul::URI& uri,
- const Resource::Properties& remove,
- const Resource::Properties& add)
+ void delta(const Raul::URI& uri,
+ const Properties& remove,
+ const Properties& add)
{ EMIT(delta, uri, remove, add); }
void connect(const Raul::Path& tail, const Raul::Path& head)
diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp
index 79795421..db3aad44 100644
--- a/ingen/client/ThreadedSigClientInterface.hpp
+++ b/ingen/client/ThreadedSigClientInterface.hpp
@@ -80,14 +80,14 @@ public:
void error(const std::string& msg)
{ push_sig(sigc::bind(error_slot, msg)); }
- void put(const Raul::URI& path,
- const Resource::Properties& properties,
- Resource::Graph ctx=Resource::Graph::DEFAULT)
+ void put(const Raul::URI& path,
+ const Properties& properties,
+ Resource::Graph ctx = Resource::Graph::DEFAULT)
{ push_sig(sigc::bind(put_slot, path, properties, ctx)); }
- void delta(const Raul::URI& path,
- const Resource::Properties& remove,
- const Resource::Properties& add)
+ void delta(const Raul::URI& path,
+ const Properties& remove,
+ const Properties& add)
{ push_sig(sigc::bind(delta_slot, path, remove, add)); }
void connect(const Raul::Path& tail, const Raul::Path& head)
@@ -149,8 +149,7 @@ private:
Raul::SRSWQueue<Closure> _sigs;
- typedef Resource::Properties Properties;
- typedef Resource::Graph Graph;
+ typedef Resource::Graph Graph;
sigc::slot<void> bundle_begin_slot;
sigc::slot<void> bundle_end_slot;