diff options
author | David Robillard <d@drobilla.net> | 2011-02-16 18:26:57 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-02-16 18:26:57 +0000 |
commit | 2c1079446f0b06559a683a9f4b0192a4f7637770 (patch) | |
tree | 0bb095529e4654cdf4633512fdaaa599ed3370f0 | |
parent | 0cb698a6d4652c54d49f599f1611e7c4a15d3778 (diff) | |
download | ingen-2c1079446f0b06559a683a9f4b0192a4f7637770.tar.gz ingen-2c1079446f0b06559a683a9f4b0192a4f7637770.tar.bz2 ingen-2c1079446f0b06559a683a9f4b0192a4f7637770.zip |
Drop redlandmm for sordmm.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2959 a436a847-0d15-0410-975c-d299462d15a1
30 files changed, 261 insertions, 278 deletions
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp index 4ccf8a8a..bd16fe73 100644 --- a/src/client/HTTPClientReceiver.cpp +++ b/src/client/HTTPClientReceiver.cpp @@ -231,8 +231,6 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi void HTTPClientReceiver::start(bool dump) { - Glib::Mutex::Lock lock(_world->rdf_world()->mutex()); - if (!_world->parser()) _world->load("ingen_serialisation"); diff --git a/src/client/HTTPClientReceiver.hpp b/src/client/HTTPClientReceiver.hpp index 094eee65..5e09d2e4 100644 --- a/src/client/HTTPClientReceiver.hpp +++ b/src/client/HTTPClientReceiver.hpp @@ -21,7 +21,7 @@ #include <cstdlib> #include <boost/utility.hpp> #include <glibmm/thread.h> -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "raul/Deletable.hpp" #include "raul/SharedPtr.hpp" #include "raul/Thread.hpp" diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp index cc0d31a0..ed69d7e0 100644 --- a/src/client/HTTPEngineSender.cpp +++ b/src/client/HTTPEngineSender.cpp @@ -19,7 +19,7 @@ #include "raul/AtomRDF.hpp" #include "raul/log.hpp" -#include "redlandmm/Model.hpp" +#include "sord/sordmm.hpp" #include "module/World.hpp" #include "HTTPEngineSender.hpp" @@ -121,14 +121,14 @@ HTTPEngineSender::put(const URI& uri, const string path = (uri.substr(0, 6) == "path:/") ? uri.substr(6) : uri.str(); const string full_uri = _engine_url.str() + "/" + path; - Redland::Model model(_world); + Sord::Model model(_world); for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i) model.add_statement( - Redland::Resource(_world, path), + Sord::Resource(_world, path), AtomRDF::atom_to_node(model, i->first), AtomRDF::atom_to_node(model, i->second)); - const string str = model.serialise_to_string("turtle"); + const string str = model.write_to_string("turtle"); SoupMessage* msg = soup_message_new(SOUP_METHOD_PUT, full_uri.c_str()); assert(msg); soup_message_set_request(msg, "application/x-turtle", SOUP_MEMORY_COPY, str.c_str(), str.length()); diff --git a/src/client/HTTPEngineSender.hpp b/src/client/HTTPEngineSender.hpp index bd8d3e23..12ba98b5 100644 --- a/src/client/HTTPEngineSender.hpp +++ b/src/client/HTTPEngineSender.hpp @@ -23,7 +23,7 @@ #include <string> #include "raul/Path.hpp" -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "interface/EngineInterface.hpp" @@ -116,7 +116,7 @@ public: protected: SoupSession* _session; - Redland::World& _world; + Sord::World& _world; const Raul::URI _engine_url; int _client_port; int32_t _id; diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index 783f2425..8d8a5ece 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -185,9 +185,6 @@ NodeModel::default_port_value_range(SharedPtr<PortModel> port, float& min, float if (_plugin && _plugin->type() == PluginModel::LV2) { if (!_min_values) { - - Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); - _num_values = slv2_plugin_get_num_ports(_plugin->slv2_plugin()); _min_values = new float[_num_values]; _max_values = new float[_num_values]; diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 08e9dad6..5d35902b 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -37,7 +37,7 @@ SLV2World PluginModel::_slv2_world = NULL; SLV2Plugins PluginModel::_slv2_plugins = NULL; #endif -Redland::World* PluginModel::_rdf_world = NULL; +Sord::World* PluginModel::_rdf_world = NULL; PluginModel::PluginModel(Shared::LV2URIMap& uris, @@ -47,7 +47,6 @@ PluginModel::PluginModel(Shared::LV2URIMap& uris, { add_properties(properties); - Glib::Mutex::Lock lock(_rdf_world->mutex()); assert(_rdf_world); add_property("http://www.w3.org/1999/02/22-rdf-syntax-ns#type", this->type_uri()); #ifdef HAVE_SLV2 @@ -177,7 +176,6 @@ PluginModel::port_human_name(uint32_t index) const { #ifdef HAVE_SLV2 if (_slv2_plugin) { - Glib::Mutex::Lock lock(_rdf_world->mutex()); SLV2Port port = slv2_plugin_get_port_by_index(_slv2_plugin, index); SLV2Value name = slv2_port_get_name(_slv2_plugin, port); string ret = slv2_value_as_string(name); @@ -193,8 +191,6 @@ PluginModel::port_human_name(uint32_t index) const bool PluginModel::has_ui() const { - Glib::Mutex::Lock lock(_rdf_world->mutex()); - SLV2Value gtk_gui_uri = slv2_value_new_uri(_slv2_world, "http://lv2plug.in/ns/extensions/ui#GtkUI"); @@ -224,7 +220,6 @@ const string& PluginModel::icon_path() const { if (_icon_path.empty() && _type == LV2) { - Glib::Mutex::Lock lock(_rdf_world->mutex()); _icon_path = get_lv2_icon_path(_slv2_plugin); } diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index c3a27713..3f647a7c 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -18,9 +18,11 @@ #ifndef INGEN_CLIENT_PLUGINMODEL_HPP #define INGEN_CLIENT_PLUGINMODEL_HPP +#include <sigc++/sigc++.h> + #include "ingen-config.h" #include "raul/SharedPtr.hpp" -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #ifdef HAVE_SLV2 #include "slv2/slv2.h" #endif @@ -67,12 +69,10 @@ public: SLV2Plugin slv2_plugin() const { return _slv2_plugin; } SLV2Port slv2_port(uint32_t index) { - Glib::Mutex::Lock lock(_rdf_world->mutex()); return slv2_plugin_get_port_by_index(_slv2_plugin, index); } static void set_slv2_world(SLV2World world) { - Glib::Mutex::Lock lock(_rdf_world->mutex()); _slv2_world = world; _slv2_plugins = slv2_world_get_all_plugins(_slv2_world); } @@ -86,11 +86,11 @@ public: static std::string get_lv2_icon_path(SLV2Plugin plugin); #endif - static void set_rdf_world(Redland::World& world) { + static void set_rdf_world(Sord::World& world) { _rdf_world = &world; } - static Redland::World* rdf_world() { return _rdf_world; } + static Sord::World* rdf_world() { return _rdf_world; } // Signals sigc::signal<void> signal_changed; @@ -111,7 +111,7 @@ private: mutable std::string _icon_path; #endif - static Redland::World* _rdf_world; + static Sord::World* _rdf_world; }; diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 693976fb..5d21ea7e 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -118,7 +118,6 @@ PluginUI::PluginUI(Ingen::Shared::World* world, PluginUI::~PluginUI() { if (_instance) { - Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); slv2_ui_instance_free(_instance); } } @@ -129,7 +128,6 @@ PluginUI::create(Ingen::Shared::World* world, SharedPtr<NodeModel> node, SLV2Plugin plugin) { - Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); SharedPtr<PluginUI> ret; SLV2Value gtk_gui_uri = slv2_value_new_uri(world->slv2_world(), diff --git a/src/client/wscript b/src/client/wscript index de135888..2ab0be44 100644 --- a/src/client/wscript +++ b/src/client/wscript @@ -36,5 +36,5 @@ def build(bld): obj.target = 'ingen_client' obj.install_path = '${LIBDIR}' obj.use = 'libingen_shared' - autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL REDLANDMM SOUP XML2 SIGCPP LIBLO SOUP') + autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL SORD SOUP XML2 SIGCPP LIBLO SOUP') diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index 79f64cc1..7068911c 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -59,14 +59,14 @@ HTTPClientSender::put(const URI& uri, const string path = (uri.substr(0, 6) == "path:/") ? uri.substr(6) : uri.str(); const string full_uri = _url + "/" + path; - Redland::Model model(*_engine.world()->rdf_world()); + Sord::Model model(*_engine.world()->rdf_world()); for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i) model.add_statement( - Redland::Resource(*_engine.world()->rdf_world(), path), + Sord::Resource(*_engine.world()->rdf_world(), path), AtomRDF::atom_to_node(model, i->first.str()), AtomRDF::atom_to_node(model, i->second)); - const string str = model.serialise_to_string("turtle"); + const string str = model.write_to_string("turtle"); send_chunk(str); } @@ -111,7 +111,7 @@ void HTTPClientSender::set_property(const URI& subject, const URI& key, const Atom& value) { #if 0 - Redland::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world(), value); + Sord::Node node = AtomRDF::atom_to_node(*_engine.world()->rdf_world(), value); const string msg = string( "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n" "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n" diff --git a/src/engine/LV2Plugin.cpp b/src/engine/LV2Plugin.cpp index 80d2b443..faa10e97 100644 --- a/src/engine/LV2Plugin.cpp +++ b/src/engine/LV2Plugin.cpp @@ -19,7 +19,7 @@ #include <string> #include <glibmm.h> -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "shared/LV2URIMap.hpp" #include "Driver.hpp" @@ -75,7 +75,6 @@ LV2Plugin::instantiate(BufferFactory& bufs, load(); // FIXME: unload at some point - Glib::Mutex::Lock lock(engine.world()->rdf_world()->mutex()); LV2Node* n = new LV2Node(this, name, polyphonic, parent, srate); if ( ! n->instantiate(bufs) ) { diff --git a/src/engine/NodeFactory.cpp b/src/engine/NodeFactory.cpp index 64b6e2b6..08584c81 100644 --- a/src/engine/NodeFactory.cpp +++ b/src/engine/NodeFactory.cpp @@ -22,7 +22,7 @@ #include <float.h> #include <cmath> #include <glibmm/miscutils.h> -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "raul/log.hpp" #include "ingen-config.h" #include "module/World.hpp" @@ -81,8 +81,6 @@ NodeFactory::load_plugins() { ThreadManager::assert_thread(THREAD_PRE_PROCESS); - _world->rdf_world()->mutex().lock(); - // Only load if we havn't already, so every client connecting doesn't cause // this (expensive!) stuff to happen. Not the best solution - would be nice // if clients could refresh plugins list for whatever reason :/ @@ -97,8 +95,6 @@ NodeFactory::load_plugins() _has_loaded = true; } - - _world->rdf_world()->mutex().unlock(); } diff --git a/src/engine/events/CreateNode.cpp b/src/engine/events/CreateNode.cpp index 9fef8070..e5f8d721 100644 --- a/src/engine/events/CreateNode.cpp +++ b/src/engine/events/CreateNode.cpp @@ -18,7 +18,7 @@ #include "raul/log.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "shared/LV2URIMap.hpp" #include "CreateNode.hpp" #include "Request.hpp" diff --git a/src/engine/wscript b/src/engine/wscript index 42e31d2c..0cbd060c 100644 --- a/src/engine/wscript +++ b/src/engine/wscript @@ -70,7 +70,7 @@ def build(bld): obj.target = 'ingen_engine' obj.install_path = '${LIBDIR}' obj.use = 'libingen_shared' - core_libs = 'GLIBMM GTHREAD LV2CORE SLV2 RAUL REDLANDMM' + core_libs = 'GLIBMM GTHREAD LV2CORE SLV2 RAUL SORD' autowaf.use_lib(bld, obj, core_libs) if bld.env['HAVE_SOUP'] == 1: diff --git a/src/gui/LoadRemotePatchWindow.cpp b/src/gui/LoadRemotePatchWindow.cpp index d03de05c..0ad4d5b5 100644 --- a/src/gui/LoadRemotePatchWindow.cpp +++ b/src/gui/LoadRemotePatchWindow.cpp @@ -67,17 +67,17 @@ LoadRemotePatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Propert cerr << "FIXME: load remote patch" << endl; #if 0 - Redland::Model model(*App::instance().world()->rdf_world(), + Sord::Model model(*App::instance().world()->rdf_world(), "http://rdf.drobilla.net/ingen_patches/index.ttl", "http://rdf.drobilla.net/ingen_patches/"); - Redland::Query query(*App::instance().world()->rdf_world(), Glib::ustring( + Sord::Query query(*App::instance().world()->rdf_world(), Glib::ustring( "SELECT DISTINCT ?name ?uri WHERE {" " ?uri a ingen:Patch ;" " doap:name ?name ." "}")); - SharedPtr<Redland::QueryResults> results(query.run(*App::instance().world()->rdf_world(), model)); + SharedPtr<Sord::QueryResults> results(query.run(*App::instance().world()->rdf_world(), model)); for (; !results->finished(); results->next()) { Gtk::TreeModel::iterator iter = _liststore->append(); (*iter)[_columns._col_name] = results->get("name").to_string(); diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 91f8cb50..44748aeb 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -120,7 +120,6 @@ NodeModule::show_human_names(bool b) const LV2URIMap& uris = App::instance().uris(); if (b && node()->plugin()) { - Glib::Mutex::Lock lock(App::instance().world()->rdf_world()->mutex()); const Raul::Atom& name_property = node()->get_property(uris.lv2_name); if (name_property.type() == Atom::STRING) set_name(name_property.get_string()); diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index ca63df6f..0e1c6fbc 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -245,12 +245,11 @@ PatchCanvas::build_plugin_menu() _menu->reorder_child(*plugin_menu_item, 5); } - Glib::Mutex::Lock lock(PluginModel::rdf_world()->mutex()); - SLV2PluginClass lv2_plugin = slv2_world_get_plugin_class(PluginModel::slv2_world()); - SLV2PluginClasses classes = slv2_world_get_plugin_classes(PluginModel::slv2_world()); + SLV2PluginClass lv2_plugin = slv2_world_get_plugin_class(PluginModel::slv2_world()); + SLV2PluginClasses classes = slv2_world_get_plugin_classes(PluginModel::slv2_world()); LV2Children children; - for (unsigned i=0; i < slv2_plugin_classes_size(classes); ++i) { + for (unsigned i = 0; i < slv2_plugin_classes_size(classes); ++i) { SLV2PluginClass c = slv2_plugin_classes_get_at(classes, i); SLV2Value p = slv2_plugin_class_get_parent_uri(c); if (!p) diff --git a/src/gui/wscript b/src/gui/wscript index 40c6a270..54919362 100644 --- a/src/gui/wscript +++ b/src/gui/wscript @@ -58,7 +58,7 @@ def build(bld): GNOMECANVASMM GTKMM RAUL - REDLANDMM + SORD SIGCPP LV2CORE SLV2 diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp index da52e1c2..4958de3b 100644 --- a/src/ingen/main.cpp +++ b/src/ingen/main.cpp @@ -28,7 +28,7 @@ #include "raul/Configuration.hpp" #include "raul/Path.hpp" #include "raul/SharedPtr.hpp" -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "interface/EngineInterface.hpp" #include "shared/Configuration.hpp" #include "shared/runtime_paths.hpp" diff --git a/src/ingen/wscript b/src/ingen/wscript index df7627ab..08d793eb 100644 --- a/src/ingen/wscript +++ b/src/ingen/wscript @@ -9,6 +9,6 @@ def build(bld): obj.defines = 'VERSION="' + bld.env['INGEN_VERSION'] + '"' obj.use = 'libingen_module libingen_shared' obj.install_path = '${BINDIR}' - autowaf.use_lib(bld, obj, 'GTHREAD GLIBMM REDLANDMM RAUL LV2CORE SLV2 INGEN LIBLO SOUP') + autowaf.use_lib(bld, obj, 'GTHREAD GLIBMM SORD RAUL LV2CORE SLV2 INGEN LIBLO SOUP') bld.install_files('${DATADIR}/applications', 'ingen.desktop') diff --git a/src/module/World.cpp b/src/module/World.cpp index 69c67f96..67bd7aaf 100644 --- a/src/module/World.cpp +++ b/src/module/World.cpp @@ -24,7 +24,7 @@ #include "slv2/slv2.h" #endif #include "raul/log.hpp" -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "shared/runtime_paths.hpp" #include "shared/LV2Features.hpp" #include "shared/LV2URIMap.hpp" @@ -100,7 +100,7 @@ struct WorldImpl : public boost::noncopyable { , argv(a_argv) , conf(conf) , lv2_features(NULL) - , rdf_world(new Redland::World()) + , rdf_world(new Sord::World()) , uris(new Shared::LV2URIMap()) #ifdef HAVE_SLV2 , slv2_world(slv2_world_new()) @@ -166,7 +166,7 @@ struct WorldImpl : public boost::noncopyable { char**& argv; Raul::Configuration* conf; LV2Features* lv2_features; - Redland::World* rdf_world; + Sord::World* rdf_world; SharedPtr<LV2URIMap> uris; SharedPtr<EngineInterface> engine; SharedPtr<Engine> local_engine; @@ -211,7 +211,7 @@ LV2Features* World::lv2_features() { return _impl->lv2_f #ifdef HAVE_SLV2 SLV2World World::slv2_world() { return _impl->slv2_world; } #endif -Redland::World* World::rdf_world() { return _impl->rdf_world; } +Sord::World* World::rdf_world() { return _impl->rdf_world; } SharedPtr<LV2URIMap> World::uris() { return _impl->uris; } diff --git a/src/module/World.hpp b/src/module/World.hpp index 1505d04c..1345f3da 100644 --- a/src/module/World.hpp +++ b/src/module/World.hpp @@ -33,7 +33,7 @@ typedef struct _SLV2World* SLV2World; #endif -namespace Redland { class World; } +namespace Sord { class World; } namespace Ingen { @@ -53,7 +53,7 @@ struct WorldImpl; /** The "world" all Ingen modules may share. * * All loaded components of Ingen, as well as things requiring shared access - * and/or locking (e.g. Redland, SLV2). + * and/or locking (e.g. Sord, SLV2). * * Ingen modules are shared libraries which modify the World when loaded * using World::load, e.g. loading the "ingen_serialisation" module will @@ -92,7 +92,7 @@ public: virtual SharedPtr<Serialisation::Parser> parser(); virtual SharedPtr<Store> store(); - virtual Redland::World* rdf_world(); + virtual Sord::World* rdf_world(); virtual SharedPtr<LV2URIMap> uris(); virtual int& argc(); diff --git a/src/module/wscript b/src/module/wscript index 85446284..41cc752b 100644 --- a/src/module/wscript +++ b/src/module/wscript @@ -17,5 +17,5 @@ def build(bld): obj.vnum = '0.0.0' obj.use = 'libingen_shared' obj.install_path = '${LIBDIR}' - autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL REDLANDMM') + autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL SORD') diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index df97fb78..f1ba2ed2 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -22,8 +22,7 @@ #include <glibmm/fileutils.h> #include <glibmm/convert.h> #include "raul/log.hpp" -#include "redlandmm/Model.hpp" -#include "redlandmm/Node.hpp" +#include "sord/sordmm.hpp" #include "raul/TableImpl.hpp" #include "raul/Atom.hpp" #include "raul/AtomRDF.hpp" @@ -33,6 +32,9 @@ #include "Parser.hpp" #include "names.hpp" +#include "serd/serd.h" +#include "sord/sordmm.hpp" + #define LOG(s) s << "[Parser] " #define NS_INGEN "http://drobilla.net/ns/ingen#" @@ -44,9 +46,9 @@ using namespace std; using namespace Raul; using namespace Ingen::Shared; -static const Redland::Node nil; +static const Sord::Node nil; -typedef set<Redland::Node> RDFNodes; +typedef set<Sord::Node> RDFNodes; namespace Ingen { namespace Serialisation { @@ -55,16 +57,26 @@ namespace Serialisation { static Glib::ustring relative_uri(Glib::ustring base, const Glib::ustring uri, bool leading_slash) { - raptor_uri* base_uri = raptor_new_uri((const unsigned char*)base.c_str()); - raptor_uri* full_uri = raptor_new_uri((const unsigned char*)uri.c_str()); + if (uri == base) { + return leading_slash ? "/" : ""; + } + + SerdURI base_uri; + serd_uri_parse((const uint8_t*)base.c_str(), &base_uri); - Glib::ustring ret((const char*)raptor_uri_to_relative_uri_string(base_uri, full_uri)); + SerdURI normal_base_uri; + SerdNode normal_base_uri_node = serd_node_new_uri_from_string( + (const uint8_t*)".", &base_uri, &normal_base_uri); - raptor_free_uri(base_uri); - raptor_free_uri(full_uri); + Glib::ustring normal_base_str((const char*)normal_base_uri_node.buf); - if (leading_slash && ret[0] != '/') - ret = Glib::ustring("/") + ret; + Glib::ustring ret = uri; + if (uri.length() >= normal_base_str.length() + && uri.substr(0, normal_base_str.length()) == normal_base_str) { + ret = uri.substr(normal_base_str.length()); + if (leading_slash && ret[0] != '/') + ret = Glib::ustring("/") + ret; + } return ret; } @@ -84,22 +96,21 @@ Parser::find_patches( Ingen::Shared::World* world, const Glib::ustring& manifest_uri) { - //Redland::Model model(*world->rdf_world(), manifest_uri, manifest_uri); - Redland::Model model(*world->rdf_world(), manifest_uri); + Sord::Model model(*world->rdf_world(), manifest_uri); model.load_file(manifest_uri); - Redland::Resource rdf_type(*world->rdf_world(), NS_RDF "type"); - Redland::Resource rdfs_seeAlso(*world->rdf_world(), NS_RDFS "seeAlso"); - Redland::Resource ingen_Patch(*world->rdf_world(), NS_INGEN "Patch"); + Sord::Resource rdf_type(*world->rdf_world(), NS_RDF "type"); + Sord::Resource rdfs_seeAlso(*world->rdf_world(), NS_RDFS "seeAlso"); + Sord::Resource ingen_Patch(*world->rdf_world(), NS_INGEN "Patch"); RDFNodes patches; - for (Redland::Iter i = model.find(nil, rdf_type, ingen_Patch); !i.end(); ++i) { + for (Sord::Iter i = model.find(nil, rdf_type, ingen_Patch); !i.end(); ++i) { patches.insert(i.get_subject()); } std::list<PatchRecord> records; for (RDFNodes::const_iterator i = patches.begin(); i != patches.end(); ++i) { - Redland::Iter f = model.find(*i, rdfs_seeAlso, nil); + Sord::Iter f = model.find(*i, rdfs_seeAlso, nil); if (f.end()) { LOG(error) << "Patch has no rdfs:seeAlso" << endl; continue; @@ -127,7 +138,11 @@ Parser::parse_document( { normalise_uri(document_uri); - assert(document_uri[document_uri.length() - 1] == '/'); + if (document_uri.substr(document_uri.length() - 4) != ".ttl") { + if (document_uri[document_uri.length() - 1] != '/') { + document_uri.append("/"); + } + } const std::string filename(Glib::filename_from_uri(document_uri)); const size_t ext = filename.find(INGEN_BUNDLE_EXT); @@ -139,7 +154,7 @@ Parser::parse_document( document_uri += basename + INGEN_PATCH_FILE_EXT; } - Redland::Model model(*world->rdf_world(), document_uri); + Sord::Model model(*world->rdf_world(), document_uri); model.load_file(document_uri); LOG(info) << "Parsing " << document_uri << endl; @@ -175,7 +190,7 @@ Parser::parse_string( boost::optional<Raul::Symbol> symbol, boost::optional<GraphObject::Properties> data) { - Redland::Model model(*world->rdf_world(), base_uri); + Sord::Model model(*world->rdf_world(), base_uri); model.load_string(str.c_str(), str.length(), base_uri); LOG(info) << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; @@ -184,7 +199,7 @@ Parser::parse_string( info << endl; bool ret = parse(world, target, model, base_uri, data_path, parent, symbol, data); - Redland::Resource subject(*world->rdf_world(), base_uri); + Sord::Resource subject(*world->rdf_world(), base_uri); parse_connections(world, target, model, subject, parent ? *parent : "/"); return ret; @@ -203,20 +218,20 @@ Parser::parse_update( boost::optional<GraphObject::Properties> data) { #if 0 - Redland::Model model(*world->rdf_world(), str.c_str(), str.length(), base_uri); + Sord::Model model(*world->rdf_world(), str.c_str(), str.length(), base_uri); // Delete anything explicitly declared to not exist Glib::ustring query_str = Glib::ustring("SELECT DISTINCT ?o WHERE { ?o a owl:Nothing }"); - Redland::Query query(*world->rdf_world(), query_str); - SharedPtr<Redland::QueryResults> results(query.run(*world->rdf_world(), model, base_uri)); + Sord::Query query(*world->rdf_world(), query_str); + SharedPtr<Sord::QueryResults> results(query.run(*world->rdf_world(), model, base_uri)); for (; !results->finished(); results->next()) { - const Redland::Node& object = results->get("o"); + const Sord::Node& object = results->get("o"); target->del(object.to_string()); } // Properties - query = Redland::Query(*world->rdf_world(), + query = Sord::Query(*world->rdf_world(), "SELECT DISTINCT ?s ?p ?o WHERE {\n" "?s ?p ?o .\n" "}"); @@ -226,7 +241,7 @@ Parser::parse_update( Glib::Mutex::Lock lock(world->rdf_world()->mutex()); string obj_uri(results->get("s").to_string()); const string key(results->get("p").to_string()); - const Redland::Node& val_node(results->get("o")); + const Sord::Node& val_node(results->get("o")); const Atom a(AtomRDF::node_to_atom(model, val_node)); if (obj_uri.find(":") == string::npos) obj_uri = Path(obj_uri).str(); @@ -237,11 +252,11 @@ Parser::parse_update( // Connections - Redland::Resource subject(*world->rdf_world(), base_uri); + Sord::Resource subject(*world->rdf_world(), base_uri); parse_connections(world, target, model, subject, "/"); // Port values - query = Redland::Query(*world->rdf_world(), + query = Sord::Query(*world->rdf_world(), "SELECT DISTINCT ?path ?value WHERE {\n" "?path ingen:value ?value .\n" "}"); @@ -249,8 +264,8 @@ Parser::parse_update( results = query.run(*world->rdf_world(), model, base_uri); for (; !results->finished(); results->next()) { Glib::Mutex::Lock lock(world->rdf_world()->mutex()); - const string obj_path = results->get("path").to_string(); - const Redland::Node& val_node = results->get("value"); + const string obj_path = results->get("path").to_string(); + const Sord::Node& val_node = results->get("value"); const Atom a(AtomRDF::node_to_atom(model, val_node)); target->set_property(obj_path, world->uris()->ingen_value, a); } @@ -265,30 +280,30 @@ boost::optional<Path> Parser::parse( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, + Sord::Model& model, Glib::ustring document_uri, boost::optional<Raul::Path> data_path, boost::optional<Raul::Path> parent, boost::optional<Raul::Symbol> symbol, boost::optional<GraphObject::Properties> data) { - const Redland::Node::Type res = Redland::Node::RESOURCE; + const Sord::Node::Type res = Sord::Node::RESOURCE; - const Redland::Resource rdf_type(*world->rdf_world(), NS_RDF "type"); + const Sord::Resource rdf_type(*world->rdf_world(), NS_RDF "type"); - const Redland::Node patch_class (*world->rdf_world(), res, NS_INGEN "Patch"); - const Redland::Node node_class (*world->rdf_world(), res, NS_INGEN "Node"); - const Redland::Node internal_class (*world->rdf_world(), res, NS_INGEN "Internal"); - const Redland::Node ladspa_class (*world->rdf_world(), res, NS_INGEN "LADSPAPlugin"); - const Redland::Node in_port_class (*world->rdf_world(), res, NS_LV2 "InputPort"); - const Redland::Node out_port_class (*world->rdf_world(), res, NS_LV2 "OutputPort"); - const Redland::Node lv2_class (*world->rdf_world(), res, NS_LV2 "Plugin"); + const Sord::Node patch_class (*world->rdf_world(), res, NS_INGEN "Patch"); + const Sord::Node node_class (*world->rdf_world(), res, NS_INGEN "Node"); + const Sord::Node internal_class (*world->rdf_world(), res, NS_INGEN "Internal"); + const Sord::Node ladspa_class (*world->rdf_world(), res, NS_INGEN "LADSPAPlugin"); + const Sord::Node in_port_class (*world->rdf_world(), res, NS_LV2 "InputPort"); + const Sord::Node out_port_class (*world->rdf_world(), res, NS_LV2 "OutputPort"); + const Sord::Node lv2_class (*world->rdf_world(), res, NS_LV2 "Plugin"); - Redland::Node subject; + Sord::Node subject = nil; if (data_path && data_path->is_root()) { subject = model.base_uri(); } else if (data_path) { - subject = Redland::Node(*world->rdf_world(), res, data_path->chop_start("/")); + subject = Sord::Node(*world->rdf_world(), res, data_path->chop_start("/")); } else { subject = nil; } @@ -297,9 +312,9 @@ Parser::parse( boost::optional<Path> ret; boost::optional<Path> root_path; - for (Redland::Iter i = model.find(subject, rdf_type, nil); !i.end(); ++i) { - const Redland::Node& subject = i.get_subject(); - const Redland::Node& rdf_class = i.get_object(); + for (Sord::Iter i = model.find(subject, rdf_type, nil); !i.end(); ++i) { + const Sord::Node& subject = i.get_subject(); + const Sord::Node& rdf_class = i.get_object(); if (!data_path) path_str = relative_uri(document_uri, subject.to_c_string(), true); @@ -367,19 +382,19 @@ boost::optional<Path> Parser::parse_patch( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject_node, + Sord::Model& model, + const Sord::Node& subject_node, boost::optional<Raul::Path> parent, boost::optional<Raul::Symbol> a_symbol, boost::optional<GraphObject::Properties> data) { const LV2URIMap& uris = *world->uris().get(); - Redland::Resource ingen_polyphony(*world->rdf_world(), NS_INGEN "polyphony"); - Redland::Resource lv2_port(*world->rdf_world(), NS_LV2 "port"); - Redland::Resource lv2_symbol(*world->rdf_world(), NS_LV2 "symbol"); + Sord::Resource ingen_polyphony(*world->rdf_world(), NS_INGEN "polyphony"); + Sord::Resource lv2_port(*world->rdf_world(), NS_LV2 "port"); + Sord::Resource lv2_symbol(*world->rdf_world(), NS_LV2 "symbol"); - const Redland::Node& patch = subject_node; + const Sord::Node& patch = subject_node; uint32_t patch_poly = 0; @@ -392,9 +407,9 @@ Parser::parse_patch( /* Load polyphony from file if necessary */ if (patch_poly == 0) { - Redland::Iter i = model.find(subject_node, ingen_polyphony, nil); + Sord::Iter i = model.find(subject_node, ingen_polyphony, nil); if (!i.end()) { - const Redland::Node& poly_node = i.get_object(); + const Sord::Node& poly_node = i.get_object(); if (poly_node.is_int()) patch_poly = poly_node.to_int(); else @@ -432,12 +447,12 @@ Parser::parse_patch( props.insert(make_pair(uris.ingen_polyphony, Raul::Atom(int32_t(patch_poly)))); target->put(patch_path, props); - Redland::Resource rdf_type(*world->rdf_world(), NS_RDF "type"); - Redland::Resource ingen_Patch(*world->rdf_world(), NS_INGEN "Patch"); - Redland::Resource ingen_node(*world->rdf_world(), NS_INGEN "node"); + Sord::Resource rdf_type(*world->rdf_world(), NS_RDF "type"); + Sord::Resource ingen_Patch(*world->rdf_world(), NS_INGEN "Patch"); + Sord::Resource ingen_node(*world->rdf_world(), NS_INGEN "node"); typedef multimap<Raul::URI, Raul::Atom> Properties; - typedef map<string, Redland::Node> Resources; + typedef map<string, Sord::Node> Resources; typedef map<string, Properties> Objects; typedef map<string, string> Types; @@ -447,16 +462,16 @@ Parser::parse_patch( Types types; /* For each node in this patch */ - typedef map<Redland::Node, Properties> Nodes; + typedef map<Sord::Node, Properties> Nodes; Nodes nodes; - for (Redland::Iter n = model.find(subject_node, ingen_node, nil); !n.end(); ++n) { - Redland::Node node = n.get_object(); + for (Sord::Iter n = model.find(subject_node, ingen_node, nil); !n.end(); ++n) { + Sord::Node node = n.get_object(); /* Get all node properties */ Properties node_properties; - for (Redland::Iter np = model.find(node, nil, nil); !np.end(); ++np) { - const Redland::Node& predicate = np.get_predicate(); - const Redland::Node& object = np.get_object(); + for (Sord::Iter np = model.find(node, nil, nil); !np.end(); ++np) { + const Sord::Node& predicate = np.get_predicate(); + const Sord::Node& object = np.get_object(); if (!skip_property(predicate)) { node_properties.insert( make_pair(predicate.to_string(), @@ -470,14 +485,14 @@ Parser::parse_patch( target->put(node_path, node_properties); /* For each port on this node */ - for (Redland::Iter p = model.find(node, lv2_port, nil); !p.end(); ++p) { - Redland::Node port = p.get_object(); + for (Sord::Iter p = model.find(node, lv2_port, nil); !p.end(); ++p) { + Sord::Node port = p.get_object(); /* Get all port properties */ Properties port_properties; - for (Redland::Iter pp = model.find(port, nil, nil); !pp.end(); ++pp) { - const Redland::Node& predicate = pp.get_predicate(); - const Redland::Node& object = pp.get_object(); + for (Sord::Iter pp = model.find(port, nil, nil); !pp.end(); ++pp) { + const Sord::Node& predicate = pp.get_predicate(); + const Sord::Node& object = pp.get_object(); if (!skip_property(predicate)) { port_properties.insert( make_pair(predicate.to_string(), @@ -499,14 +514,14 @@ Parser::parse_patch( } /* For each port on this patch */ - for (Redland::Iter p = model.find(patch, lv2_port, nil); !p.end(); ++p) { - Redland::Node port = p.get_object(); + for (Sord::Iter p = model.find(patch, lv2_port, nil); !p.end(); ++p) { + Sord::Node port = p.get_object(); /* Get all port properties */ Properties port_properties; - for (Redland::Iter pp = model.find(port, nil, nil); !pp.end(); ++pp) { - const Redland::Node& predicate = pp.get_predicate(); - const Redland::Node& object = pp.get_object(); + for (Sord::Iter pp = model.find(port, nil, nil); !pp.end(); ++pp) { + const Sord::Node& predicate = pp.get_predicate(); + const Sord::Node& object = pp.get_object(); if (!skip_property(predicate)) { port_properties.insert( make_pair(predicate.to_string(), @@ -533,7 +548,7 @@ Parser::parse_patch( target->set_property(patch_path, uris.ingen_enabled, (bool)true); #if 0 /* Enable */ - query = Redland::Query(*world->rdf_world(), Glib::ustring( + query = Sord::Query(*world->rdf_world(), Glib::ustring( "SELECT DISTINCT ?enabled WHERE {\n") + subject + " ingen:enabled ?enabled .\n" "}"); @@ -541,7 +556,7 @@ Parser::parse_patch( results = query.run(*world->rdf_world(), model, base_uri); for (; !results->finished(); results->next()) { Glib::Mutex::Lock lock(world->rdf_world()->mutex()); - const Redland::Node& enabled_node = results->get("enabled"); + const Sord::Node& enabled_node = results->get("enabled"); if (enabled_node.is_bool() && enabled_node) { target->set_property(patch_path, uris.ingen_enabled, (bool)true); break; @@ -559,24 +574,24 @@ boost::optional<Path> Parser::parse_node( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, const Raul::Path& path, boost::optional<GraphObject::Properties> data) { const LV2URIMap& uris = *world->uris().get(); - Redland::Resource rdf_instanceOf(*world->rdf_world(), NS_RDF "instanceOf"); + Sord::Resource rdf_instanceOf(*world->rdf_world(), NS_RDF "instanceOf"); /* Get plugin */ - Redland::Iter i = model.find(subject, rdf_instanceOf, nil); + Sord::Iter i = model.find(subject, rdf_instanceOf, nil); if (i.end()) { LOG(error) << "Node missing mandatory rdf:instanceOf property" << endl; return boost::optional<Path>(); } - const Redland::Node& plugin_node = i.get_object(); - if (plugin_node.type() != Redland::Node::RESOURCE) { + const Sord::Node& plugin_node = i.get_object(); + if (plugin_node.type() != Sord::Node::RESOURCE) { LOG(error) << "Node's rdf:instanceOf property is not a resource" << endl; return boost::optional<Path>(); } @@ -597,24 +612,24 @@ bool Parser::parse_connections( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, const Raul::Path& parent) { - Redland::Resource ingen_connection(*world->rdf_world(), NS_INGEN "connection"); - Redland::Resource ingen_source(*world->rdf_world(), NS_INGEN "source"); - Redland::Resource ingen_destination(*world->rdf_world(), NS_INGEN "destination"); + Sord::Resource ingen_connection(*world->rdf_world(), NS_INGEN "connection"); + Sord::Resource ingen_source(*world->rdf_world(), NS_INGEN "source"); + Sord::Resource ingen_destination(*world->rdf_world(), NS_INGEN "destination"); const Glib::ustring& base_uri = model.base_uri().to_string(); RDFNodes connections; - for (Redland::Iter i = model.find(subject, ingen_connection, nil); !i.end(); ++i) { + for (Sord::Iter i = model.find(subject, ingen_connection, nil); !i.end(); ++i) { connections.insert(i.get_object()); } for (RDFNodes::const_iterator i = connections.begin(); i != connections.end(); ++i) { - Redland::Iter s = model.find(*i, ingen_source, nil); - Redland::Iter d = model.find(*i, ingen_destination, nil); + Sord::Iter s = model.find(*i, ingen_source, nil); + Sord::Iter d = model.find(*i, ingen_destination, nil); if (s.end()) { LOG(error) << "Connection has no source" << endl; @@ -648,15 +663,15 @@ bool Parser::parse_properties( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, const Raul::URI& uri, boost::optional<GraphObject::Properties> data) { Resource::Properties properties; - for (Redland::Iter i = model.find(subject, nil, nil); !i.end(); ++i) { - const Redland::Node& key = i.get_predicate(); - const Redland::Node& val = i.get_object(); + for (Sord::Iter i = model.find(subject, nil, nil); !i.end(); ++i) { + const Sord::Node& key = i.get_predicate(); + const Sord::Node& val = i.get_object(); if (!skip_property(key)) { properties.insert(make_pair(key.to_string(), AtomRDF::node_to_atom(model, val))); @@ -674,7 +689,7 @@ Parser::parse_properties( bool -Parser::skip_property(const Redland::Node& predicate) +Parser::skip_property(const Sord::Node& predicate) { return (predicate.to_string() == "http://drobilla.net/ns/ingen#node" || predicate.to_string() == "http://lv2plug.in/ns/lv2core#port"); diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp index ed354905..06f42f14 100644 --- a/src/serialisation/Parser.hpp +++ b/src/serialisation/Parser.hpp @@ -24,8 +24,8 @@ #include <boost/optional.hpp> #include "interface/GraphObject.hpp" -namespace Raul { class Path; } -namespace Redland { class World; class Model; class Node; } +namespace Raul { class Path; } +namespace Sord { class World; class Model; class Node; } namespace Ingen { namespace Shared { class CommonInterface; } } namespace Ingen { @@ -86,7 +86,7 @@ private: boost::optional<Raul::Path> parse( Ingen::Shared::World* world, Shared::CommonInterface* target, - Redland::Model& model, + Sord::Model& model, Glib::ustring document_uri, boost::optional<Raul::Path> data_path=boost::optional<Raul::Path>(), boost::optional<Raul::Path> parent=boost::optional<Raul::Path>(), @@ -96,8 +96,8 @@ private: boost::optional<Raul::Path> parse_patch( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, boost::optional<Raul::Path> parent=boost::optional<Raul::Path>(), boost::optional<Raul::Symbol> symbol=boost::optional<Raul::Symbol>(), boost::optional<Properties> data=boost::optional<Properties>()); @@ -105,27 +105,27 @@ private: boost::optional<Raul::Path> parse_node( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, const Raul::Path& path, boost::optional<Properties> data=boost::optional<Properties>()); bool parse_properties( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, const Raul::URI& uri, - boost::optional<Properties> data=boost::optional<Properties>()); + boost::optional<Properties> data = boost::optional<Properties>()); bool parse_connections( Ingen::Shared::World* world, Ingen::Shared::CommonInterface* target, - Redland::Model& model, - const Redland::Node& subject, + Sord::Model& model, + const Sord::Node& subject, const Raul::Path& patch); - bool skip_property(const Redland::Node& predicate); + bool skip_property(const Sord::Node& predicate); }; diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 99e8bdc4..4c6e3f12 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -36,9 +36,7 @@ #include "raul/AtomRDF.hpp" #include "raul/Path.hpp" #include "raul/TableImpl.hpp" -#include "redlandmm/Model.hpp" -#include "redlandmm/Node.hpp" -#include "redlandmm/World.hpp" +#include "sord/sordmm.hpp" #include "module/World.hpp" #include "interface/EngineInterface.hpp" #include "interface/Plugin.hpp" @@ -55,7 +53,7 @@ using namespace std; using namespace Raul; -using namespace Redland; +using namespace Sord; using namespace Ingen; using namespace Ingen::Shared; @@ -110,23 +108,23 @@ Serialiser::write_manifest(const std::string& bundle_uri, SharedPtr<Patch> patch = PtrCast<Patch>(i->object); if (patch) { const std::string filename = uri_to_symbol(i->uri) + INGEN_PATCH_FILE_EXT; - const Redland::Resource subject(_model->world(), filename); + const Sord::Resource subject(_model->world(), filename); _model->add_statement( subject, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "ingen:Patch")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "ingen:Patch")); _model->add_statement( subject, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "lv2:Plugin")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "lv2:Plugin")); _model->add_statement( subject, - Redland::Curie(_model->world(), "rdfs:seeAlso"), - Redland::Resource(_model->world(), filename)); + Sord::Curie(_model->world(), "rdfs:seeAlso"), + Sord::Resource(_model->world(), filename)); _model->add_statement( subject, - Redland::Curie(_model->world(), "lv2:binary"), - Redland::Resource(_model->world(), + Sord::Curie(_model->world(), "lv2:binary"), + Sord::Resource(_model->world(), Glib::Module::build_path("", "ingen_lv2"))); symlink(Glib::Module::build_path(INGEN_MODULE_DIR, "ingen_lv2").c_str(), Glib::Module::build_path(bundle_path, "ingen_lv2").c_str()); @@ -166,7 +164,7 @@ Serialiser::to_string(SharedPtr<GraphObject> object, start_to_string(object->path(), base_uri); serialise(object); - Redland::Resource base_rdf_node(_model->world(), base_uri); + Sord::Resource base_rdf_node(_model->world(), base_uri); for (GraphObject::Properties::const_iterator v = extra_rdf.begin(); v != extra_rdf.end(); ++v) { if (v->first.find(":") != string::npos) { _model->add_statement( @@ -196,7 +194,7 @@ Serialiser::start_to_filename(const string& filename) _base_uri = "file://" + filename; else _base_uri = filename; - _model = new Redland::Model(*_world.rdf_world(), _base_uri); + _model = new Sord::Model(*_world.rdf_world(), _base_uri); _mode = TO_FILE; } @@ -218,7 +216,7 @@ Serialiser::start_to_string(const Raul::Path& root, const string& base_uri) _root_path = root; _base_uri = base_uri; - _model = new Redland::Model(*_world.rdf_world(), base_uri); + _model = new Sord::Model(*_world.rdf_world(), base_uri); _mode = TO_STRING; } @@ -233,9 +231,9 @@ Serialiser::finish() { string ret = ""; if (_mode == TO_FILE) { - _model->serialise_to_file(_base_uri, "turtle"); + _model->write_to_file(_base_uri, "turtle"); } else { - char* c_str = _model->serialise_to_string("turtle"); + char* c_str = _model->write_to_string("turtle"); if (c_str != NULL) { ret = c_str; free(c_str); @@ -249,31 +247,21 @@ Serialiser::finish() } -Redland::Node +Sord::Node Serialiser::instance_rdf_node(const Path& path) { assert(_model); assert(path.is_child_of(_root_path)); - - if (path == _root_path) - return Redland::Resource(_model->world(), _base_uri); - else - return Redland::Resource(_model->world(), - path.substr(_root_path.base().length())); + return Sord::Resource(_model->world(), path.chop_scheme().substr(1)); } -Redland::Node +Sord::Node Serialiser::class_rdf_node(const Path& path) { assert(_model); assert(path.is_child_of(_root_path)); - - if (path == _root_path) - return Redland::Resource(_model->world(), _base_uri); - else - return Redland::Resource(_model->world(), - string(META_PREFIX) + path.relative_to_base(_root_path).chop_start("/")); + return Sord::Resource(_model->world(), path.chop_scheme().substr(1)); } @@ -286,10 +274,10 @@ Serialiser::serialise(SharedPtr<GraphObject> object) throw (std::logic_error) SharedPtr<Shared::Patch> patch = PtrCast<Shared::Patch>(object); if (patch) { if (patch->path() == _root_path) { - const Redland::Resource patch_id(_model->world(), _base_uri); + const Sord::Resource patch_id(_model->world(), ""); serialise_patch(patch, patch_id); } else { - const Redland::Resource patch_id(_model->world(), + const Sord::Resource patch_id(_model->world(), string(META_PREFIX) + patch->path().chop_start("/")); serialise_patch(patch, patch_id); serialise_node(patch, patch_id, instance_rdf_node(patch->path())); @@ -299,7 +287,7 @@ Serialiser::serialise(SharedPtr<GraphObject> object) throw (std::logic_error) SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(object); if (node) { - const Redland::Resource plugin_id(_model->world(), node->plugin()->uri().str()); + const Sord::Resource plugin_id(_model->world(), node->plugin()->uri().str()); serialise_node(node, plugin_id, instance_rdf_node(node->path())); return; } @@ -316,19 +304,19 @@ Serialiser::serialise(SharedPtr<GraphObject> object) throw (std::logic_error) void -Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& patch_id) +Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& patch_id) { assert(_model); _model->add_statement( patch_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "ingen:Patch")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "ingen:Patch")); _model->add_statement( patch_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "lv2:Plugin")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "lv2:Plugin")); const LV2URIMap& uris = *_world.uris().get(); @@ -343,7 +331,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& _model->add_statement( patch_id, AtomRDF::atom_to_node(*_model, uris.lv2_symbol.c_str()), - Redland::Literal(_model->world(), symbol)); + Sord::Literal(_model->world(), symbol)); } else { symbol = s->second.get_string(); } @@ -353,7 +341,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& _model->add_statement( patch_id, AtomRDF::atom_to_node(*_model, uris.doap_name), - Redland::Literal(_model->world(), symbol)); + Sord::Literal(_model->world(), symbol)); serialise_properties(patch_id, NULL, patch->meta().properties()); @@ -366,21 +354,21 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& SharedPtr<Shared::Patch> subpatch = PtrCast<Shared::Patch>(n->second); SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(n->second); if (subpatch) { - const Redland::Resource class_id(_model->world(), + const Sord::Resource class_id(_model->world(), string(META_PREFIX) + subpatch->path().chop_start("/")); - const Redland::Node node_id(instance_rdf_node(n->second->path())); + const Sord::Node node_id(instance_rdf_node(n->second->path())); _model->add_statement( patch_id, - Redland::Curie(_model->world(), "ingen:node"), + Sord::Curie(_model->world(), "ingen:node"), node_id); serialise_patch(subpatch, class_id); serialise_node(subpatch, class_id, node_id); } else if (node) { - const Redland::Resource class_id(_model->world(), node->plugin()->uri().str()); - const Redland::Node node_id(instance_rdf_node(n->second->path())); + const Sord::Resource class_id(_model->world(), node->plugin()->uri().str()); + const Sord::Node node_id(instance_rdf_node(n->second->path())); _model->add_statement( patch_id, - Redland::Curie(_model->world(), "ingen:node"), + Sord::Curie(_model->world(), "ingen:node"), node_id); serialise_node(node, class_id, node_id); } @@ -390,7 +378,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& for (uint32_t i=0; i < patch->num_ports(); ++i) { Port* p = patch->port(i); - const Redland::Node port_id = root + const Sord::Node port_id = root ? instance_rdf_node(p->path()) : class_rdf_node(p->path()); @@ -400,7 +388,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& _model->add_statement( patch_id, - Redland::Resource(_model->world(), "http://lv2plug.in/ns/lv2core#port"), + Sord::Resource(_model->world(), "http://lv2plug.in/ns/lv2core#port"), port_id); serialise_port_meta(p, port_id); if (root) @@ -419,41 +407,41 @@ Serialiser::serialise_plugin(const Shared::Plugin& plugin) { assert(_model); - const Redland::Node plugin_id = Redland::Resource(_model->world(), plugin.uri().str()); + const Sord::Node plugin_id = Sord::Resource(_model->world(), plugin.uri().str()); _model->add_statement( plugin_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), plugin.type_uri().str())); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Resource(_model->world(), plugin.type_uri().str())); } void Serialiser::serialise_node(SharedPtr<Shared::Node> node, - const Redland::Node& class_id, const Redland::Node& node_id) + const Sord::Node& class_id, const Sord::Node& node_id) { _model->add_statement( node_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "ingen:Node")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "ingen:Node")); _model->add_statement( node_id, - Redland::Curie(_model->world(), "rdf:instanceOf"), + Sord::Curie(_model->world(), "rdf:instanceOf"), class_id); _model->add_statement( node_id, - Redland::Curie(_model->world(), "lv2:symbol"), - Redland::Literal(_model->world(), node->path().symbol())); + Sord::Curie(_model->world(), "lv2:symbol"), + Sord::Literal(_model->world(), node->path().symbol())); serialise_properties(node_id, &node->meta(), node->properties()); for (uint32_t i=0; i < node->num_ports(); ++i) { Port* p = node->port(i); - const Redland::Node port_id = instance_rdf_node(p->path()); + const Sord::Node port_id = instance_rdf_node(p->path()); serialise_port(p, port_id); _model->add_statement( node_id, - Redland::Curie(_model->world(), "lv2:port"), + Sord::Curie(_model->world(), "lv2:port"), port_id); } } @@ -461,36 +449,36 @@ Serialiser::serialise_node(SharedPtr<Shared::Node> node, /** Serialise a port on a Node */ void -Serialiser::serialise_port(const Port* port, const Redland::Node& port_id) +Serialiser::serialise_port(const Port* port, const Sord::Node& port_id) { if (port->is_input()) _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "lv2:InputPort")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "lv2:InputPort")); else _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "lv2:OutputPort")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "lv2:OutputPort")); for (Port::PortTypes::const_iterator i = port->types().begin(); i != port->types().end(); ++i) _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), i->uri().str())); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Resource(_model->world(), i->uri().str())); if (dynamic_cast<Patch*>(port->graph_parent())) _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:instanceOf"), + Sord::Curie(_model->world(), "rdf:instanceOf"), class_rdf_node(port->path())); _model->add_statement( port_id, - Redland::Curie(_model->world(), "lv2:symbol"), - Redland::Literal(_model->world(), port->path().symbol())); + Sord::Curie(_model->world(), "lv2:symbol"), + Sord::Literal(_model->world(), port->path().symbol())); serialise_properties(port_id, &port->meta(), port->properties()); } @@ -498,42 +486,42 @@ Serialiser::serialise_port(const Port* port, const Redland::Node& port_id) /** Serialise a port on a Patch */ void -Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id) +Serialiser::serialise_port_meta(const Port* port, const Sord::Node& port_id) { if (port->is_input()) _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "lv2:InputPort")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "lv2:InputPort")); else _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "lv2:OutputPort")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "lv2:OutputPort")); for (Port::PortTypes::const_iterator i = port->types().begin(); i != port->types().end(); ++i) _model->add_statement( port_id, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), i->uri().str())); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Resource(_model->world(), i->uri().str())); _model->add_statement( port_id, - Redland::Curie(_model->world(), "lv2:index"), + Sord::Curie(_model->world(), "lv2:index"), AtomRDF::atom_to_node(*_model, Atom((int)port->index()))); _model->add_statement( port_id, - Redland::Curie(_model->world(), "lv2:symbol"), - Redland::Literal(_model->world(), port->path().symbol())); + Sord::Curie(_model->world(), "lv2:symbol"), + Sord::Literal(_model->world(), port->path().symbol())); if (!port->get_property("http://lv2plug.in/ns/lv2core#default").is_valid()) { if (port->is_input()) { if (port->value().is_valid()) { _model->add_statement( port_id, - Redland::Curie(_model->world(), "lv2:default"), + Sord::Curie(_model->world(), "lv2:default"), AtomRDF::atom_to_node(*_model, Atom(port->value()))); } else if (port->is_a(PortType::CONTROL)) { LOG(warn) << "Port " << port->path() << " has no lv2:default" << endl; @@ -553,48 +541,48 @@ Serialiser::serialise_connection(SharedPtr<GraphObject> parent, throw std::logic_error("serialise_connection called without serialization in progress"); bool top = (parent->path() == _root_path); - const Redland::Node src_node = top + const Sord::Node src_node = top ? instance_rdf_node(connection->src_port_path()) : class_rdf_node(connection->src_port_path()); - const Redland::Node dst_node = top + const Sord::Node dst_node = top ? instance_rdf_node(connection->dst_port_path()) : class_rdf_node(connection->dst_port_path()); - const Redland::Node connection_node = Redland::Node::blank_id(*_world.rdf_world()); + const Sord::Node connection_node = Sord::Node::blank_id(*_world.rdf_world()); _model->add_statement( connection_node, - Redland::Curie(_model->world(), "ingen:source"), + Sord::Curie(_model->world(), "ingen:source"), src_node); _model->add_statement( connection_node, - Redland::Curie(_model->world(), "ingen:destination"), + Sord::Curie(_model->world(), "ingen:destination"), dst_node); if (parent) { - const Redland::Node parent_node = class_rdf_node(parent->path()); + const Sord::Node parent_node = class_rdf_node(parent->path()); _model->add_statement( parent_node, - Redland::Curie(_model->world(), "ingen:connection"), + Sord::Curie(_model->world(), "ingen:connection"), connection_node); } else { _model->add_statement( connection_node, - Redland::Curie(_model->world(), "rdf:type"), - Redland::Resource(_model->world(), "ingen:Connection")); + Sord::Curie(_model->world(), "rdf:type"), + Sord::Curie(_model->world(), "ingen:Connection")); } } void Serialiser::serialise_properties( - Redland::Node subject, + Sord::Node subject, const Shared::Resource* meta, const GraphObject::Properties& properties) { for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) { if (v->second.is_valid()) { if (!meta || !meta->has_property(v->first.str(), v->second)) { - const Redland::Resource key(_model->world(), v->first.str()); - const Redland::Node value(AtomRDF::atom_to_node(*_model, v->second)); + const Sord::Resource key(_model->world(), v->first.str()); + const Sord::Node value(AtomRDF::atom_to_node(*_model, v->second)); if (value.is_valid()) { _model->add_statement(subject, key, value); } else { diff --git a/src/serialisation/Serialiser.hpp b/src/serialisation/Serialiser.hpp index ccc51d20..58fd6fc6 100644 --- a/src/serialisation/Serialiser.hpp +++ b/src/serialisation/Serialiser.hpp @@ -25,8 +25,7 @@ #include <cassert> #include "raul/SharedPtr.hpp" #include "raul/Path.hpp" -#include "redlandmm/World.hpp" -#include "redlandmm/Model.hpp" +#include "sord/sordmm.hpp" #include "interface/GraphObject.hpp" #include "shared/Store.hpp" @@ -93,27 +92,27 @@ private: void setup_prefixes(); - void serialise_patch(SharedPtr<Shared::Patch> p, const Redland::Node& id); + void serialise_patch(SharedPtr<Shared::Patch> p, const Sord::Node& id); void serialise_node(SharedPtr<Shared::Node> n, - const Redland::Node& class_id, const Redland::Node& id); - void serialise_port(const Shared::Port* p, const Redland::Node& id); - void serialise_port_meta(const Shared::Port* p, const Redland::Node& id); + const Sord::Node& class_id, const Sord::Node& id); + void serialise_port(const Shared::Port* p, const Sord::Node& id); + void serialise_port_meta(const Shared::Port* p, const Sord::Node& id); - void serialise_meta_properties(Redland::Node subject, const Properties& properties); + void serialise_meta_properties(Sord::Node subject, const Properties& properties); void serialise_properties( - Redland::Node subject, + Sord::Node subject, const Shared::Resource* meta, const Properties& properties); - Redland::Node instance_rdf_node(const Raul::Path& path); - Redland::Node class_rdf_node(const Raul::Path& path); + Sord::Node instance_rdf_node(const Raul::Path& path); + Sord::Node class_rdf_node(const Raul::Path& path); Raul::Path _root_path; SharedPtr<Shared::Store> _store; Mode _mode; std::string _base_uri; Shared::World& _world; - Redland::Model* _model; + Sord::Model* _model; }; diff --git a/src/serialisation/wscript b/src/serialisation/wscript index 4d2fe690..4e38bed5 100644 --- a/src/serialisation/wscript +++ b/src/serialisation/wscript @@ -17,5 +17,5 @@ def build(bld): obj.target = 'ingen_serialisation' obj.install_path = '${LIBDIR}' obj.use = 'libingen_shared' - autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL REDLANDMM') + autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL SORD') diff --git a/src/shared/wscript b/src/shared/wscript index 84f7b4ee..07a851bb 100644 --- a/src/shared/wscript +++ b/src/shared/wscript @@ -29,5 +29,5 @@ def build(bld): obj.vnum = '0.0.0' obj.install_path = '${LIBDIR}' obj.linkflags = '-ldl' - autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL REDLANDMM LIBLO') + autowaf.use_lib(bld, obj, 'GLIBMM LV2CORE SLV2 RAUL SORD LIBLO') @@ -54,7 +54,7 @@ def configure(conf): atleast_version='2.6.0', mandatory=False) autowaf.check_pkg(conf, 'libglademm-2.4', uselib_store='GLADEMM', atleast_version='2.6.0', mandatory=False) - autowaf.check_pkg(conf, 'redlandmm', uselib_store='REDLANDMM', + autowaf.check_pkg(conf, 'sord', uselib_store='SORD', atleast_version='0.1.0', mandatory=False) if not Options.options.no_http: autowaf.check_pkg(conf, 'libsoup-2.4', uselib_store='SOUP', @@ -132,7 +132,7 @@ def build(bld): obj.defines = 'VERSION="' + bld.env['INGEN_VERSION'] + '"' obj.use = 'libingen_module libingen_shared' obj.install_path = '${BINDIR}' - autowaf.use_lib(bld, obj, 'GTHREAD GLIBMM REDLANDMM RAUL LV2CORE SLV2 INGEN LIBLO SOUP') + autowaf.use_lib(bld, obj, 'GTHREAD GLIBMM SORD RAUL LV2CORE SLV2 INGEN LIBLO SOUP') bld.install_files('${DATADIR}/applications', 'src/ingen/ingen.desktop') |