diff options
author | David Robillard <d@drobilla.net> | 2010-12-17 17:54:59 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-17 17:54:59 +0000 |
commit | c3c8acb6c62ad740bf8acedd8e21f50f735c2629 (patch) | |
tree | 8566caf5076e2016f104d504848a680134babe4f /src/engine | |
parent | 623a23dcd7bf6910a10594dc2599f31574c93860 (diff) | |
download | machina-c3c8acb6c62ad740bf8acedd8e21f50f735c2629.tar.gz machina-c3c8acb6c62ad740bf8acedd8e21f50f735c2629.tar.bz2 machina-c3c8acb6c62ad740bf8acedd8e21f50f735c2629.zip |
Use an actual wrapper for query results (instead of building a Bindings and returning that).
git-svn-id: http://svn.drobilla.net/lad/trunk/machina@2742 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/Loader.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/engine/Loader.cpp b/src/engine/Loader.cpp index a899fce..c50258c 100644 --- a/src/engine/Loader.cpp +++ b/src/engine/Loader.cpp @@ -50,6 +50,7 @@ SharedPtr<Machine> Loader::load(const Glib::ustring& uri) { using Redland::Query; + using Redland::QueryResults; using Glib::ustring; SharedPtr<Machine> machine; @@ -90,12 +91,13 @@ Loader::load(const Glib::ustring& uri) "?node :duration ?duration .\n" "}\n"); - Query::Results results = query.run(_rdf_world, model); + SharedPtr<QueryResults> results = query.run(_rdf_world, model); - for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const char* node_id = (*i)["node"]; - SharedPtr<Node> node(new Node( - TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), (*i)["duration"].to_float()), + for (; !results->finished(); results->next()) { + const char* node_id = results->get("node"); + SharedPtr<Node> node( + new Node( + TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), results->get("duration").to_float()), true)); machine->add_node(node); created[node_id] = node; @@ -111,12 +113,12 @@ Loader::load(const Glib::ustring& uri) "}\n"); results = query.run(_rdf_world, model); - - for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const char* node_id = (*i)["node"]; + + for (; !results->finished(); results->next()) { + const char* node_id = results->get("node"); if (created.find(node_id) == created.end()) { SharedPtr<Node> node(new Node( - TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), (*i)["duration"].to_float()), + TimeStamp(TimeUnit(TimeUnit::BEATS, MACHINA_PPQN), results->get("duration").to_float()), false)); machine->add_node(node); created[node_id] = node; @@ -134,8 +136,8 @@ Loader::load(const Glib::ustring& uri) results = query.run(_rdf_world, model); - for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const char* node_id = (*i)["node"]; + for (; !results->finished(); results->next()) { + const char* node_id = results->get("node"); Created::iterator n = created.find(node_id); if (n != created.end()) n->second->set_selector(true); @@ -153,12 +155,11 @@ Loader::load(const Glib::ustring& uri) "}\n")); results = query.run(_rdf_world, model); - - for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - Created::iterator node_i = created.find((const char*)(*i)["node"]); + for (; !results->finished(); results->next()) { + Created::iterator node_i = created.find((const char*)results->get("node")); if (node_i != created.end()) { SharedPtr<Node> node = node_i->second; - const int note_num = (*i)["note"].to_int(); + const int note_num = results->get("note").to_int(); if (note_num >= 0 && note_num <= 127) { node->set_enter_action(ActionFactory::note_on((unsigned char)note_num)); node->set_exit_action(ActionFactory::note_off((unsigned char)note_num)); @@ -182,10 +183,10 @@ Loader::load(const Glib::ustring& uri) results = query.run(_rdf_world, model); - for (Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const char* src_uri = (*i)["src"]; - const char* dst_uri = (*i)["dst"]; - float prob = (*i)["prob"].to_float(); + for (; !results->finished(); results->next()) { + const char* src_uri = results->get("src"); + const char* dst_uri = results->get("dst"); + float prob = results->get("prob").to_float(); Created::iterator src_i = created.find(src_uri); Created::iterator dst_i = created.find(dst_uri); |