diff options
author | David Robillard <d@drobilla.net> | 2007-10-08 19:26:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-08 19:26:07 +0000 |
commit | cac2494fb075045694134a7aace68fced10ff1d9 (patch) | |
tree | 0375857a1d340eba310262b4bd09c8ed3fb3ea81 /src | |
parent | 88cff5320290010b5f35b8dcbd40c63317956d62 (diff) | |
download | ingen-cac2494fb075045694134a7aace68fced10ff1d9.tar.gz ingen-cac2494fb075045694134a7aace68fced10ff1d9.tar.bz2 ingen-cac2494fb075045694134a7aace68fced10ff1d9.zip |
Build fixes.
Work on proper variable (metadata) serialisation.
git-svn-id: http://svn.drobilla.net/lad/ingen@854 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/module/Makefile.am | 4 | ||||
-rw-r--r-- | src/libs/module/World.hpp | 4 | ||||
-rw-r--r-- | src/libs/serialisation/Loader.cpp | 57 | ||||
-rw-r--r-- | src/libs/serialisation/Makefile.am | 5 | ||||
-rw-r--r-- | src/libs/serialisation/Serialiser.cpp | 4 |
5 files changed, 40 insertions, 34 deletions
diff --git a/src/libs/module/Makefile.am b/src/libs/module/Makefile.am index 57219c85..0d52e635 100644 --- a/src/libs/module/Makefile.am +++ b/src/libs/module/Makefile.am @@ -1,8 +1,8 @@ noinst_LTLIBRARIES = libingen_module.la -libingen_module_la_CXXFLAGS = @RAUL_CFLAGS@ @SLV2_CFLAGS@ @GLIBMM_CFLAGS@ -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" +libingen_module_la_CXXFLAGS = @GLIBMM_CFLAGS@ @RAUL_CFLAGS@ @SLV2_CFLAGS@ -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" -libingen_module_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ @SLV2_LIBS@ +libingen_module_la_LIBADD = @GLIBMM_LIBS@ @RAUL_LIBS@ @SLV2_LIBS@ libingen_module_la_SOURCES = \ global.hpp \ diff --git a/src/libs/module/World.hpp b/src/libs/module/World.hpp index 1caa50ac..ca8f7b14 100644 --- a/src/libs/module/World.hpp +++ b/src/libs/module/World.hpp @@ -18,13 +18,13 @@ #ifndef INGEN_WORLD_HPP #define INGEN_WORLD_HPP +#include CONFIG_H_PATH + #include <string> #include <glibmm/module.h> #include <raul/SharedPtr.hpp> #include <raul/RDFWorld.hpp> -#include CONFIG_H_PATH - #ifdef HAVE_SLV2 #include <slv2/slv2.h> #endif diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index a52024aa..fb6f1e7c 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -22,6 +22,7 @@ #include <raul/RDFModel.hpp> #include <raul/RDFQuery.hpp> #include <raul/TableImpl.hpp> +#include <raul/AtomRedland.hpp> #include "interface/EngineInterface.hpp" #include "Loader.hpp" @@ -116,13 +117,15 @@ Loader::load(SharedPtr<EngineInterface> engine, /* Load (plugin) nodes */ RDF::Query query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval ?poly WHERE {\n") + + "SELECT DISTINCT ?name ?plugin ?varkey ?varval ?poly WHERE {\n") + patch_uri + " ingen:node ?node .\n" "?node ingen:name ?name ;\n" " ingen:plugin ?plugin ;\n" " ingen:polyphonic ?poly .\n" - "OPTIONAL { ?node ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" + "OPTIONAL { ?node ingen:variable ?variable .\n" + " ?variable ingen:key ?varkey ;\n" + " ingen:value ?varval .\n" + " }" "}"); RDF::Query::Results results = query.run(*rdf_world, model); @@ -146,13 +149,11 @@ Loader::load(SharedPtr<EngineInterface> engine, created.insert(node_path); } - /* Float variable (FIXME: use using raw predicates is definitely a very - * bad idea, make an ingen:Variable or something */ - const string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); - RDF::Node val_node = (*i)["floatval"]; + const string key = rdf_world->prefixes().qualify((*i)["varkey"].to_string()); + RDF::Node val_node = (*i)["varval"]; - if (floatkey != "" && val_node.is_float()) - engine->set_variable(node_path, floatkey, val_node.to_float()); + if (key != "") + engine->set_variable(node_path, key, AtomRedland::rdf_node_to_atom(val_node)); } @@ -212,16 +213,18 @@ Loader::load(SharedPtr<EngineInterface> engine, /* Load this patch's ports */ query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval WHERE {\n") + + "SELECT DISTINCT ?port ?type ?name ?datatype ?varkey ?varval ?portval WHERE {\n") + patch_uri + " ingen:port ?port .\n" "?port a ?type ;\n" " a ?datatype ;\n" " ingen:name ?name .\n" " FILTER (?type != ?datatype && ((?type = ingen:InputPort) || (?type = ingen:OutputPort)))\n" - "OPTIONAL { ?port ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" "OPTIONAL { ?port ingen:value ?portval . \n" " FILTER ( datatype(?portval) = xsd:decimal ) }\n" + "OPTIONAL { ?port ingen:variable ?variable .\n" + " ?variable ingen:key ?varkey ;\n" + " ingen:value ?varval .\n" + " }" "}"); results = query.run(*rdf_world, model); @@ -239,18 +242,17 @@ Loader::load(SharedPtr<EngineInterface> engine, created.insert(port_path); } - RDF::Node val_node = (*i)["portval"]; + const RDF::Node val_node = (*i)["portval"]; if (val_node.is_float()) { const float val = val_node.to_float(); engine->set_port_value(patch_path.base() + name, "ingen:control", sizeof(float), &val); } + const string key = rdf_world->prefixes().qualify((*i)["varkey"].to_string()); + const RDF::Node var_val_node = (*i)["varval"]; - string floatkey = rdf_world->qualify((*i)["floatkey"].to_string()); - val_node = (*i)["floatval"]; - - if (floatkey != "" && val_node.is_float()) - engine->set_variable(patch_path.base() + name, floatkey, Atom(val_node.to_float())); + if (key != "") + engine->set_variable(patch_path.base() + name, key, AtomRedland::rdf_node_to_atom(var_val_node)); } created.clear(); @@ -337,27 +339,28 @@ Loader::load(SharedPtr<EngineInterface> engine, } - /* Load variable */ + /* Load variables */ query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?floatkey ?floatval WHERE {\n") + - patch_uri + " ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) \n" + "SELECT DISTINCT ?varkey ?varval WHERE {\n") + + patch_uri + " ingen:variable ?variable .\n" + "?variable ingen:key ?varkey ;\n" + " ingen:value ?varval .\n" "}"); results = query.run(*rdf_world, model); for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); - RDF::Node val_node = (*i)["floatval"]; + const string key = rdf_world->prefixes().qualify((*i)["varkey"].to_string()); + RDF::Node val_node = (*i)["varval"]; - if (floatkey != "" && val_node.is_float()) - engine->set_variable(patch_path, floatkey, Atom(val_node.to_float())); + if (key != "") + engine->set_variable(patch_path, key, AtomRedland::rdf_node_to_atom(val_node)); } - // Set passed variable last to override any loaded values + // Set passed variables last to override any loaded values for (GraphObject::Variables::const_iterator i = data.begin(); i != data.end(); ++i) engine->set_variable(patch_path, i->first, i->second); diff --git a/src/libs/serialisation/Makefile.am b/src/libs/serialisation/Makefile.am index 579da448..0ceae510 100644 --- a/src/libs/serialisation/Makefile.am +++ b/src/libs/serialisation/Makefile.am @@ -8,10 +8,11 @@ libingen_serialisation_la_CXXFLAGS = \ -I$(top_srcdir)/ingen/src/common \ -I$(top_srcdir)/ingen/src/libs \ @RAUL_CFLAGS@ \ - @GLIBMM_CFLAGS@ + @GLIBMM_CFLAGS@ \ + @SLV2_CFLAGS@ libingen_serialisation_la_LDFLAGS = -no-undefined -module -avoid-version -libingen_serialisation_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ +libingen_serialisation_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ @SLV2_LIBS@ libingen_serialisation_la_SOURCES = \ Loader.cpp \ diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp index f0008b64..83920d28 100644 --- a/src/libs/serialisation/Serialiser.cpp +++ b/src/libs/serialisation/Serialiser.cpp @@ -410,8 +410,10 @@ Serialiser::serialise_variables(RDF::Node subject, const GraphObject::Variables& { for (GraphObject::Variables::const_iterator v = variables.begin(); v != variables.end(); ++v) { if (v->first.find(":") != string::npos) { - RDF::Node var_id = _world.blank_id(); + const RDF::Node var_id = _world.blank_id(); + const RDF::Node key(_model->world(), RDF::Node::RESOURCE, v->first); _model->add_statement(subject, "ingen:variable", var_id); + _model->add_statement(var_id, "ingen:key", key); _model->add_statement(var_id, "ingen:value", v->second); } else { cerr << "Warning: not serialising variable with key '" << v->first << "'" << endl; |