summaryrefslogtreecommitdiffstats
path: root/src/libs/serialisation/Loader.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-12 03:20:59 +0000
committerDavid Robillard <d@drobilla.net>2007-09-12 03:20:59 +0000
commit599b4833362ca131ed4c4cd186a38de0764b1ec9 (patch)
treeac6d0fc1f3c4faa395e2d0fb7bc899128793e77a /src/libs/serialisation/Loader.cpp
parentc13e988094bca2c19b0676f8cfd60f3cff2f4a57 (diff)
downloadingen-599b4833362ca131ed4c4cd186a38de0764b1ec9.tar.gz
ingen-599b4833362ca131ed4c4cd186a38de0764b1ec9.tar.bz2
ingen-599b4833362ca131ed4c4cd186a38de0764b1ec9.zip
Fix manually specifying polyphony in load patch dialog.
git-svn-id: http://svn.drobilla.net/lad/ingen@703 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/serialisation/Loader.cpp')
-rw-r--r--src/libs/serialisation/Loader.cpp49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp
index 1a33dac9..e34b5503 100644
--- a/src/libs/serialisation/Loader.cpp
+++ b/src/libs/serialisation/Loader.cpp
@@ -64,24 +64,35 @@ Loader::load(SharedPtr<EngineInterface> engine,
cerr << "[Loader] Loading " << patch_uri << " from " << document_uri
<< " under " << (string)(parent ? (string)parent.get() : "no parent") << endl;
- /* Get polyphony (mandatory) */
-
- // FIXME: polyphony datatype
- RDF::Query query(*rdf_world, Glib::ustring(
- "SELECT DISTINCT ?poly WHERE {\n") +
- patch_uri + " ingen:polyphony ?poly\n }");
-
- RDF::Query::Results results = query.run(*rdf_world, model);
+ size_t patch_poly = 1;
+
+ /* Use parameter overridden polyphony, if given */
+ Raul::Table<string, Atom>::iterator poly_param = data.find("ingen:polyphony");
+ if (poly_param != data.end() && poly_param->second.type() == Atom::INT) {
+ cerr << "Using overridden poly: " << poly_param->second.get_int32();
+ patch_poly = poly_param->second.get_int32();
+
+ /* Get polyphony from file (mandatory if not specified in parameters) */
+ } else {
+ cerr << "No overridden poly." << endl;
+
+ // FIXME: polyphony datatype?
+ RDF::Query query(*rdf_world, Glib::ustring(
+ "SELECT DISTINCT ?poly WHERE {\n") +
+ patch_uri + " ingen:polyphony ?poly\n }");
+
+ RDF::Query::Results results = query.run(*rdf_world, model);
+
+ if (results.size() == 0) {
+ cerr << "[Loader] ERROR: No polyphony found!" << endl;
+ return false;
+ }
- if (results.size() == 0) {
- cerr << "[Loader] ERROR: No polyphony found!" << endl;
- return false;
+ const RDF::Node& poly_node = (*results.begin())["poly"];
+ assert(poly_node.is_int());
+ patch_poly = static_cast<size_t>(poly_node.to_int());
}
- RDF::Node poly_node = (*results.begin())["poly"];
- assert(poly_node.is_int());
- const size_t patch_poly = static_cast<size_t>(poly_node.to_int());
-
/* Get name (if available/necessary) */
if (patch_name == "") {
@@ -89,11 +100,11 @@ Loader::load(SharedPtr<EngineInterface> engine,
if (patch_name.substr(patch_name.length()-10) == ".ingen.ttl")
patch_name = patch_name.substr(0, patch_name.length()-10);
- query = RDF::Query(*rdf_world, Glib::ustring(
+ RDF::Query query(*rdf_world, Glib::ustring(
"SELECT DISTINCT ?name WHERE {\n") +
patch_uri + " ingen:name ?name\n}");
- results = query.run(*rdf_world, model);
+ RDF::Query::Results results = query.run(*rdf_world, model);
if (results.size() > 0)
patch_name = (*results.begin())["name"].to_string();
@@ -107,7 +118,7 @@ Loader::load(SharedPtr<EngineInterface> engine,
/* Load (plugin) nodes */
- query = RDF::Query(*rdf_world, Glib::ustring(
+ RDF::Query query(*rdf_world, Glib::ustring(
"SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") +
patch_uri + " ingen:node ?node .\n"
"?node ingen:name ?name ;\n"
@@ -116,7 +127,7 @@ Loader::load(SharedPtr<EngineInterface> engine,
" FILTER ( datatype(?floatval) = xsd:decimal ) }\n"
"}");
- results = query.run(*rdf_world, model);
+ RDF::Query::Results results = query.run(*rdf_world, model);
for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) {