diff options
author | David Robillard <d@drobilla.net> | 2007-09-08 01:17:49 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-09-08 01:17:49 +0000 |
commit | 360cff412ea44e86c8481e781c19d401724f4abb (patch) | |
tree | 5a1f3fd846577715d63a031f1bed03fbc767b5e6 /src/libs | |
parent | a8c5598add06e2a413d06dbccb61708d164959b5 (diff) | |
download | ingen-360cff412ea44e86c8481e781c19d401724f4abb.tar.gz ingen-360cff412ea44e86c8481e781c19d401724f4abb.tar.bz2 ingen-360cff412ea44e86c8481e781c19d401724f4abb.zip |
Serialisation of patch enabled status.
git-svn-id: http://svn.drobilla.net/lad/ingen@700 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/client/Serializer.cpp | 9 | ||||
-rw-r--r-- | src/libs/gui/LoadPluginWindow.cpp | 8 | ||||
-rw-r--r-- | src/libs/module/module.cpp | 4 | ||||
-rw-r--r-- | src/libs/serialisation/Loader.cpp | 233 |
4 files changed, 138 insertions, 116 deletions
diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index 035ff0ba..bfcdc51c 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -247,10 +247,8 @@ Serializer::patch_path_to_rdf_id(const Path& path) return Node(_model->world(), Node::RESOURCE, _base_uri); } else { assert(path.length() > _root_object->path().length()); - const Node ret(_model->world(), Node::RESOURCE, + return Node(_model->world(), Node::RESOURCE, _base_uri + string("#") + path.substr(_root_object->path().length())); - cerr << "RDF ID: " << path << " -> " << ret.to_string() << endl; - return ret; } } @@ -278,6 +276,11 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch) "ingen:polyphony", Atom((int)patch->poly())); + _model->add_statement( + patch_id, + "ingen:enabled", + Atom(patch->enabled())); + for (MetadataMap::const_iterator m = patch->metadata().begin(); m != patch->metadata().end(); ++m) { if (m->first.find(":") != string::npos) { _model->add_statement( diff --git a/src/libs/gui/LoadPluginWindow.cpp b/src/libs/gui/LoadPluginWindow.cpp index f079bb18..6f1fe66f 100644 --- a/src/libs/gui/LoadPluginWindow.cpp +++ b/src/libs/gui/LoadPluginWindow.cpp @@ -221,13 +221,13 @@ LoadPluginWindow::set_plugins(const Raul::Table<string, SharedPtr<PluginModel> > row[_plugins_columns._col_name] = plugin->name(); //row[_plugins_columns._col_label] = plugin->plug_label(); - if (plugin->type_uri() == "ingen:Internal") + if (!strcmp(plugin->type_uri(), "ingen:Internal")) row[_plugins_columns._col_type] = "Internal"; - else if (plugin->type_uri() == "ingen:LV2") + else if (!strcmp(plugin->type_uri(), "ingen:LV2")) row[_plugins_columns._col_type] = "LV2"; - else if (plugin->type_uri() == "ingen:DSSI") + else if (!strcmp(plugin->type_uri(), "ingen:DSSI")) row[_plugins_columns._col_type] = "DSSI"; - else if (plugin->type_uri() == "ingen:LADSPA") + else if (!strcmp(plugin->type_uri(), "ingen:LADSPA")) row[_plugins_columns._col_type] = "LADSPA"; else row[_plugins_columns._col_type] = plugin->type_uri(); diff --git a/src/libs/module/module.cpp b/src/libs/module/module.cpp index 2914907a..f19f9e46 100644 --- a/src/libs/module/module.cpp +++ b/src/libs/module/module.cpp @@ -36,7 +36,7 @@ get_world() { static World* world = NULL; - if (!&world) { + if (&world == NULL) { cerr << "ERROR: Ingen::Shared::world undefined." << endl; return NULL; } @@ -58,7 +58,7 @@ get_world() void destroy_world() { - if (!&world) { + if (&world == NULL) { cerr << "ERROR: Ingen::Shared::world undefined." << endl; return; } diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp index d4c93b03..1a33dac9 100644 --- a/src/libs/serialisation/Loader.cpp +++ b/src/libs/serialisation/Loader.cpp @@ -41,17 +41,17 @@ namespace Serialisation { */ bool Loader::load(SharedPtr<EngineInterface> engine, - Raul::RDF::World* rdf_world, - const Glib::ustring& document_uri, - boost::optional<Path> parent, - string patch_name, - Glib::ustring patch_uri, - Raul::Table<string, Atom> data) + Raul::RDF::World* rdf_world, + const Glib::ustring& document_uri, + boost::optional<Path> parent, + string patch_name, + Glib::ustring patch_uri, + Raul::Table<string, Atom> data) { setlocale(LC_NUMERIC, "C"); // FIXME: this whole thing is a mess - + std::set<Path> created; RDF::Model model(*rdf_world, document_uri); @@ -68,8 +68,8 @@ Loader::load(SharedPtr<EngineInterface> engine, // FIXME: polyphony datatype RDF::Query query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?poly WHERE {\n") + - patch_uri + " ingen:polyphony ?poly\n }"); + "SELECT DISTINCT ?poly WHERE {\n") + + patch_uri + " ingen:polyphony ?poly\n }"); RDF::Query::Results results = query.run(*rdf_world, model); @@ -81,17 +81,17 @@ Loader::load(SharedPtr<EngineInterface> engine, 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 == "") { patch_name = string(document_uri.substr(document_uri.find_last_of("/")+1)); 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( - "SELECT DISTINCT ?name WHERE {\n") + - patch_uri + " ingen:name ?name\n}"); + "SELECT DISTINCT ?name WHERE {\n") + + patch_uri + " ingen:name ?name\n}"); results = query.run(*rdf_world, model); @@ -106,23 +106,23 @@ Loader::load(SharedPtr<EngineInterface> engine, /* Load (plugin) nodes */ - + query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") + - patch_uri + " ingen:node ?node .\n" - "?node ingen:name ?name ;\n" - " ingen:plugin ?plugin .\n" - "OPTIONAL { ?node ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" - "}"); + "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval WHERE {\n") + + patch_uri + " ingen:node ?node .\n" + "?node ingen:name ?name ;\n" + " ingen:plugin ?plugin .\n" + "OPTIONAL { ?node ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" + "}"); results = query.run(*rdf_world, model); for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - + const string name = (*i)["name"].to_string(); const string plugin = (*i)["plugin"].to_string(); - + const Path node_path = patch_path.base() + (string)name; if (created.find(node_path) == created.end()) { @@ -136,51 +136,51 @@ Loader::load(SharedPtr<EngineInterface> engine, if (floatkey != "" && val_node.is_float()) engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); } - + /* Load subpatches */ - + query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?patch ?name WHERE {\n") + - patch_uri + " ingen:node ?patch .\n" - "?patch a ingen:Patch ;\n" - " ingen:name ?name .\n" - "}"); + "SELECT DISTINCT ?patch ?name WHERE {\n") + + patch_uri + " ingen:node ?patch .\n" + "?patch a ingen:Patch ;\n" + " ingen:name ?name .\n" + "}"); results = query.run(*rdf_world, model); for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - + const string name = (*i)["name"].to_string(); const string patch = (*i)["patch"].to_string(); - + const Path subpatch_path = patch_path.base() + (string)name; - + if (created.find(subpatch_path) == created.end()) { created.insert(subpatch_path); load(engine, rdf_world, document_uri, patch_path, name, patch); } } - + //created.clear(); /* Set node port control values */ - + query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?nodename ?portname ?portval WHERE {\n") + - patch_uri + " ingen:node ?node .\n" - "?node ingen:name ?nodename ;\n" - " ingen:port ?port .\n" - "?port ingen:name ?portname ;\n" - " ingen:value ?portval .\n" - "FILTER ( datatype(?portval) = xsd:decimal )\n" - "}\n"); + "SELECT DISTINCT ?nodename ?portname ?portval WHERE {\n") + + patch_uri + " ingen:node ?node .\n" + "?node ingen:name ?nodename ;\n" + " ingen:port ?port .\n" + "?port ingen:name ?portname ;\n" + " ingen:value ?portval .\n" + "FILTER ( datatype(?portval) = xsd:decimal )\n" + "}\n"); results = query.run(*rdf_world, model); for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - + const string node_name = (*i)["nodename"].to_string(); const string port_name = (*i)["portname"].to_string(); const float val = (*i)["portval"].to_float(); @@ -189,21 +189,21 @@ Loader::load(SharedPtr<EngineInterface> engine, engine->set_port_value(port_path, val); } - + /* Load this patch's ports */ - + query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval WHERE {\n") + - patch_uri + " ingen:port ?port .\n" - "?port a ?type ;\n" - " ingen:name ?name ;\n" - " ingen:dataType ?datatype .\n" - "OPTIONAL { ?port ?floatkey ?floatval . \n" - " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" - "OPTIONAL { ?port ingen:value ?portval . \n" - " FILTER ( datatype(?portval) = xsd:decimal ) }\n" - "}"); + "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval WHERE {\n") + + patch_uri + " ingen:port ?port .\n" + "?port a ?type ;\n" + " ingen:name ?name ;\n" + " ingen:dataType ?datatype .\n" + "OPTIONAL { ?port ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" + "OPTIONAL { ?port ingen:value ?portval . \n" + " FILTER ( datatype(?portval) = xsd:decimal ) }\n" + "}"); results = query.run(*rdf_world, model); @@ -231,98 +231,98 @@ Loader::load(SharedPtr<EngineInterface> engine, if (floatkey != "" && val_node.is_float()) engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); } - + created.clear(); /* Node -> Node connections */ query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?srcnodename ?srcname ?dstnodename ?dstname WHERE {\n") + - patch_uri + "ingen:node ?srcnode ;\n" - " ingen:node ?dstnode .\n" - "?srcnode ingen:port ?src ;\n" - " ingen:name ?srcnodename .\n" - "?dstnode ingen:port ?dst ;\n" - " ingen:name ?dstnodename .\n" - "?src ingen:name ?srcname .\n" - "?dst ingen:connectedTo ?src ;\n" - " ingen:name ?dstname .\n" - "}\n"); - + "SELECT DISTINCT ?srcnodename ?srcname ?dstnodename ?dstname WHERE {\n") + + patch_uri + "ingen:node ?srcnode ;\n" + " ingen:node ?dstnode .\n" + "?srcnode ingen:port ?src ;\n" + " ingen:name ?srcnodename .\n" + "?dstnode ingen:port ?dst ;\n" + " ingen:name ?dstnodename .\n" + "?src ingen:name ?srcname .\n" + "?dst ingen:connectedTo ?src ;\n" + " ingen:name ?dstname .\n" + "}\n"); + results = query.run(*rdf_world, model); - + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { Path src_node = patch_path.base() + (*i)["srcnodename"].to_string(); Path src_port = src_node.base() + (*i)["srcname"].to_string(); Path dst_node = patch_path.base() + (*i)["dstnodename"].to_string(); Path dst_port = dst_node.base() + (*i)["dstname"].to_string(); - + cerr << patch_path << " 1 CONNECTION: " << src_port << " -> " << dst_port << endl; engine->connect(src_port, dst_port); } - + /* This Patch -> Node connections */ query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?srcname ?dstnodename ?dstname WHERE {\n") + - patch_uri + " ingen:port ?src ;\n" - " ingen:node ?dstnode .\n" - "?dstnode ingen:port ?dst ;\n" - " ingen:name ?dstnodename .\n" - "?dst ingen:connectedTo ?src ;\n" - " ingen:name ?dstname .\n" - "?src ingen:name ?srcname .\n" - "}\n"); - + "SELECT DISTINCT ?srcname ?dstnodename ?dstname WHERE {\n") + + patch_uri + " ingen:port ?src ;\n" + " ingen:node ?dstnode .\n" + "?dstnode ingen:port ?dst ;\n" + " ingen:name ?dstnodename .\n" + "?dst ingen:connectedTo ?src ;\n" + " ingen:name ?dstname .\n" + "?src ingen:name ?srcname .\n" + "}\n"); + results = query.run(*rdf_world, model); - + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { Path src_port = patch_path.base() + (*i)["srcname"].to_string(); Path dst_node = patch_path.base() + (*i)["dstnodename"].to_string(); Path dst_port = dst_node.base() + (*i)["dstname"].to_string(); - + cerr << patch_path << " 2 CONNECTION: " << src_port << " -> " << dst_port << endl; engine->connect(src_port, dst_port); } - - + + /* Node -> This Patch connections */ query = RDF::Query(*rdf_world, Glib::ustring( - "SELECT DISTINCT ?srcnodename ?srcname ?dstname WHERE {\n") + - patch_uri + " ingen:port ?dst ;\n" - " ingen:node ?srcnode .\n" - "?srcnode ingen:port ?src ;\n" - " ingen:name ?srcnodename .\n" - "?dst ingen:connectedTo ?src ;\n" - " ingen:name ?dstname .\n" - "?src ingen:name ?srcname .\n" - "}\n"); - + "SELECT DISTINCT ?srcnodename ?srcname ?dstname WHERE {\n") + + patch_uri + " ingen:port ?dst ;\n" + " ingen:node ?srcnode .\n" + "?srcnode ingen:port ?src ;\n" + " ingen:name ?srcnodename .\n" + "?dst ingen:connectedTo ?src ;\n" + " ingen:name ?dstname .\n" + "?src ingen:name ?srcname .\n" + "}\n"); + results = query.run(*rdf_world, model); - + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { Path dst_port = patch_path.base() + (*i)["dstname"].to_string(); Path src_node = patch_path.base() + (*i)["srcnodename"].to_string(); Path src_port = src_node.base() + (*i)["srcname"].to_string(); - + cerr << patch_path << " 3 CONNECTION: " << src_port << " -> " << dst_port << endl; engine->connect(src_port, dst_port); } - - + + /* Load metadata */ - + 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 ?floatkey ?floatval WHERE {\n") + + patch_uri + " ?floatkey ?floatval . \n" + " FILTER ( datatype(?floatval) = xsd:decimal ) \n" + "}"); results = query.run(*rdf_world, model); @@ -334,16 +334,35 @@ Loader::load(SharedPtr<EngineInterface> engine, if (floatkey != "" && val_node.is_float()) engine->set_metadata(patch_path, floatkey, Atom(val_node.to_float())); } - + // Set passed metadata last to override any loaded values for (Metadata::const_iterator i = data.begin(); i != data.end(); ++i) engine->set_metadata(patch_path, i->first, i->second); + + /* Enable */ + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?enabled WHERE {\n") + + patch_uri + " ingen:enabled ?enabled .\n" + "}"); + + results = query.run(*rdf_world, model); + + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + + RDF::Node enabled_node = (*i)["enabled"]; + + if (enabled_node.is_bool() && enabled_node.to_bool()) { + engine->enable_patch(patch_path); + break; + } + } + return true; } - } // namespace Serialisation } // namespace Ingen |