summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-19 05:10:29 +0000
committerDavid Robillard <d@drobilla.net>2011-02-19 05:10:29 +0000
commit6b18de71d1c603255b263a64434005306f152f13 (patch)
tree09c6e87acca1fe76bc74b3b549fee7ad09751993 /src/common
parent8e07e115429a0869593d4f29dc3e6cf5c8b25049 (diff)
downloadingen-6b18de71d1c603255b263a64434005306f152f13.tar.gz
ingen-6b18de71d1c603255b263a64434005306f152f13.tar.bz2
ingen-6b18de71d1c603255b263a64434005306f152f13.zip
Save/load patches as nested bundles (fix ticket #520).
Sane (context-based, ala RDF quads) approach to the problem of externally visible / internally visible properties. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2993 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/common')
-rw-r--r--src/common/interface/CommonInterface.hpp3
-rw-r--r--src/common/interface/GraphObject.hpp10
-rw-r--r--src/common/interface/Resource.hpp64
3 files changed, 59 insertions, 18 deletions
diff --git a/src/common/interface/CommonInterface.hpp b/src/common/interface/CommonInterface.hpp
index efd80050..cbf3573c 100644
--- a/src/common/interface/CommonInterface.hpp
+++ b/src/common/interface/CommonInterface.hpp
@@ -46,7 +46,8 @@ public:
virtual void bundle_end() = 0;
virtual void put(const Raul::URI& uri,
- const Resource::Properties& properties) = 0;
+ const Resource::Properties& properties,
+ Resource::Graph ctx=Resource::DEFAULT) = 0;
virtual void delta(const Raul::URI& uri,
const Resource::Properties& remove,
diff --git a/src/common/interface/GraphObject.hpp b/src/common/interface/GraphObject.hpp
index de908cc5..ed592971 100644
--- a/src/common/interface/GraphObject.hpp
+++ b/src/common/interface/GraphObject.hpp
@@ -39,15 +39,11 @@ class GraphObject : public Raul::Deletable
, public virtual Resource
{
public:
- virtual const Resource& meta() const = 0;
- virtual Resource& meta() = 0;
-
virtual void set_path(const Raul::Path& path) = 0;
- virtual const Raul::Path& path() const = 0;
- virtual const Raul::Symbol& symbol() const = 0;
-
- virtual GraphObject* graph_parent() const = 0;
+ virtual const Raul::Path& path() const = 0;
+ virtual const Raul::Symbol& symbol() const = 0;
+ virtual GraphObject* graph_parent() const = 0;
};
diff --git a/src/common/interface/Resource.hpp b/src/common/interface/Resource.hpp
index c5b5624a..3b2f9aa6 100644
--- a/src/common/interface/Resource.hpp
+++ b/src/common/interface/Resource.hpp
@@ -30,22 +30,66 @@ namespace Shared {
class Resource
{
public:
+ enum Graph {
+ DEFAULT,
+ EXTERNAL,
+ INTERNAL
+ };
+
+ class Property : public Raul::Atom {
+ public:
+ Property(const Raul::Atom& atom, Graph ctx=DEFAULT)
+ : Raul::Atom(atom)
+ , _ctx(ctx)
+ {}
+
+ Property() : Raul::Atom(), _ctx(DEFAULT) {}
+ Property(int32_t val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(float val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(bool val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(const char* val) : Raul::Atom(val), _ctx(DEFAULT) {}
+ Property(const std::string& val) : Raul::Atom(val), _ctx(DEFAULT) {}
+
+ Property(const Raul::Atom::DictValue& dict)
+ : Raul::Atom(dict)
+ , _ctx(DEFAULT)
+ {}
+
+ Property(Type t, const std::string& uri)
+ : Raul::Atom(t, uri)
+ , _ctx(DEFAULT)
+ {}
+
+ Graph context() const { return _ctx; }
+ void set_context(Graph ctx) { _ctx = ctx; }
+
+ private:
+ Graph _ctx;
+ };
+
virtual ~Resource() {}
- typedef std::multimap<Raul::URI, Raul::Atom> Properties;
- virtual const Raul::URI& uri() const = 0;
- virtual const Properties& properties() const = 0;
- virtual Properties& properties() = 0;
+ virtual const Raul::URI& uri() const = 0;
- virtual Raul::Atom& set_property(const Raul::URI& uri,
- const Raul::Atom& value) = 0;
+ typedef std::multimap<Raul::URI, Property> Properties;
- virtual void add_property(const Raul::URI& uri,
- const Raul::Atom& value) = 0;
+ static void set_context(Properties& props, Graph ctx) {
+ for (Properties::iterator i = props.begin(); i != props.end(); ++i) {
+ i->second.set_context(ctx);
+ }
+ }
- virtual const Raul::Atom& get_property(const Raul::URI& uri) const = 0;
+ virtual Properties properties(Resource::Graph ctx) const = 0;
- virtual bool has_property(const Raul::URI& uri, const Raul::Atom& value) const = 0;
+ virtual const Properties& properties() const = 0;
+ virtual Properties& properties() = 0;
+ virtual const Raul::Atom& get_property(const Raul::URI& uri) const = 0;
+ virtual Raul::Atom& set_property(const Raul::URI& uri,
+ const Raul::Atom& value) = 0;
+ virtual void add_property(const Raul::URI& uri,
+ const Raul::Atom& value) = 0;
+ virtual bool has_property(const Raul::URI& uri,
+ const Raul::Atom& value) const = 0;
};