From 6b18de71d1c603255b263a64434005306f152f13 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 19 Feb 2011 05:10:29 +0000 Subject: 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 --- src/client/ClientStore.cpp | 62 +++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 36 deletions(-) (limited to 'src/client/ClientStore.cpp') 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 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 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 obj = PtrCast(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 obj = object(path); if (obj) { @@ -370,23 +368,15 @@ void ClientStore::set_property(const URI& subject_uri, const URI& predicate, const Atom& value) { SharedPtr 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 om = PtrCast(subject); - if (om) - om->meta().set_property(predicate, value); } else { SharedPtr 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; } } -- cgit v1.2.1