From 481df972552977a1331f9eb70bb6dce55429475c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 16 Nov 2008 21:49:33 +0000 Subject: Fix loading errors. Partially separate 'update' from parsing from object (i.e. patch file loading) parsing. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1736 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/HTTPClientReceiver.cpp | 2 +- src/serialisation/Parser.cpp | 42 +++++++++++++++++++++++++-------------- src/serialisation/Parser.hpp | 10 ++++++++++ 3 files changed, 38 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp index dcb105b0..cee7eac4 100644 --- a/src/client/HTTPClientReceiver.cpp +++ b/src/client/HTTPClientReceiver.cpp @@ -97,7 +97,7 @@ HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std:: void HTTPClientReceiver::update(const std::string& str) { - cout << _parser->parse_string(_world, _target.get(), str, "/", "/"); + cout << _parser->parse_update(_world, _target.get(), str, "/", "/"); } void diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 0591e0f8..9d5007e4 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -109,25 +109,20 @@ Parser::parse_string( bool -Parser::parse( +Parser::parse_update( Ingen::Shared::World* world, - Ingen::Shared::CommonInterface* target, - Redland::Model& model, - Glib::ustring base_uri, + Shared::CommonInterface* target, + const Glib::ustring& str, + const Glib::ustring& base_uri, Glib::ustring engine_base, boost::optional object_uri, boost::optional symbol, boost::optional data) { - const Redland::Node::Type res = Redland::Node::RESOURCE; - Glib::ustring query_str; - if (object_uri && object_uri.get()[0] == '/') - object_uri = object_uri.get().substr(1); - - /* **** First query out global information (top-level info) **** */ - + Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri); + // Delete anything explicitly declared to not exist - query_str = Glib::ustring("SELECT DISTINCT ?o WHERE { ?o a owl:Nothing }"); + Glib::ustring query_str = Glib::ustring("SELECT DISTINCT ?o WHERE { ?o a owl:Nothing }"); Redland::Query query(*world->rdf_world, query_str); Redland::Query::Results results = query.run(*world->rdf_world, model, base_uri); @@ -173,16 +168,33 @@ Parser::parse( } world->rdf_world->mutex().unlock(); + return parse(world, target, model, base_uri, engine_base, object_uri, symbol, data); +} + - /* **** Now query out objects **** */ +bool +Parser::parse( + Ingen::Shared::World* world, + Ingen::Shared::CommonInterface* target, + Redland::Model& model, + Glib::ustring base_uri, + Glib::ustring engine_base, + boost::optional object_uri, + boost::optional symbol, + boost::optional data) +{ + const Redland::Node::Type res = Redland::Node::RESOURCE; + Glib::ustring query_str; + if (object_uri && object_uri.get()[0] == '/') + object_uri = object_uri.get().substr(1); if (object_uri) query_str = Glib::ustring("SELECT DISTINCT ?class WHERE { <") + object_uri.get() + "> a ?class . }"; else query_str = Glib::ustring("SELECT DISTINCT ?subject ?class WHERE { ?subject a ?class . }"); - query = Redland::Query(*world->rdf_world, query_str); - results = Redland::Query::Results(query.run(*world->rdf_world, model, base_uri)); + 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"); diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp index d20e4345..0210a4bb 100644 --- a/src/serialisation/Parser.hpp +++ b/src/serialisation/Parser.hpp @@ -58,6 +58,16 @@ public: boost::optional object_uri=boost::optional(), boost::optional symbol=boost::optional(), boost::optional data=boost::optional()); + + virtual bool parse_update( + Ingen::Shared::World* world, + Shared::CommonInterface* target, + const Glib::ustring& str, + const Glib::ustring& base_uri, + Glib::ustring engine_base, + boost::optional object_uri=boost::optional(), + boost::optional symbol=boost::optional(), + boost::optional data=boost::optional()); private: -- cgit v1.2.1