From de58b508b28a42b072fb26d2633aa0af37ee7c0e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 29 Jul 2008 04:39:59 +0000 Subject: Bump Ingen librdf dependency to 1.0.8. Several serialization fixes. Include Smack 808 Om patches converted to Ingen files. git-svn-id: http://svn.drobilla.net/lad/ingen@1301 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/serialisation/Loader.cpp | 8 +++++--- src/libs/serialisation/Serialiser.cpp | 34 ++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src/libs/serialisation') diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index da2e6507..6708a0e3 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -212,8 +212,9 @@ Loader::load(Ingen::Shared::World* world, const string port_name = (*i)["portname"].to_string(); const float val = (*i)["portval"].to_float(); - const Path port_path = patch_path.base() + Path::nameify(node_name) - +"/"+ Path::nameify(port_name); + assert(Path::is_valid_name(node_name)); + assert(Path::is_valid_name(port_name)); + const Path port_path = patch_path.base() + node_name + "/" + port_name; world->engine->set_port_value(port_path, "ingen:Float", sizeof(float), &val); } @@ -243,7 +244,8 @@ Loader::load(Ingen::Shared::World* world, const string type = world->rdf_world->qualify((*i)["type"].to_string()); const string datatype = world->rdf_world->qualify((*i)["datatype"].to_string()); - const Path port_path = patch_path.base() + (string)name; + assert(Path::is_valid_name(name)); + const Path port_path = patch_path.base() + name; if (created.find(port_path) == created.end()) { bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp index a81c76f6..710a538c 100644 --- a/src/libs/serialisation/Serialiser.cpp +++ b/src/libs/serialisation/Serialiser.cpp @@ -100,9 +100,15 @@ Serialiser::start_to_filename(const string& filename) { setlocale(LC_NUMERIC, "C"); - _base_uri = "file://" + filename; + cout << "STARTING SERIALIZATION TO FILENAME: " << filename << endl; + + assert(filename.find(":") == string::npos || filename.substr(0, 5) == "file:"); + if (filename.find(":") == string::npos) + _base_uri = "file://" + filename; + else + _base_uri = filename; _model = new Redland::Model(_world); - _model->set_base_uri(string("file://" + filename)); + _model->set_base_uri(_base_uri); _mode = TO_FILE; } @@ -429,19 +435,19 @@ void Serialiser::serialise_variables(Redland::Node subject, const GraphObject::Variables& variables) { for (GraphObject::Variables::const_iterator v = variables.begin(); v != variables.end(); ++v) { - if (v->first.find(":") != string::npos) { + if (v->first.find(":") != string::npos && v->first != "ingen:document") { if (v->second.is_valid()) { - const Redland::Node var_id = _world.blank_id(); - const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first); - const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second); - if (value) { - _model->add_statement(subject, "ingen:variable", var_id); - _model->add_statement(var_id, "ingen:key", key); - _model->add_statement(var_id, "ingen:value", value); - } else { - cerr << "Warning: can not serialise value: key '" << v->first << "', type " - << (int)v->second.type() << endl; - } + const Redland::Node var_id = _world.blank_id(); + const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first); + const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second); + if (value) { + _model->add_statement(subject, "ingen:variable", var_id); + _model->add_statement(var_id, "ingen:key", key); + _model->add_statement(var_id, "ingen:value", value); + } else { + cerr << "Warning: can not serialise value: key '" << v->first << "', type " + << (int)v->second.type() << endl; + } } else { cerr << "Warning: variable with no value: key '" << v->first << "'" << endl; } -- cgit v1.2.1