diff options
author | David Robillard <d@drobilla.net> | 2007-05-01 04:01:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-05-01 04:01:04 +0000 |
commit | 3e5fef2e59776923f175a4260adf18c559ab861f (patch) | |
tree | 5c83291c595830ac472e5661de83d4560513a9d6 | |
parent | 71b5ad39baceacb5d7aa75050fd8c76bfb16fb76 (diff) | |
download | ingen-3e5fef2e59776923f175a4260adf18c559ab861f.tar.gz ingen-3e5fef2e59776923f175a4260adf18c559ab861f.tar.bz2 ingen-3e5fef2e59776923f175a4260adf18c559ab861f.zip |
Converted Raul (and thus Ingen and Machina) to use Redland over Raptor/Rasqal independently.
Fixed patch loading for Ingen (local only, still something wrong with remote...).
git-svn-id: http://svn.drobilla.net/lad/ingen@486 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/libs/client/Loader.cpp | 214 | ||||
-rw-r--r-- | src/libs/client/Loader.h | 10 | ||||
-rw-r--r-- | src/libs/client/PluginModel.cpp | 3 | ||||
-rw-r--r-- | src/libs/client/PluginModel.h | 22 | ||||
-rw-r--r-- | src/libs/client/Serializer.cpp | 184 | ||||
-rw-r--r-- | src/libs/client/Serializer.h | 54 | ||||
-rw-r--r-- | src/libs/engine/LADSPANode.cpp | 4 | ||||
-rw-r--r-- | src/progs/ingenuity/App.cpp | 12 | ||||
-rw-r--r-- | src/progs/ingenuity/App.h | 5 | ||||
-rw-r--r-- | src/progs/ingenuity/ControlGroups.cpp | 4 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadPluginWindow.cpp | 8 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadRemotePatchWindow.cpp | 18 | ||||
-rw-r--r-- | src/progs/ingenuity/LoadSubpatchWindow.cpp | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchCanvas.cpp | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/PortPropertiesWindow.cpp | 16 | ||||
-rw-r--r-- | src/progs/ingenuity/ThreadedLoader.cpp | 5 | ||||
-rw-r--r-- | src/progs/ingenuity/UploadPatchWindow.cpp | 2 | ||||
-rw-r--r-- | src/progs/ingenuity/main.cpp | 1 | ||||
-rw-r--r-- | src/progs/patch_loader/patch_loader.cpp | 18 |
19 files changed, 306 insertions, 278 deletions
diff --git a/src/libs/client/Loader.cpp b/src/libs/client/Loader.cpp index 789b0b57..0efc07c9 100644 --- a/src/libs/client/Loader.cpp +++ b/src/libs/client/Loader.cpp @@ -17,8 +17,8 @@ #include <iostream> #include <glibmm/ustring.h> -#include <raptor.h> -#include "raul/RDFQuery.h" +#include <raul/RDFModel.h> +#include <raul/RDFQuery.h> #include "Loader.h" #include "ModelEngineInterface.h" @@ -28,18 +28,10 @@ namespace Ingen { namespace Client { -Loader::Loader(SharedPtr<ModelEngineInterface> engine, SharedPtr<Namespaces> namespaces) +Loader::Loader(SharedPtr<ModelEngineInterface> engine, Raul::RDF::World* rdf_world) : _engine(engine) - , _namespaces(namespaces) + , _rdf_world(rdf_world) { - if (!_namespaces) - _namespaces = SharedPtr<Namespaces>(new Namespaces()); - - (*_namespaces)["xsd"] = "http://www.w3.org/2001/XMLSchema#"; - (*_namespaces)["ingen"] = "http://drobilla.net/ns/ingen#"; - (*_namespaces)["ingenuity"] = "http://drobilla.net/ns/ingenuity#"; - (*_namespaces)["lv2"] = "http://lv2plug.in/ontology#"; - (*_namespaces)["doap"] = "http://usefulinc.com/ns/doap#"; } @@ -50,7 +42,8 @@ Loader::Loader(SharedPtr<ModelEngineInterface> engine, SharedPtr<Namespaces> nam * @return whether or not load was successful. */ bool -Loader::load(const Glib::ustring& document_uri, +Loader::load(Raul::RDF::World* rdf_world, + const Glib::ustring& document_uri, boost::optional<Path> parent, string patch_name, Glib::ustring patch_uri, @@ -60,12 +53,10 @@ Loader::load(const Glib::ustring& document_uri, std::map<Path, bool> created; - // FIXME: kluge - //unsigned char* document_uri_str = raptor_uri_filename_to_uri_string(filename.c_str()); - //Glib::ustring document_uri = (const char*)document_uri_str; - //Glib::ustring document_uri = "file:///home/dave/code/drobillanet/ingen/src/progs/ingenuity/test2.ingen.ttl"; + RDF::Model model(*rdf_world, document_uri); - patch_uri = string("<") + patch_uri + ">"; + //patch_uri = string("<") + patch_uri + ">"; + patch_uri = string("<") + document_uri + ">"; cerr << "[Loader] Loading " << patch_uri << " from " << document_uri << " under " << (string)(parent ? (string)parent.get() : "no parent") << endl; @@ -73,20 +64,20 @@ Loader::load(const Glib::ustring& document_uri, /* Get polyphony (mandatory) */ // FIXME: polyphony datatype - RDFQuery query(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?poly FROM <") + document_uri + "> WHERE {\n" + - patch_uri + " ingen:polyphony ?poly .\n" - "}"); + RDF::Query query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?poly WHERE {\n") + + patch_uri + " ingen:polyphony ?poly\n }"); - RDFQuery::Results results = query.run(document_uri); + RDF::Query::Results results = query.run(*rdf_world, model); if (results.size() == 0) { cerr << "[Loader] ERROR: No polyphony found!" << endl; return false; } - size_t patch_poly = atoi(((*results.begin())["poly"]).c_str()); - + RDF::Node poly_node = (*results.begin())["poly"]; + assert(poly_node.is_int()); + size_t patch_poly = (size_t)poly_node.to_int(); /* Get name (if available/necessary) */ @@ -95,15 +86,14 @@ Loader::load(const Glib::ustring& document_uri, if (patch_name.substr(patch_name.length()-10) == ".ingen.ttl") patch_name = patch_name.substr(0, patch_name.length()-10); - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?name FROM <") + document_uri + "> WHERE {\n" + - patch_uri + " ingen:name ?name .\n" - "}"); + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?name WHERE {\n") + + patch_uri + " ingen:name ?name\n}"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); if (results.size() > 0) - patch_name = string((*results.begin())["name"]); + patch_name = (*results.begin())["name"].to_string(); } Path patch_path = ( parent ? (parent.get().base() + patch_name) : Path("/") ); @@ -114,8 +104,8 @@ Loader::load(const Glib::ustring& document_uri, /* Load (plugin) nodes */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?name ?plugin ?floatkey ?floatval FROM <") + document_uri + "> WHERE {\n" + + 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" @@ -123,12 +113,12 @@ Loader::load(const Glib::ustring& document_uri, " FILTER ( datatype(?floatval) = xsd:decimal ) }\n" "}"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const Glib::ustring& name = (*i)["name"]; - const Glib::ustring& plugin = (*i)["plugin"]; + string name = (*i)["name"].to_string(); + string plugin = (*i)["plugin"].to_string(); const Path node_path = patch_path.base() + (string)name; @@ -137,36 +127,34 @@ Loader::load(const Glib::ustring& document_uri, created[node_path] = true; } - const Glib::ustring& floatkey = _namespaces->qualify((*i)["floatkey"]); - const Glib::ustring& floatval = (*i)["floatval"]; + string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); + RDF::Node val_node = (*i)["floatval"]; - if (floatkey != "" && floatval != "") { - const float val = atof(floatval.c_str()); - _engine->set_metadata(patch_path.base() + name, floatkey, Atom(val)); - } + if (floatkey != "" && val_node.is_float()) + _engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); } /* Load subpatches */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?patch ?name FROM <") + document_uri + "> WHERE {\n" + + 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" "}"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const Glib::ustring& name = (*i)["name"]; - const Glib::ustring& patch = (*i)["patch"]; + string name = (*i)["name"].to_string(); + string patch = (*i)["patch"].to_string(); const Path subpatch_path = patch_path.base() + (string)name; if (created.find(subpatch_path) == created.end()) { - load(document_uri, patch_path, name, patch); + load(rdf_world, document_uri, patch_path, name, patch); created[subpatch_path] = true; } } @@ -176,37 +164,34 @@ Loader::load(const Glib::ustring& document_uri, /* Set node port control values */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?nodename ?portname ?portval FROM <") + document_uri + "> WHERE {\n" + + 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"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const Glib::ustring& node_name = (*i)["nodename"]; - const Glib::ustring& port_name = (*i)["portname"]; - const Glib::ustring& portval = (*i)["portval"]; + string node_name = (*i)["nodename"].to_string(); + string port_name = (*i)["portname"].to_string(); + const float val = (*i)["portval"].to_float(); Path port_path = patch_path.base() + (const string&)node_name +"/"+ (const string&)port_name; - if (portval != "") { - const float val = atof(portval.c_str()); - cerr << port_path << " VALUE: " << val << endl; - _engine->set_port_value(port_path, val); - } + _engine->set_port_value(port_path, val); } /* Load this patch's ports */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?port ?type ?name ?datatype ?floatkey ?floatval ?portval FROM <") + document_uri + "> WHERE {\n" + + 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" @@ -217,12 +202,12 @@ Loader::load(const Glib::ustring& document_uri, " FILTER ( datatype(?portval) = xsd:decimal ) }\n" "}"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { - const Glib::ustring& name = (*i)["name"]; - const Glib::ustring& type = _namespaces->qualify((*i)["type"]); - const Glib::ustring& datatype = (*i)["datatype"]; + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { + string name = (*i)["name"].to_string(); + string type = _rdf_world->qualify((*i)["type"].to_string()); + string datatype = (*i)["datatype"].to_string(); const Path port_path = patch_path.base() + (string)name; @@ -233,20 +218,15 @@ Loader::load(const Glib::ustring& document_uri, created[port_path] = true; } - const Glib::ustring& portval = (*i)["portval"]; - if (portval != "") { - const float val = atof(portval.c_str()); - cerr << name << " VALUE: " << val << endl; - _engine->set_port_value(patch_path.base() + name, val); - } + RDF::Node val_node = (*i)["portval"]; + if (val_node.is_float()) + _engine->set_port_value(patch_path.base() + name, val_node.to_float()); - const Glib::ustring& floatkey = _namespaces->qualify((*i)["floatkey"]); - const Glib::ustring& floatval = (*i)["floatval"]; + string floatkey = _rdf_world->qualify((*i)["floatkey"].to_string()); + val_node = (*i)["floatval"]; - if (floatkey != "" && floatval != "") { - const float val = atof(floatval.c_str()); - _engine->set_metadata(patch_path.base() + name, floatkey, Atom(val)); - } + if (floatkey != "" && val_node.is_float()) + _engine->set_metadata(patch_path.base() + name, floatkey, Atom(val_node.to_float())); } created.clear(); @@ -254,12 +234,12 @@ Loader::load(const Glib::ustring& document_uri, /* Node -> Node connections */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?srcnodename ?srcname ?dstnodename ?dstname FROM <") + document_uri + "> WHERE {\n" + - patch_uri + " ingen:node ?srcnode ;\n" + 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" + + " ingen:name ?srcnodename .\n" "?dstnode ingen:port ?dst ;\n" " ingen:name ?dstnodename .\n" "?src ingen:name ?srcname .\n" @@ -267,13 +247,13 @@ Loader::load(const Glib::ustring& document_uri, " ingen:name ?dstname .\n" "}\n"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { - Path src_node = patch_path.base() + string((*i)["srcnodename"]); - Path src_port = src_node.base() + string((*i)["srcname"]); - Path dst_node = patch_path.base() + string((*i)["dstnodename"]); - Path dst_port = dst_node.base() + string((*i)["dstname"]); + 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; @@ -283,9 +263,9 @@ Loader::load(const Glib::ustring& document_uri, /* This Patch -> Node connections */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?srcname ?dstnodename ?dstname FROM <") + document_uri + "> WHERE {\n" + - patch_uri + " ingen:port ?src ;\n" + + 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" @@ -294,13 +274,12 @@ Loader::load(const Glib::ustring& document_uri, "?src ingen:name ?srcname .\n" "}\n"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { - Path src_port = patch_path.base() + string((*i)["srcname"]); - - Path dst_node = patch_path.base() + string((*i)["dstnodename"]); - Path dst_port = dst_node.base() + string((*i)["dstname"]); + 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; @@ -310,9 +289,9 @@ Loader::load(const Glib::ustring& document_uri, /* Node -> This Patch connections */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?srcnodename ?srcname ?dstname FROM <") + document_uri + "> WHERE {\n" + - patch_uri + " ingen:port ?dst ;\n" + + 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" @@ -321,13 +300,12 @@ Loader::load(const Glib::ustring& document_uri, "?src ingen:name ?srcname .\n" "}\n"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { - Path dst_port = patch_path.base() + string((*i)["dstname"]); - - Path src_node = patch_path.base() + string((*i)["srcnodename"]); - Path src_port = src_node.base() + string((*i)["srcname"]); + 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; @@ -337,23 +315,21 @@ Loader::load(const Glib::ustring& document_uri, /* Load metadata */ - query = RDFQuery(*_namespaces, Glib::ustring( - "SELECT DISTINCT ?floatkey ?floatval FROM <") + document_uri + "> WHERE {\n" + + query = RDF::Query(*rdf_world, Glib::ustring( + "SELECT DISTINCT ?floatkey ?floatval WHERE {\n") + patch_uri + " ?floatkey ?floatval . \n" " FILTER ( datatype(?floatval) = xsd:decimal ) \n" "}"); - results = query.run(document_uri); + results = query.run(*rdf_world, model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { - const Glib::ustring& floatkey = _namespaces->qualify((*i)["floatkey"]); - const Glib::ustring& floatval = (*i)["floatval"]; + string floatkey = rdf_world->prefixes().qualify((*i)["floatkey"].to_string()); + RDF::Node val_node = (*i)["floatval"]; - if (floatkey != "" && floatval != "") { - const float val = atof(floatval.c_str()); - _engine->set_metadata(patch_path, floatkey, Atom(val)); - } + if (floatkey != "" && val_node.is_float()) + _engine->set_metadata(patch_path, floatkey, Atom(val_node.to_float())); } diff --git a/src/libs/client/Loader.h b/src/libs/client/Loader.h index 76a3e60c..371e7065 100644 --- a/src/libs/client/Loader.h +++ b/src/libs/client/Loader.h @@ -22,10 +22,9 @@ #include <glibmm/ustring.h> #include "raul/SharedPtr.h" #include "raul/Path.h" -#include "raul/Namespaces.h" #include "ObjectModel.h" -using Raul::Namespaces; +namespace Raul { namespace RDF { class World; } } namespace Ingen { namespace Client { @@ -37,9 +36,10 @@ class ModelEngineInterface; */ class Loader { public: - Loader(SharedPtr<ModelEngineInterface> engine, SharedPtr<Namespaces> = SharedPtr<Namespaces>()); + Loader(SharedPtr<ModelEngineInterface> engine, Raul::RDF::World* rdf_world); - bool load(const Glib::ustring& uri, + bool load(Raul::RDF::World* world, + const Glib::ustring& uri, boost::optional<Path> parent, string patch_name, Glib::ustring patch_uri = "", @@ -48,7 +48,7 @@ public: private: //string _patch_search_path; SharedPtr<ModelEngineInterface> _engine; - SharedPtr<Namespaces> _namespaces; + Raul::RDF::World* _rdf_world; }; diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp index 89dcab6d..24b45179 100644 --- a/src/libs/client/PluginModel.cpp +++ b/src/libs/client/PluginModel.cpp @@ -24,7 +24,8 @@ namespace Ingen { namespace Client { -SLV2World PluginModel::_slv2_world = NULL; +SLV2World PluginModel::_slv2_world = NULL; +SLV2Plugins PluginModel::_slv2_plugins = NULL; string diff --git a/src/libs/client/PluginModel.h b/src/libs/client/PluginModel.h index d15d0ff4..aba4d1cf 100644 --- a/src/libs/client/PluginModel.h +++ b/src/libs/client/PluginModel.h @@ -48,17 +48,7 @@ public: , _name(name) { set_type_from_uri(type_uri); -#ifdef HAVE_SLV2 - static SLV2Plugins plugins = NULL; - - if (!_slv2_world) { - _slv2_world = slv2_world_new(); - slv2_world_load_all(_slv2_world); - plugins = slv2_world_get_all_plugins(_slv2_world); - } - - _slv2_plugin = slv2_plugins_get_by_uri(plugins, uri.c_str()); -#endif + _slv2_plugin = slv2_plugins_get_by_uri(_slv2_plugins, uri.c_str()); } Type type() const { return _type; } @@ -108,6 +98,12 @@ public: #ifdef HAVE_SLV2 SLV2Plugin slv2_plugin() { return _slv2_plugin; } static SLV2World slv2_world() { return _slv2_world; } + + static void set_slv2_world(SLV2World world) { + _slv2_world = world; + slv2_world_load_all(_slv2_world); + _slv2_plugins = slv2_world_get_all_plugins(_slv2_world); + } #endif private: @@ -116,7 +112,9 @@ private: string _name; #ifdef HAVE_SLV2 - static SLV2World _slv2_world; + static SLV2World _slv2_world; + static SLV2Plugins _slv2_plugins; + SLV2Plugin _slv2_plugin; #endif }; diff --git a/src/libs/client/Serializer.cpp b/src/libs/client/Serializer.cpp index 762cd061..85a13331 100644 --- a/src/libs/client/Serializer.cpp +++ b/src/libs/client/Serializer.cpp @@ -27,7 +27,12 @@ #include <cstdlib> // atof #include <boost/optional/optional.hpp> #include <cstring> -#include <raptor.h> +#include <raul/RDFWorld.h> +#include <raul/RDFModel.h> +#include <raul/RDFNode.h> +#include <raul/Path.h> +#include <raul/Atom.h> +#include <raul/AtomRedland.h> #include "Serializer.h" #include "PatchModel.h" #include "NodeModel.h" @@ -36,25 +41,19 @@ #include "PresetModel.h" #include "ModelEngineInterface.h" #include "PluginModel.h" -#include "raul/Path.h" -#include "raul/Atom.h" -#include "raul/AtomRaptor.h" -using std::string; using std::vector; using std::pair; -using std::cerr; using std::cout; using std::endl; -using boost::optional; +using namespace std; using namespace Raul; +using namespace Raul::RDF; +using boost::optional; namespace Ingen { namespace Client { -Serializer::Serializer() +Serializer::Serializer(Raul::RDF::World& world) + : _world(world) { - _writer.add_prefix("ingen", "http://drobilla.net/ns/ingen#"); - _writer.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#"); - _writer.add_prefix("lv2", "http://lv2plug.in/ontology#"); - _writer.add_prefix("doap", "http://usefulinc.com/ns/doap#"); } @@ -63,10 +62,12 @@ Serializer::Serializer() * This must be called before any serializing methods. */ void -Serializer::start_to_filename(const string& filename) throw (std::logic_error) +Serializer::start_to_filename(const string& filename) { _base_uri = "file://" + filename; - _writer.start_to_filename(filename); + _model = new RDF::Model(_world); + _mode = TO_FILE; + _filename = filename; } @@ -78,10 +79,12 @@ Serializer::start_to_filename(const string& filename) throw (std::logic_error) * the desired objects have been serialized. */ void -Serializer::start_to_string() throw (std::logic_error) +Serializer::start_to_string() { _base_uri = ""; - _writer.start_to_string(); + _model = new RDF::Model(_world); + _mode = TO_STRING; + _filename = ""; } @@ -91,18 +94,28 @@ Serializer::start_to_string() throw (std::logic_error) * will be returned, otherwise the empty string is returned. */ string -Serializer::finish() throw(std::logic_error) +Serializer::finish() { - return _writer.finish(); - _id_map.clear(); + string ret = ""; + + if (_mode == TO_FILE) + _model->serialize_to_file(_filename); + else + ret = _model->serialize_to_string(); + + _filename = ""; + _node_map.clear(); + + return ret; } /** Convert a path to an RDF blank node ID for serializing. */ -RdfId +Node Serializer::path_to_node_id(const Path& path) { + assert(_model); /*string ret = path.substr(1); for (size_t i=0; i < ret.length(); ++i) { @@ -110,15 +123,15 @@ Serializer::path_to_node_id(const Path& path) ret[i] = '_'; } - return RdfId(RdfId::ANONYMOUS, ret); + return Node(Node::BLANK, ret); */ - IDMap::iterator i = _id_map.find(path); - if (i != _id_map.end()) { + NodeMap::iterator i = _node_map.find(path); + if (i != _node_map.end()) { return i->second; } else { - const RdfId id = _writer.blank_id(); - _id_map[path] = id; + Node id = _world.blank_id(); + _node_map[path] = id; return id; } } @@ -178,12 +191,12 @@ Serializer::find_file(const string& filename, const string& additional_path) void Serializer::serialize(SharedPtr<ObjectModel> object) throw (std::logic_error) { - if (!_writer.serialization_in_progress()) + if (!_model) throw std::logic_error("serialize called without serialization in progress"); SharedPtr<PatchModel> patch = PtrCast<PatchModel>(object); if (patch) { - serialize_patch(patch, RdfId(RdfId::RESOURCE, _base_uri)); + serialize_patch(patch, Node(_model->world(), Node::RESOURCE, _base_uri)); return; } @@ -205,29 +218,31 @@ Serializer::serialize(SharedPtr<ObjectModel> object) throw (std::logic_error) void -Serializer::serialize_patch(SharedPtr<PatchModel> patch, const RdfId& patch_id) +Serializer::serialize_patch(SharedPtr<PatchModel> patch, const Node& patch_id) { - _writer.write( + assert(_model); + + _model->add_statement( patch_id, - NS_RDF("type"), - NS_INGEN("Patch")); + "rdf:type", + "ingen:Patch"); if (patch->path().name().length() > 0) { - _writer.write( - patch_id, NS_INGEN("name"), + _model->add_statement( + patch_id, "ingen:name", Atom(patch->path().name().c_str())); } - _writer.write( + _model->add_statement( patch_id, - NS_INGEN("polyphony"), + "ingen:polyphony", Atom((int)patch->poly())); for (MetadataMap::const_iterator m = patch->metadata().begin(); m != patch->metadata().end(); ++m) { - if (_writer.expand_uri(m->first) != "") { - _writer.write( + if (m->first.find(":") != string::npos) { + _model->add_statement( patch_id, - RdfId(RdfId::RESOURCE, _writer.expand_uri(m->first.c_str()).c_str()), + m->first.c_str(), m->second); } } @@ -235,20 +250,20 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch, const RdfId& patch_id) for (NodeModelMap::const_iterator n = patch->nodes().begin(); n != patch->nodes().end(); ++n) { SharedPtr<PatchModel> patch = PtrCast<PatchModel>(n->second); if (patch) { - const RdfId subpatch_id = RdfId(RdfId::RESOURCE, + const Node subpatch_id = Node(_model->world(), Node::RESOURCE, patch_id.to_string() + "#" + patch->path().substr(1)); - _writer.write(patch_id, NS_INGEN("node"), subpatch_id); + _model->add_statement(patch_id, "ingen:node", subpatch_id); serialize_patch(patch, subpatch_id); } else { - const RdfId node_id = path_to_node_id(n->second->path()); - _writer.write(patch_id, NS_INGEN("node"), node_id); + const Node node_id = path_to_node_id(n->second->path()); + _model->add_statement(patch_id, "ingen:node", node_id); serialize_node(n->second, node_id); } } for (PortModelList::const_iterator p = patch->ports().begin(); p != patch->ports().end(); ++p) { - const RdfId port_id = path_to_node_id((*p)->path()); - _writer.write(patch_id, NS_INGEN("port"), port_id); + const Node port_id = path_to_node_id((*p)->path()); + _model->add_statement(patch_id, "ingen:port", port_id); serialize_port(*p, port_id); } @@ -261,53 +276,55 @@ Serializer::serialize_patch(SharedPtr<PatchModel> patch, const RdfId& patch_id) void Serializer::serialize_plugin(SharedPtr<PluginModel> plugin) { - const RdfId plugin_id = RdfId(RdfId::RESOURCE, plugin->uri()); + assert(_model); + + const Node plugin_id = Node(_model->world(), Node::RESOURCE, plugin->uri()); - _writer.write( + _model->add_statement( plugin_id, - NS_RDF("type"), - RdfId(RdfId::RESOURCE, plugin->type_uri())); -} + "rdf:type", + Node(_model->world(), Node::RESOURCE, plugin->type_uri())); +} void -Serializer::serialize_node(SharedPtr<NodeModel> node, const RdfId& node_id) +Serializer::serialize_node(SharedPtr<NodeModel> node, const Node& node_id) { - const RdfId plugin_id = RdfId(RdfId::RESOURCE, node->plugin()->uri()); + const Node plugin_id = Node(_model->world(), Node::RESOURCE, node->plugin()->uri()); - _writer.write( + _model->add_statement( node_id, - NS_RDF("type"), - NS_INGEN("Node")); + "rdf:type", + "ingen:Node"); - _writer.write( + _model->add_statement( node_id, - NS_INGEN("name"), + "ingen:name", node->path().name()); - _writer.write( + _model->add_statement( node_id, - NS_INGEN("plugin"), + "ingen:plugin", plugin_id); //serialize_plugin(node->plugin()); - /*_writer.write(_serializer, + /*_model->add_statement(_serializer, node_uri_ref.c_str(), - NS_INGEN("name"), + "ingen:name", Atom(node->path().name()));*/ for (PortModelList::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p) { - const RdfId port_id = path_to_node_id((*p)->path()); + const Node port_id = path_to_node_id((*p)->path()); serialize_port(*p, port_id); - _writer.write(node_id, NS_INGEN("port"), port_id); + _model->add_statement(node_id, "ingen:port", port_id); } for (MetadataMap::const_iterator m = node->metadata().begin(); m != node->metadata().end(); ++m) { - if (_writer.expand_uri(m->first) != "") { - _writer.write( + if (m->first.find(":") != string::npos) { + _model->add_statement( node_id, - RdfId(RdfId::RESOURCE, _writer.expand_uri(m->first.c_str()).c_str()), + m->first, m->second); } } @@ -318,26 +335,26 @@ Serializer::serialize_node(SharedPtr<NodeModel> node, const RdfId& node_id) * Audio output ports with no metadata will not be written, for example. */ void -Serializer::serialize_port(SharedPtr<PortModel> port, const RdfId& port_id) +Serializer::serialize_port(SharedPtr<PortModel> port, const Node& port_id) { if (port->is_input()) - _writer.write(port_id, NS_RDF("type"), NS_INGEN("InputPort")); + _model->add_statement(port_id, "rdf:type", "ingen:InputPort"); else - _writer.write(port_id, NS_RDF("type"), NS_INGEN("OutputPort")); + _model->add_statement(port_id, "rdf:type", "ingen:OutputPort"); - _writer.write(port_id, NS_INGEN("name"), Atom(port->path().name().c_str())); + _model->add_statement(port_id, "ingen:name", Atom(port->path().name().c_str())); - _writer.write(port_id, NS_INGEN("dataType"), Atom(port->type())); + _model->add_statement(port_id, "ingen:dataType", Atom(port->type())); if (port->is_control() && port->is_input()) - _writer.write(port_id, NS_INGEN("value"), Atom(port->value())); + _model->add_statement(port_id, "ingen:value", Atom(port->value())); if (port->metadata().size() > 0) { for (MetadataMap::const_iterator m = port->metadata().begin(); m != port->metadata().end(); ++m) { - if (_writer.expand_uri(m->first) != "") { - _writer.write( + if (m->first.find(":") != string::npos) { + _model->add_statement( port_id, - RdfId(RdfId::RESOURCE, _writer.expand_uri(m->first).c_str()), + m->first, m->second); } } @@ -348,22 +365,25 @@ Serializer::serialize_port(SharedPtr<PortModel> port, const RdfId& port_id) void Serializer::serialize_connection(SharedPtr<ConnectionModel> connection) throw (std::logic_error) { - const RdfId connection_id = RdfId(RdfId::ANONYMOUS, + if (!_model) + throw std::logic_error("serialize_connection called without serialization in progress"); + + const Node connection_id = Node(_model->world(), Node::BLANK, path_to_node_id(connection->src_port_path()).to_string() + "-" + path_to_node_id(connection->dst_port_path()).to_string()); - _writer.write(path_to_node_id(connection->dst_port_path()), - NS_INGEN("connectedTo"), + _model->add_statement(path_to_node_id(connection->dst_port_path()), + "ingen:connectedTo", path_to_node_id(connection->src_port_path())); - /*_writer.write(connection_id, NS_RDF("type"), NS_INGEN("Connection")); + /*_model->add_statement(connection_id, "rdf:type", "ingen:Connection"; - _writer.write(connection_id, - NS_INGEN("source"), + _model->add_statement(connection_id, + "ingen:source", path_to_node_id(connection->src_port_path())); - _writer.write(connection_id, - NS_INGEN("destination"), + _model->add_statement(connection_id, + "ingen:destination", path_to_node_id(connection->dst_port_path())); */ } diff --git a/src/libs/client/Serializer.h b/src/libs/client/Serializer.h index 83e85bf8..ad91afac 100644 --- a/src/libs/client/Serializer.h +++ b/src/libs/client/Serializer.h @@ -23,18 +23,13 @@ #include <string> #include <stdexcept> #include <cassert> -#include <boost/optional/optional.hpp> -#include <raptor.h> -#include "raul/SharedPtr.h" -#include "raul/Path.h" -#include "raul/Atom.h" -#include "raul/RDFWriter.h" +#include <raul/SharedPtr.h> +#include <raul/Path.h> +#include <raul/Atom.h> +#include <raul/RDFWorld.h> +#include <raul/RDFModel.h> #include "ObjectModel.h" -using std::string; -using boost::optional; -using Raul::RdfId; - namespace Ingen { namespace Client { @@ -47,11 +42,6 @@ class PresetModel; class ModelEngineInterface; -/** Namespace prefix macros. */ -#define NS_RDF(x) RdfId(RdfId::RESOURCE, "http://www.w3.org/1999/02/22-rdf-syntax-ns#" x) -#define NS_INGEN(x) RdfId(RdfId::RESOURCE, "http://drobilla.net/ns/ingen#" x) - - /** Serializes Ingen objects (patches, nodes, etc) to RDF. * * \ingroup IngenClient @@ -59,28 +49,36 @@ class ModelEngineInterface; class Serializer { public: - Serializer(); + Serializer(Raul::RDF::World& world); + + void start_to_filename(const string& filename); + void start_to_string(); - void start_to_filename(const string& filename) throw (std::logic_error); - void start_to_string() throw (std::logic_error); void serialize(SharedPtr<ObjectModel> object) throw (std::logic_error); void serialize_connection(SharedPtr<ConnectionModel> c) throw (std::logic_error); - string finish() throw (std::logic_error); + + string finish(); private: + enum Mode { TO_FILE, TO_STRING }; + + void setup_prefixes(); void serialize_plugin(SharedPtr<PluginModel> p); - void serialize_patch(SharedPtr<PatchModel> p, const Raul::RdfId& id); - void serialize_node(SharedPtr<NodeModel> n, const Raul::RdfId& id); - void serialize_port(SharedPtr<PortModel> p, const Raul::RdfId& id); + void serialize_patch(SharedPtr<PatchModel> p, const Raul::RDF::Node& id); + void serialize_node(SharedPtr<NodeModel> n, const Raul::RDF::Node& id); + void serialize_port(SharedPtr<PortModel> p, const Raul::RDF::Node& id); - Raul::RdfId path_to_node_id(const Path& path); - - typedef std::map<Path, RdfId> IDMap; - IDMap _id_map; - string _base_uri; - Raul::RDFWriter _writer; + Raul::RDF::Node path_to_node_id(const Path& path); + + typedef std::map<Path, Raul::RDF::Node> NodeMap; + Mode _mode; + std::string _filename; + NodeMap _node_map; + string _base_uri; + Raul::RDF::World& _world; + Raul::RDF::Model* _model; }; diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index ff32fc04..713423cc 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -125,8 +125,8 @@ LADSPANode::instantiate() } if (port->is_input() && port->buffer_size() == 1) { - port->set_metadata("min", min); - port->set_metadata("max", max); + port->set_metadata("ingen:minimum", min); + port->set_metadata("ingen:maximum", max); } } diff --git a/src/progs/ingenuity/App.cpp b/src/progs/ingenuity/App.cpp index 4bd12efa..e1e4912d 100644 --- a/src/progs/ingenuity/App.cpp +++ b/src/progs/ingenuity/App.cpp @@ -71,8 +71,19 @@ App::App() glade_xml->get_widget_derived("config_win", _config_window); glade_xml->get_widget("about_win", _about_dialog); + _rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#"); + _rdf_world.add_prefix("ingen", "http://drobilla.net/ns/ingen#"); + _rdf_world.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#"); + _rdf_world.add_prefix("lv2", "http://lv2plug.in/ontology#"); + _rdf_world.add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); + _rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#"); _config_window->configuration(_configuration); + +#ifdef HAVE_SLV2 + SLV2World slv2_world = slv2_world_new_using_rdf_world(_rdf_world.world()); + PluginModel::set_slv2_world(slv2_world); +#endif } @@ -80,6 +91,7 @@ App::~App() { } + void App::instantiate() { diff --git a/src/progs/ingenuity/App.h b/src/progs/ingenuity/App.h index 62968864..aaf33893 100644 --- a/src/progs/ingenuity/App.h +++ b/src/progs/ingenuity/App.h @@ -26,6 +26,7 @@ #include <libgnomecanvasmm.h> #include <gtkmm.h> #include <libglademm.h> +#include <raul/RDFWorld.h> #include <raul/SharedPtr.h> using std::string; using std::map; using std::list; using std::cerr; using std::endl; @@ -85,6 +86,8 @@ public: PatchTreeWindow* patch_tree() const { return _patch_tree_window; } Configuration* configuration() const { return _configuration; } WindowFactory* window_factory() const { return _window_factory; } + + Raul::RDF::World* rdf_world() { return &_rdf_world; } const SharedPtr<ModelEngineInterface>& engine() const { return _engine; } const SharedPtr<SigClientInterface>& client() const { return _client; } @@ -112,6 +115,8 @@ protected: Gtk::Dialog* _about_dialog; WindowFactory* _window_factory; + Raul::RDF::World _rdf_world; + /** Used to avoid feedback loops with (eg) process checkbutton * FIXME: Maybe this should be globally implemented at the Controller level, * disable all command sending while handling events to avoid feedback diff --git a/src/progs/ingenuity/ControlGroups.cpp b/src/progs/ingenuity/ControlGroups.cpp index 4958f5be..f775709a 100644 --- a/src/progs/ingenuity/ControlGroups.cpp +++ b/src/progs/ingenuity/ControlGroups.cpp @@ -108,8 +108,8 @@ SliderControlGroup::init(ControlPanel* panel, SharedPtr<PortModel> pm) float min = 0.0f; float max = 1.0f; - const Atom& min_atom = pm->get_metadata("min"); - const Atom& max_atom = pm->get_metadata("max"); + const Atom& min_atom = pm->get_metadata("ingen:minimum"); + const Atom& max_atom = pm->get_metadata("ingen:maximum"); if (min_atom.type() == Atom::FLOAT && max_atom.type() == Atom::FLOAT) { min = min_atom.get_float(); max = max_atom.get_float(); diff --git a/src/progs/ingenuity/LoadPluginWindow.cpp b/src/progs/ingenuity/LoadPluginWindow.cpp index 3607ba23..d0311446 100644 --- a/src/progs/ingenuity/LoadPluginWindow.cpp +++ b/src/progs/ingenuity/LoadPluginWindow.cpp @@ -191,6 +191,14 @@ LoadPluginWindow::plugin_compare(const Gtk::TreeModel::iterator& a_i, SharedPtr<PluginModel> a = a_i->get_value(_plugins_columns._col_plugin_model); SharedPtr<PluginModel> b = b_i->get_value(_plugins_columns._col_plugin_model); + // FIXME: haaack + if (!a && !b) + return 0; + else if (!a) + return 1; + else if (!b) + return -1; + if (a->type() == b->type()) return strcmp(a->name().c_str(), b->name().c_str()); else diff --git a/src/progs/ingenuity/LoadRemotePatchWindow.cpp b/src/progs/ingenuity/LoadRemotePatchWindow.cpp index ec49f70f..12006f3f 100644 --- a/src/progs/ingenuity/LoadRemotePatchWindow.cpp +++ b/src/progs/ingenuity/LoadRemotePatchWindow.cpp @@ -63,24 +63,22 @@ LoadRemotePatchWindow::present(SharedPtr<PatchModel> patch, MetadataMap data) set_patch(patch); _initial_data = data; + + RDF::Model model(*App::instance().rdf_world(), + "http://rdf.drobilla.net/ingen_patches/index.ttl"); - Namespaces namespaces; - namespaces["ingen"] = "http://drobilla.net/ns/ingen#"; - namespaces["rdfs"] = "http://www.w3.org/2000/01/rdf-schema#"; - namespaces["doap"] = "http://usefulinc.com/ns/doap#"; - - RDFQuery query(namespaces, Glib::ustring( + RDF::Query query(*App::instance().rdf_world(), Glib::ustring( "SELECT DISTINCT ?name ?uri FROM <> WHERE {" " ?uri a ingen:Patch ;" " doap:name ?name ." "}")); - RDFQuery::Results results = query.run("http://rdf.drobilla.net/ingen_patches/index.ttl"); + RDF::Query::Results results = query.run(*App::instance().rdf_world(), model); - for (RDFQuery::Results::iterator i = results.begin(); i != results.end(); ++i) { + for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { Gtk::TreeModel::iterator iter = _liststore->append(); - (*iter)[_columns._col_name] = (*i)["name"]; - (*iter)[_columns._col_uri] = (*i)["uri"]; + (*iter)[_columns._col_name] = (*i)["name"].to_string(); + (*iter)[_columns._col_uri] = (*i)["uri"].to_string(); } _treeview->columns_autosize(); diff --git a/src/progs/ingenuity/LoadSubpatchWindow.cpp b/src/progs/ingenuity/LoadSubpatchWindow.cpp index 22beb70f..37648ca8 100644 --- a/src/progs/ingenuity/LoadSubpatchWindow.cpp +++ b/src/progs/ingenuity/LoadSubpatchWindow.cpp @@ -156,7 +156,7 @@ LoadSubpatchWindow::ok_clicked() else if (_poly_from_parent_radio->get_active()) poly = _patch->poly(); - App::instance().loader()->load_patch(false, get_filename(), "/", + App::instance().loader()->load_patch(false, get_uri(), "/", _initial_data, _patch->path(), name, poly); hide(); diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp index af99d4d1..38fd0d87 100644 --- a/src/progs/ingenuity/PatchCanvas.cpp +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -405,7 +405,7 @@ PatchCanvas::destroy_selection() void PatchCanvas::copy_selection() { - Serializer serializer; + Serializer serializer(*App::instance().rdf_world()); serializer.start_to_string(); for (list<boost::shared_ptr<Item> >::iterator m = _selected_items.begin(); m != _selected_items.end(); ++m) { diff --git a/src/progs/ingenuity/PortPropertiesWindow.cpp b/src/progs/ingenuity/PortPropertiesWindow.cpp index b7a78ebc..3a490a74 100644 --- a/src/progs/ingenuity/PortPropertiesWindow.cpp +++ b/src/progs/ingenuity/PortPropertiesWindow.cpp @@ -66,8 +66,8 @@ PortPropertiesWindow::init(ControlGroup* control, SharedPtr<PortModel> pm) float min = 0.0f; float max = 1.0f; - const Atom& min_atom = pm->get_metadata("min"); - const Atom& max_atom = pm->get_metadata("max"); + const Atom& min_atom = pm->get_metadata("ingen:minimum"); + const Atom& max_atom = pm->get_metadata("ingen_maximum"); if (min_atom.type() == Atom::FLOAT && max_atom.type() == Atom::FLOAT) { min = min_atom.get_float(); max = max_atom.get_float(); @@ -108,9 +108,9 @@ PortPropertiesWindow::metadata_update(const string& key, const Atom& value) { _enable_signal = false; - if ( (key == "min") && value.type() == Atom::FLOAT) + if ( (key == "ingen:minimum") && value.type() == Atom::FLOAT) _min_spinner->set_value(value.get_float()); - else if ( (key == "max") && value.type() == Atom::FLOAT) + else if ( (key == "ingen:maximum") && value.type() == Atom::FLOAT) _max_spinner->set_value(value.get_float()); _enable_signal = true; @@ -131,7 +131,7 @@ PortPropertiesWindow::min_changed() _control->set_range(min, max); if (_enable_signal) - App::instance().engine()->set_metadata(_port_model->path(), "min", min); + App::instance().engine()->set_metadata(_port_model->path(), "ingen:minimum", min); } @@ -149,15 +149,15 @@ PortPropertiesWindow::max_changed() _control->set_range(min, max); if (_enable_signal) - App::instance().engine()->set_metadata(_port_model->path(), "max", max); + App::instance().engine()->set_metadata(_port_model->path(), "ingen:maximum", max); } void PortPropertiesWindow::cancel() { - App::instance().engine()->set_metadata(_port_model->path(), "min", _initial_min); - App::instance().engine()->set_metadata(_port_model->path(), "max", _initial_max); + App::instance().engine()->set_metadata(_port_model->path(), "ingen:minimum", _initial_min); + App::instance().engine()->set_metadata(_port_model->path(), "ingen:maximum", _initial_max); delete this; } diff --git a/src/progs/ingenuity/ThreadedLoader.cpp b/src/progs/ingenuity/ThreadedLoader.cpp index 0ba2bb33..118d252f 100644 --- a/src/progs/ingenuity/ThreadedLoader.cpp +++ b/src/progs/ingenuity/ThreadedLoader.cpp @@ -20,6 +20,7 @@ #include <cassert> #include <string> #include "PatchModel.h" +#include "App.h" using std::cout; using std::endl; namespace Ingenuity { @@ -27,7 +28,8 @@ namespace Ingenuity { ThreadedLoader::ThreadedLoader(SharedPtr<ModelEngineInterface> engine) : _deprecated_loader(engine) - , _loader(engine) + , _loader(engine, App::instance().rdf_world()) + , _serializer(*App::instance().rdf_world()) { // FIXME: rework this so the thread is only present when it's doing something (save mem) start(); @@ -77,6 +79,7 @@ ThreadedLoader::load_patch(bool merge, } else { _events.push_back(sigc::hide_return(sigc::bind( sigc::mem_fun(_loader, &Loader::load), + App::instance().rdf_world(), data_base_uri, engine_parent, (engine_name) ? engine_name.get() : "", diff --git a/src/progs/ingenuity/UploadPatchWindow.cpp b/src/progs/ingenuity/UploadPatchWindow.cpp index 3eccd600..6c68236d 100644 --- a/src/progs/ingenuity/UploadPatchWindow.cpp +++ b/src/progs/ingenuity/UploadPatchWindow.cpp @@ -246,7 +246,7 @@ UploadPatchWindow::upload_clicked() _upload_progress->set_fraction(0.0); _upload_progress->set_text(""); - Serializer s; + Serializer s(*App::instance().rdf_world()); s.start_to_string(); s.serialize(_patch); const string str = s.finish(); diff --git a/src/progs/ingenuity/main.cpp b/src/progs/ingenuity/main.cpp index 4e5789c8..8170833f 100644 --- a/src/progs/ingenuity/main.cpp +++ b/src/progs/ingenuity/main.cpp @@ -45,6 +45,7 @@ main(int argc, char** argv) Gnome::Canvas::init(); Gtk::Main gtk_main(argc, argv); + Gtk::Window::set_default_icon_from_file(PKGDATADIR "/ingen-icon.svg"); /* Instantiate all singletons */ App::instantiate(); diff --git a/src/progs/patch_loader/patch_loader.cpp b/src/progs/patch_loader/patch_loader.cpp index d25ac24f..f011d308 100644 --- a/src/progs/patch_loader/patch_loader.cpp +++ b/src/progs/patch_loader/patch_loader.cpp @@ -15,12 +15,13 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <iostream> +#include <unistd.h> +#include <raul/Path.h> +#include <raul/RDFWorld.h> #include "OSCModelEngineInterface.h" #include "Loader.h" #include "PatchModel.h" -#include "raul/Path.h" -#include <iostream> -#include <unistd.h> #include "cmdline.h" // generated by gengetopt using std::cout; using std::endl; @@ -51,9 +52,16 @@ int main(int argc, char** argv) /* **** Mr. Spock.. Engage **** */ + Raul::RDF::World rdf_world; + rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#"); + rdf_world.add_prefix("ingen", "http://drobilla.net/ns/ingen#"); + rdf_world.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#"); + rdf_world.add_prefix("lv2", "http://lv2plug.in/ontology#"); + rdf_world.add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); + rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#"); SharedPtr<OSCModelEngineInterface> engine(new OSCModelEngineInterface(engine_url)); - Loader loader(engine); + Loader loader(engine, &rdf_world); /* Connect to engine */ engine->attach(-1, client_port); @@ -73,7 +81,7 @@ int main(int argc, char** argv) for (uint i=0; i < args_info.inputs_num; ++i) { cerr << "FIXME: load patch under root" << endl; cerr << "Load " << args_info.inputs[i] << endl; - loader.load(args_info.inputs[i], Path("/"), ""); + loader.load(&rdf_world, string("file:") + args_info.inputs[i], Path("/"), ""); } return 0; |