diff options
author | David Robillard <d@drobilla.net> | 2008-11-09 01:32:38 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-11-09 01:32:38 +0000 |
commit | 5d1f579900182f283a1c21ad4e59daf7f035e219 (patch) | |
tree | e73066002177cf48a31eef91712aa74839dfc555 /src/serialisation | |
parent | 23bb407a4f0db71eb15cbf8bbb8e82e02088a998 (diff) | |
download | ingen-5d1f579900182f283a1c21ad4e59daf7f035e219.tar.gz ingen-5d1f579900182f283a1c21ad4e59daf7f035e219.tar.bz2 ingen-5d1f579900182f283a1c21ad4e59daf7f035e219.zip |
Move patch to /patch via HTTP to give a place for RESTful access to other things.
Implement HTTP access to plugins.
Work towards client being able to use HTTP to connect.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1712 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r-- | src/serialisation/Parser.cpp | 57 | ||||
-rw-r--r-- | src/serialisation/Parser.hpp | 1 | ||||
-rw-r--r-- | src/serialisation/Serialiser.cpp | 6 | ||||
-rw-r--r-- | src/serialisation/Serialiser.hpp | 3 |
4 files changed, 42 insertions, 25 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 3945c379..b9f52652 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -42,12 +42,15 @@ namespace Serialisation { Glib::ustring Parser::uri_relative_to_base(Glib::ustring base, const Glib::ustring uri) { + //cout << "BASE: " << base << endl; base = base.substr(0, base.find_last_of("/")+1); + //cout << uri << " RELATIVE TO " << base << endl; Glib::ustring ret; - if (uri.length() > base.length() && uri.substr(0, base.length()) == base) + if (uri.length() >= base.length() && uri.substr(0, base.length()) == base) ret = uri.substr(base.length()); else ret = uri; + //cout << " => " << ret << endl; return ret; } @@ -126,13 +129,18 @@ Parser::parse( else query_str = Glib::ustring("SELECT DISTINCT ?subject ?class WHERE { ?subject a ?class . }"); + cout << "QUERY: " << query_str << endl; + Redland::Query query(*world->rdf_world, query_str); Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri); 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"); string subject_str = ((object_uri && object_uri.get() != "") ? object_uri.get() : base_uri); if (subject_str[0] == '/') @@ -143,39 +151,43 @@ Parser::parse( const Redland::Node subject_uri(*world->rdf_world, res, subject_str); bool ret = false; + std::string path_str; for (Redland::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { const Redland::Node& subject = (object_uri ? subject_uri : (*i)["subject"]); const Redland::Node& rdf_class = (*i)["class"]; + //cout << "SUBJECT: " << subject.to_c_string() << endl; if (!object_uri) { - std::string path_str = uri_relative_to_base(base_uri, subject.to_c_string()); + path_str = uri_relative_to_base(base_uri, subject.to_c_string()); + //cout << "BASE: " << base_uri.c_str() << endl; + //cout << "PATH: " << path_str.c_str() << endl; if (path_str[0] != '/') path_str = string("/").append(path_str); - if (Path(path_str).parent() != "/") + if (!Path::is_valid(path_str)) { + //cerr << "INVALID PATH: " << path_str << endl; + } else if (Path(path_str).parent() != "/") { continue; + } } - if (rdf_class == patch_class || rdf_class == node_class || - rdf_class == in_port_class || rdf_class == out_port_class) { - Raul::Path path("/"); - if (base_uri != subject.to_c_string()) { - string path_str = (string)uri_relative_to_base(base_uri, subject.to_c_string()); - if (path_str[0] != '/') - path_str = string("/").append(path_str); - if (Path::is_valid(path_str)) { - path = path_str; - } else { - cerr << "[Parser] ERROR: Invalid path '" << path << "'" << endl; - continue; - } - } + const bool is_plugin = (rdf_class == ladspa_class) + || (rdf_class == lv2_class) + || (rdf_class == internal_class); + + const bool is_object = (rdf_class == patch_class) + || (rdf_class == node_class) + || (rdf_class == in_port_class) + || (rdf_class == out_port_class); + + if (is_object) { + Raul::Path path(path_str == "" ? "/" : path_str); if (path.parent() != "/") continue; if (rdf_class == patch_class) { ret = parse_patch(world, target, model, base_uri, engine_base, - subject.to_c_string(), data); + path_str, data); if (ret) target->set_variable(path, "ingen:document", Atom(base_uri.c_str())); } else if (rdf_class == node_class) { @@ -184,11 +196,18 @@ Parser::parse( } else if (rdf_class == in_port_class || rdf_class == out_port_class) { ret = parse_port(world, target, model, base_uri, Glib::ustring("<") + subject.to_c_string() + ">", path, data); - } + } else if (rdf_class == ladspa_class || rdf_class == lv2_class || rdf_class == internal_class) if (ret == false) { cerr << "Failed to parse object " << object_uri << endl; return ret; } + } else if (is_plugin) { + if (path_str.length() > 0) { + const string uri = path_str.substr(1); + cout << "PLUGIN: " << uri << endl; + } else { + cout << "ERROR: Plugin with no URI parsed, ignoring" << endl; + } } } diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp index 9d1314fe..d20e4345 100644 --- a/src/serialisation/Parser.hpp +++ b/src/serialisation/Parser.hpp @@ -116,7 +116,6 @@ private: const Glib::ustring& base_uri, const Glib::ustring& subject, const Raul::Path& parent); - }; diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index cb9e36e4..9e8623a3 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -372,16 +372,16 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch) void -Serialiser::serialise_plugin(SharedPtr<Shared::Plugin> plugin) +Serialiser::serialise_plugin(const Shared::Plugin& plugin) { assert(_model); - const Redland::Node plugin_id = Redland::Node(_model->world(), Redland::Node::RESOURCE, plugin->uri()); + const Redland::Node plugin_id = Redland::Node(_model->world(), Redland::Node::RESOURCE, plugin.uri()); _model->add_statement( plugin_id, "rdf:type", - Redland::Node(_model->world(), Redland::Node::RESOURCE, plugin->type_uri())); + Redland::Node(_model->world(), Redland::Node::RESOURCE, plugin.type_uri())); } diff --git a/src/serialisation/Serialiser.hpp b/src/serialisation/Serialiser.hpp index 58cad912..4d33d771 100644 --- a/src/serialisation/Serialiser.hpp +++ b/src/serialisation/Serialiser.hpp @@ -66,6 +66,7 @@ public: void start_to_string(const Raul::Path& root, const std::string& base_uri); void serialise(SharedPtr<GraphObject> object) throw (std::logic_error); + void serialise_plugin(const Shared::Plugin& p); void serialise_connection(SharedPtr<GraphObject> parent, SharedPtr<Shared::Connection> c) throw (std::logic_error); @@ -78,8 +79,6 @@ private: void setup_prefixes(); - void serialise_plugin(SharedPtr<Shared::Plugin> p); - void serialise_patch(SharedPtr<Shared::Patch> p); void serialise_node(SharedPtr<Shared::Node> n, const Redland::Node& id); void serialise_port(const Shared::Port* p, const Redland::Node& id); |