diff options
author | David Robillard <d@drobilla.net> | 2006-12-09 19:08:03 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-12-09 19:08:03 +0000 |
commit | c9fdc9d94f3d6081e36e98f5ae6cc03f361e8057 (patch) | |
tree | 8cfe823900c227341a051c0f96d9783dbbb6e64e /src/libs/client/Loader.cpp | |
parent | d5e8ce8127784fc67953ab3b6247e911be697cc2 (diff) | |
download | ingen-c9fdc9d94f3d6081e36e98f5ae6cc03f361e8057.tar.gz ingen-c9fdc9d94f3d6081e36e98f5ae6cc03f361e8057.tar.bz2 ingen-c9fdc9d94f3d6081e36e98f5ae6cc03f361e8057.zip |
More loading progress (node positions restore).
git-svn-id: http://svn.drobilla.net/lad/ingen@215 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/client/Loader.cpp')
-rw-r--r-- | src/libs/client/Loader.cpp | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp index 7816e88a..ac661e58 100644 --- a/src/libs/client/Loader.cpp +++ b/src/libs/client/Loader.cpp @@ -23,9 +23,15 @@ namespace Ingen { namespace Client { -Loader::Loader(SharedPtr<ModelEngineInterface> engine) +Loader::Loader(SharedPtr<ModelEngineInterface> engine, SharedPtr<Namespaces> namespaces) : _engine(engine) + , _namespaces(namespaces) { + if (!_namespaces) + _namespaces = SharedPtr<Namespaces>(new Namespaces()); + + // FIXME: hack + _namespaces->add("ingenuity", "http://codeson.net/ns/ingenuity#"); } @@ -39,16 +45,40 @@ void Loader::load(const Glib::ustring& filename, const Path& parent) { - RDFQuery query(Glib::ustring("SELECT DISTINCT ?name ?plugin FROM <") + filename + "> WHERE {\n" - + "?patch ingen:node ?node .\n" - + "?node ingen:name ?name ;\n" - + " ingen:plugin ?plugin .\n" - + "}"); + std::map<Glib::ustring, bool> created; + + RDFQuery query(Glib::ustring( + "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval FROM <") + filename + "> WHERE {\n" + "?patch ingen:node ?node .\n" + "?node ingen:name ?name ;\n" + " ingen:plugin ?plugin ;\n" + "OPTIONAL { ?node ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal )\n" + " }\n" + "}"); RDFQuery::Results nodes = query.run(filename); - for (RDFQuery::Results::iterator i = nodes.begin(); i != nodes.end(); ++i) - _engine->create_node(parent.base() + (*i)["name"], (*i)["plugin"], false); + for (RDFQuery::Results::iterator i = nodes.begin(); i != nodes.end(); ++i) { + const Glib::ustring& name = (*i)["name"]; + const Glib::ustring& plugin = (*i)["plugin"]; + + if (created.find(name) == created.end()) { + cerr << "CREATING " << name << endl; + _engine->create_node(parent.base() + name, plugin, false); + created[name] = true; + } + + Glib::ustring floatkey = _namespaces->qualify((*i)["floatkey"]); + Glib::ustring floatval = (*i)["floatval"]; + + float val = atof(floatval.c_str()); + + cerr << floatkey << " = " << val << endl; + + _engine->set_metadata(parent.base() + name, floatkey, Atom(val)); + } + } |