From fa6bb9afe8fcf2b0b8348495b9c4e1d6425136f0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 15 Feb 2017 23:18:59 +0100 Subject: Move Properties out of Resource --- ingen/Resource.hpp | 63 +++--------------------------------------------------- 1 file changed, 3 insertions(+), 60 deletions(-) (limited to 'ingen/Resource.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 #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 { - public: - Properties() {} - - Properties(const Properties& copy) - : std::multimap(copy) - {} - - Properties(std::initializer_list l) - : std::multimap(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 -- cgit v1.2.1