From a054212abbdb26e03ca42c91d0c86819d445bc5f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 19 Sep 2007 20:21:12 +0000 Subject: Fix various serialization problems. git-svn-id: http://svn.drobilla.net/lad/ingen@731 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/serialisation/Loader.cpp | 40 ++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) (limited to 'src/libs/serialisation') diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index e34b5503..1602ed6f 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -119,40 +119,58 @@ Loader::load(SharedPtr engine, /* Load (plugin) nodes */ RDF::Query query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") + + "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval ?poly WHERE {\n") + patch_uri + " ingen:node ?node .\n" "?node ingen:name ?name ;\n" " ingen:plugin ?plugin .\n" "OPTIONAL { ?node ?floatkey ?floatval . \n" " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" + "OPTIONAL { ?node ?polyphonic ?poly }\n" "}"); RDF::Query::Results results = query.run(*rdf_world, model); + string node_name; + string node_plugin; + bool node_polyphonic = false; + map metadata; + + /* Get all node information */ for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const string name = (*i)["name"].to_string(); - const string plugin = (*i)["plugin"].to_string(); + if (node_name.length() == 0) + node_name = (*i)["name"].to_string(); - const Path node_path = patch_path.base() + (string)name; + if (node_plugin.length() == 0) + node_plugin = rdf_world->qualify((*i)["plugin"].to_string()); - if (created.find(node_path) == created.end()) { - engine->create_node(node_path, plugin, false); - created.insert(node_path); - } + RDF::Node poly_node = (*i)["poly"]; + if (poly_node.is_bool() && poly_node.to_bool() == true) + node_polyphonic = true; - string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); + const string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); RDF::Node val_node = (*i)["floatval"]; if (floatkey != "" && val_node.is_float()) - engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); + metadata.insert(make_pair(floatkey, Atom(val_node.to_float()))); + } + + const Path node_path = patch_path.base() + node_name; + + /* Create node */ + if (created.find(node_path) == created.end()) { + engine->create_node(node_path, node_plugin, node_polyphonic); + created.insert(node_path); } + /* Set node metadata */ + for (map::const_iterator i = metadata.begin(); i != metadata.end(); ++i) + engine->set_metadata(patch_path.base() + node_name, i->first, i->second); /* Load subpatches */ query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?patch ?name WHERE {\n") + + "SELECT DISTINCT ?patch ?name WHERE {\n") + patch_uri + " ingen:node ?patch .\n" "?patch a ingen:Patch ;\n" " ingen:name ?name .\n" -- cgit v1.2.1