diff options
author | David Robillard <d@drobilla.net> | 2017-02-15 23:18:59 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-02-15 23:26:03 +0100 |
commit | fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0 (patch) | |
tree | e69cd957486b3fe8a82c0b56f26aec0a23b8235c /ingen/Resource.hpp | |
parent | 2ba09e4b41b01cbd8f8756eb0e3b7e33136e06b3 (diff) | |
download | ingen-fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0.tar.gz ingen-fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0.tar.bz2 ingen-fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0.zip |
Move Properties out of Resource
Diffstat (limited to 'ingen/Resource.hpp')
-rw-r--r-- | ingen/Resource.hpp | 63 |
1 files changed, 3 insertions, 60 deletions
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 |