From e2e782dcba57e89a7501810d3a4c948035165f62 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 18 Feb 2011 15:58:07 +0000 Subject: Trim more cruft. Fix running without loading a patch. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2989 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientStore.cpp | 13 +++++---- src/serialisation/Parser.cpp | 65 +++++++++++++++----------------------------- 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 010acb10..c5b09b8d 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -255,9 +255,7 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) for (iterator i = properties.begin(); i != properties.end(); ++i) LOG(info) << " " << i->first << " = " << i->second << " :: " << i->second.type() << endl; LOG(info) << "}" << endl;*/ - - bool is_meta = ResourceImpl::is_meta_uri(uri); - + // Check if uri is a plugin const Atom& type = properties.find(_uris->rdf_type)->second; if (type.type() == Atom::URI) { @@ -266,10 +264,11 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) SharedPtr p(new PluginModel(uris(), uri, type_uri, properties)); add_plugin(p); return; - } else { } } + 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; @@ -288,6 +287,10 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) 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; + } + if (is_patch) { SharedPtr model(new PatchModel(uris(), path)); model->set_properties(properties); @@ -307,7 +310,7 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) n->set_properties(properties); add_object(n); } else { - LOG(error) << "Plugin with no type" << endl; + LOG(warn) << "Node " << path << " has no plugin" << endl; } } else if (is_port) { if (data_type != PortType::UNKNOWN) { diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 57f54bc9..06922653 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -221,60 +221,39 @@ Parser::parse(Ingen::Shared::World* world, subject = nil; } - std::string path_str = data_path ? data_path->chop_scheme() : "/"; + Raul::Path path("/"); + if (data_path) { + path = *data_path; + } else if (parent && symbol) { + path = parent->child(*symbol); + } + boost::optional ret; boost::optional root_path; - for (Sord::Iter i = model.find(subject, rdf_type, nil); !i.end(); ++i) { const Sord::Node& subject = i.get_subject(); const Sord::Node& rdf_class = i.get_object(); - if (!data_path) - path_str = relative_uri(document_uri, subject.to_c_string(), true); - - const bool is_object = (rdf_class == patch_class) - || (rdf_class == node_class) - || (rdf_class == in_port_class) - || (rdf_class == out_port_class); - - if (is_object) { - if (path_str.empty() || path_str[0] != '/') - path_str = "/" + path_str; - - if (!Path::is_valid(path_str)) { - LOG(warn) << "Invalid path '" << path_str << "', object skipped" << endl; - continue; - } - - string path = (parent && symbol) - ? parent->child(*symbol).str() - : (parent ? *parent : Path("/")).child(path_str.substr(path_str.find("/")+1)).str(); - - if (!Path::is_valid(path)) { - LOG(warn) << "Invalid path '" << path << "' transformed to /" << endl; - path = "/"; - } - - if (rdf_class == patch_class) { - ret = parse_patch(world, target, model, subject, parent, symbol, data); - } else if (rdf_class == node_class) { - ret = parse_node(world, target, model, subject, path, data); - } else if (rdf_class == in_port_class || rdf_class == out_port_class) { - parse_properties(world, target, model, subject, path, data); - ret = path; - } + if (rdf_class == patch_class) { + ret = parse_patch(world, target, model, subject, parent, symbol, data); + } else if (rdf_class == node_class) { + ret = parse_node(world, target, model, subject, path, data); + } else if (rdf_class == in_port_class || rdf_class == out_port_class) { + parse_properties(world, target, model, subject, path, data); + ret = path; + } - if (!ret) { - LOG(error) << "Failed to parse object " << path << endl; - return boost::optional(); - } + if (!ret) { + LOG(error) << "Failed to parse object " << path << endl; + return boost::optional(); + } - if (data_path && subject.to_string() == data_path->str()) - root_path = ret; + if (data_path && subject.to_string() == data_path->str()) { + root_path = ret; } } - return boost::optional(Path(path_str)); + return path; } boost::optional -- cgit v1.2.1