diff options
author | David Robillard <d@drobilla.net> | 2011-02-19 05:10:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-02-19 05:10:29 +0000 |
commit | 6b18de71d1c603255b263a64434005306f152f13 (patch) | |
tree | 09c6e87acca1fe76bc74b3b549fee7ad09751993 /src/client | |
parent | 8e07e115429a0869593d4f29dc3e6cf5c8b25049 (diff) | |
download | ingen-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/client')
-rw-r--r-- | src/client/ClientStore.cpp | 62 | ||||
-rw-r--r-- | src/client/ClientStore.hpp | 29 | ||||
-rw-r--r-- | src/client/HTTPEngineSender.cpp | 3 | ||||
-rw-r--r-- | src/client/HTTPEngineSender.hpp | 3 | ||||
-rw-r--r-- | src/client/OSCEngineSender.cpp | 3 | ||||
-rw-r--r-- | src/client/OSCEngineSender.hpp | 3 | ||||
-rw-r--r-- | src/client/ObjectModel.cpp | 18 | ||||
-rw-r--r-- | src/client/ObjectModel.hpp | 3 | ||||
-rw-r--r-- | src/client/SigClientInterface.hpp | 9 | ||||
-rw-r--r-- | src/client/ThreadedSigClientInterface.hpp | 16 |
10 files changed, 79 insertions, 70 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 2ac8a5ee..2b457aa0 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -97,10 +97,6 @@ ClientStore::add_object(SharedPtr<ObjectModel> object) } - for (Resource::Properties::const_iterator i = object->meta().properties().begin(); - i != object->meta().properties().end(); ++i) - object->signal_property(i->first, i->second); - for (Resource::Properties::const_iterator i = object->properties().begin(); i != object->properties().end(); ++i) object->signal_property(i->first, i->second); @@ -252,34 +248,41 @@ ClientStore::move(const Path& old_path_str, const Path& new_path_str) void -ClientStore::put(const URI& uri, const Resource::Properties& properties) +ClientStore::put(const URI& uri, + const Resource::Properties& properties, + Resource::Graph ctx) { typedef Resource::Properties::const_iterator iterator; - /*LOG(info) << "PUT " << uri << " {" << endl; + /* + LOG(info) << "PUT " << uri << " {" << endl; for (iterator i = properties.begin(); i != properties.end(); ++i) LOG(info) << " " << i->first << " = " << i->second << " :: " << i->second.type() << endl; - LOG(info) << "}" << endl;*/ - + LOG(info) << "}" << endl; + */ + + bool is_patch, is_node, is_port, is_output; + PortType data_type(PortType::UNKNOWN); + ResourceImpl::type(uris(), properties, is_patch, is_node, is_port, is_output, data_type); // Check if uri is a plugin const Atom& type = properties.find(_uris->rdf_type)->second; if (type.type() == Atom::URI) { - const URI& type_uri = type.get_uri(); - if (Plugin::type_from_uri(type_uri) != Plugin::NIL) { + const URI& type_uri = type.get_uri(); + const Plugin::Type plugin_type = Plugin::type_from_uri(type_uri); + if (plugin_type == Plugin::Patch) { + is_patch = true; + } else if (plugin_type != Plugin::NIL) { SharedPtr<PluginModel> p(new PluginModel(uris(), uri, type_uri, properties)); add_plugin(p); return; } } - bool is_meta = ResourceImpl::is_meta_uri(uri); - - string path_str = is_meta ? (string("/") + uri.chop_start("#")) : uri.str(); - if (!Path::is_valid(path_str)) { - LOG(error) << "Bad path: " << uri.str() << " - " << path_str << endl; + if (!Path::is_valid(uri.str())) { + LOG(error) << "Bad path `" << uri.str() << "'" << endl; return; } - Path path(is_meta ? (string("/") + uri.chop_start("#")) : uri.str()); + const Path path(uri.str()); SharedPtr<ObjectModel> obj = PtrCast<ObjectModel>(object(path)); if (obj) { @@ -287,10 +290,6 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) return; } - bool is_patch, is_node, is_port, is_output; - PortType data_type(PortType::UNKNOWN); - ResourceImpl::type(uris(), properties, is_patch, is_node, is_port, is_output, data_type); - if (path.is_root()) { is_patch = true; } @@ -347,14 +346,13 @@ ClientStore::delta(const URI& uri, const Resource::Properties& remove, const Res for (iterator i = add.begin(); i != add.end(); ++i) LOG(info) << " + " << i->first << " = " << i->second << " :: " << i->second.type() << endl; LOG(info) << "}" << endl;*/ - bool is_meta = ResourceImpl::is_meta_uri(uri); - string path_str = is_meta ? (string("/") + uri.chop_start("#")) : uri.str(); - if (!Path::is_valid(path_str)) { - LOG(error) << "Bad path: " << uri.str() << " - " << path_str << endl; + + if (!Path::is_valid(uri.str())) { + LOG(error) << "Bad path `" << uri.str() << "'" << endl; return; } - Path path(is_meta ? (string("/") + uri.chop_start("#")) : uri.str()); + const Path path(uri.str()); SharedPtr<ObjectModel> obj = object(path); if (obj) { @@ -370,23 +368,15 @@ void ClientStore::set_property(const URI& subject_uri, const URI& predicate, const Atom& value) { SharedPtr<Resource> subject = resource(subject_uri); - - size_t hash = subject_uri.find("#"); - if (!value.is_valid()) { - LOG(error) << "Property '" << predicate << "' is invalid" << endl; - } else if (subject) { + if (subject) { subject->set_property(predicate, value); - } else if (ResourceImpl::is_meta_uri(subject_uri)) { - Path instance_path = string("/") + subject_uri.substr(hash + 1); - SharedPtr<ObjectModel> om = PtrCast<ObjectModel>(subject); - if (om) - om->meta().set_property(predicate, value); } else { SharedPtr<PluginModel> plugin = this->plugin(subject_uri); if (plugin) plugin->set_property(predicate, value); else - LOG(warn) << "Property '" << predicate << "' for unknown object " << subject_uri << endl; + LOG(warn) << "Property '" << predicate << "' for unknown object " + << subject_uri << endl; } } diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp index a2a424c8..a3928760 100644 --- a/src/client/ClientStore.hpp +++ b/src/client/ClientStore.hpp @@ -71,13 +71,28 @@ public: // CommonInterface bool new_object(const Shared::GraphObject* object); - void put(const Raul::URI& path, const Shared::Resource::Properties& properties); - void delta(const Raul::URI& path, const Shared::Resource::Properties& remove, - const Shared::Resource::Properties& add); - void move(const Raul::Path& old_path, const Raul::Path& new_path); - void set_property(const Raul::URI& subject_path, const Raul::URI& predicate, const Raul::Atom& value); - void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); - void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path); + + void put(const Raul::URI& uri, + const Shared::Resource::Properties& properties, + Shared::Resource::Graph ctx=Shared::Resource::DEFAULT); + + void delta(const Raul::URI& uri, + const Shared::Resource::Properties& remove, + const Shared::Resource::Properties& add); + + void move(const Raul::Path& old_path, + const Raul::Path& new_path); + + void set_property(const Raul::URI& subject_path, + const Raul::URI& predicate, + const Raul::Atom& value); + + void connect(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); + + void disconnect(const Raul::Path& src_port_path, + const Raul::Path& dst_port_path); + void del(const Raul::Path& path); sigc::signal< void, SharedPtr<ObjectModel> > signal_new_object; diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp index 6468deef..84448743 100644 --- a/src/client/HTTPEngineSender.cpp +++ b/src/client/HTTPEngineSender.cpp @@ -116,7 +116,8 @@ HTTPEngineSender::quit() void HTTPEngineSender::put(const URI& uri, - const Resource::Properties& properties) + const Resource::Properties& properties, + Shared::Resource::Graph ctx) { const string path = (uri.substr(0, 6) == "path:/") ? uri.substr(6) : uri.str(); const string full_uri = _engine_url.str() + "/" + path; diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp index 12ba98b5..2b31701f 100644 --- a/src/client/HTTPEngineSender.hpp +++ b/src/client/HTTPEngineSender.hpp @@ -85,7 +85,8 @@ public: // Object commands virtual void put(const Raul::URI& path, - const Shared::Resource::Properties& properties); + const Shared::Resource::Properties& properties, + Shared::Resource::Graph ctx=Shared::Resource::DEFAULT); virtual void delta(const Raul::URI& path, const Shared::Resource::Properties& remove, diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp index 66327768..512d21aa 100644 --- a/src/client/OSCEngineSender.cpp +++ b/src/client/OSCEngineSender.cpp @@ -135,7 +135,8 @@ OSCEngineSender::quit() void OSCEngineSender::put(const Raul::URI& path, - const Shared::Resource::Properties& properties) + const Shared::Resource::Properties& properties, + Shared::Resource::Graph ctx) { typedef Shared::Resource::Properties::const_iterator iterator; lo_message m = lo_message_new(); diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp index c2146f7a..c696eb1b 100644 --- a/src/client/OSCEngineSender.hpp +++ b/src/client/OSCEngineSender.hpp @@ -78,7 +78,8 @@ public: // Object commands virtual void put(const Raul::URI& path, - const Shared::Resource::Properties& properties); + const Shared::Resource::Properties& properties, + Shared::Resource::Graph ctx=Shared::Resource::DEFAULT); virtual void delta(const Raul::URI& path, const Shared::Resource::Properties& remove, diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index d3726862..728d530e 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -29,7 +29,7 @@ namespace Client { ObjectModel::ObjectModel(Shared::LV2URIMap& uris, const Raul::Path& path) : ResourceImpl(uris, path) - , _meta(uris, ResourceImpl::meta_uri(path)) + , _meta(uris, Raul::URI("http://example.org/FIXME")) , _path(path) , _symbol((path == Path::root()) ? "root" : path.symbol()) { @@ -62,8 +62,7 @@ ObjectModel::set_property(const Raul::URI& key, const Raul::Atom& value) Raul::Atom& ObjectModel::set_meta_property(const Raul::URI& key, const Raul::Atom& value) { - signal_property.emit(key, value); - return _meta.set_property(key, value); + return set_property(key, Resource::Property(value, Resource::INTERNAL)); } @@ -78,8 +77,9 @@ ObjectModel::add_property(const Raul::URI& key, const Raul::Atom& value) const Atom& ObjectModel::get_property(const Raul::URI& key) const { + static const Atom null_atom; Resource::Properties::const_iterator i = properties().find(key); - return (i != properties().end()) ? i->second : _meta.get_property(key); + return (i != properties().end()) ? i->second : null_atom; } @@ -103,11 +103,8 @@ ObjectModel::set(SharedPtr<ObjectModel> o) if (o->_parent) _parent = o->_parent; - for (Properties::const_iterator v = o->meta().properties().begin(); v != o->meta().properties().end(); ++v) { - o->meta().set_property(v->first, v->second); - signal_property.emit(v->first, v->second); - } - for (Properties::const_iterator v = o->properties().begin(); v != o->properties().end(); ++v) { + for (Properties::const_iterator v = o->properties().begin(); + v != o->properties().end(); ++v) { ResourceImpl::set_property(v->first, v->second); signal_property.emit(v->first, v->second); } @@ -117,9 +114,8 @@ ObjectModel::set(SharedPtr<ObjectModel> o) void ObjectModel::set_path(const Raul::Path& p) { - _path = p; + _path = p; _symbol = p.symbol(); - _meta.set_uri(ResourceImpl::meta_uri(p)); signal_moved.emit(); } diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index 9f480567..0899ed99 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -62,9 +62,6 @@ public: void add_property(const Raul::URI& key, const Raul::Atom& value); Raul::Atom& set_meta_property(const Raul::URI& key, const Raul::Atom& value); - Resource& meta() { return _meta; } - const Resource& meta() const { return _meta; } - const Raul::URI& meta_uri() const { return _meta.uri(); } const Raul::Path& path() const { return _path; } const Raul::Symbol& symbol() const { return _symbol; } SharedPtr<ObjectModel> parent() const { return _parent; } diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp index a2c6da73..55965fd2 100644 --- a/src/client/SigClientInterface.hpp +++ b/src/client/SigClientInterface.hpp @@ -50,7 +50,8 @@ public: sigc::signal<void, std::string> signal_error; sigc::signal<void, Raul::Path, uint32_t> signal_new_patch; sigc::signal<void, Raul::Path, Raul::URI, uint32_t, bool> signal_new_port; - sigc::signal<void, Raul::URI, Shared::Resource::Properties> signal_put; + sigc::signal<void, Raul::URI, Shared::Resource::Properties, + Shared::Resource::Graph> signal_put; sigc::signal<void, Raul::URI, Shared::Resource::Properties, Shared::Resource::Properties> signal_delta; sigc::signal<void, Raul::Path, Raul::Path> signal_object_moved; @@ -89,8 +90,10 @@ protected: void error(const std::string& msg) { EMIT(error, msg); } - void put(const Raul::URI& uri, const Shared::Resource::Properties& properties) - { EMIT(put, uri, properties); } + void put(const Raul::URI& uri, + const Shared::Resource::Properties& properties, + Shared::Resource::Graph ctx=Shared::Resource::DEFAULT) + { EMIT(put, uri, properties, ctx); } void delta(const Raul::URI& uri, const Shared::Resource::Properties& remove, const Shared::Resource::Properties& add) diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp index 5f5ea5a9..06a8da73 100644 --- a/src/client/ThreadedSigClientInterface.hpp +++ b/src/client/ThreadedSigClientInterface.hpp @@ -83,11 +83,14 @@ public: void error(const std::string& msg) { push_sig(sigc::bind(error_slot, msg)); } - void put(const Raul::URI& path, const Shared::Resource::Properties& properties) - { push_sig(sigc::bind(put_slot, path, properties)); } - - void delta(const Raul::URI& path, - const Shared::Resource::Properties& remove, const Shared::Resource::Properties& add) + void put(const Raul::URI& path, + const Shared::Resource::Properties& properties, + Shared::Resource::Graph ctx=Shared::Resource::DEFAULT) + { push_sig(sigc::bind(put_slot, path, properties, ctx)); } + + void delta(const Raul::URI& path, + const Shared::Resource::Properties& remove, + const Shared::Resource::Properties& add) { push_sig(sigc::bind(delta_slot, path, remove, add)); } void connect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) @@ -126,7 +129,8 @@ private: sigc::slot<void, std::string> error_slot; sigc::slot<void, Raul::URI, Raul::URI, Raul::Symbol> new_plugin_slot; sigc::slot<void, Raul::Path, Raul::URI, uint32_t, bool> new_port_slot; - sigc::slot<void, Raul::URI, Shared::Resource::Properties> put_slot; + sigc::slot<void, Raul::URI, Shared::Resource::Properties, + Shared::Resource::Graph> put_slot; sigc::slot<void, Raul::URI, Shared::Resource::Properties, Shared::Resource::Properties> delta_slot; sigc::slot<void, Raul::Path, Raul::Path> connection_slot; |