diff options
author | David Robillard <d@drobilla.net> | 2007-10-21 05:27:32 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-10-21 05:27:32 +0000 |
commit | 22b17482a552b0966a80c19d94651385357d5701 (patch) | |
tree | 8f2d5b7d14eb28d1f43d718e507024844e45784c | |
parent | c74810c215c2722a69bb74e834caa5fe89109561 (diff) | |
download | ingen-22b17482a552b0966a80c19d94651385357d5701.tar.gz ingen-22b17482a552b0966a80c19d94651385357d5701.tar.bz2 ingen-22b17482a552b0966a80c19d94651385357d5701.zip |
Fix patch serialisation to a string.
Fix patch uploading.
Closes ticket 100.
git-svn-id: http://svn.drobilla.net/lad/ingen@892 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/libs/gui/PatchCanvas.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/UploadPatchWindow.cpp | 20 | ||||
-rw-r--r-- | src/libs/serialisation/Serialiser.cpp | 21 | ||||
-rw-r--r-- | src/libs/serialisation/Serialiser.hpp | 7 |
4 files changed, 31 insertions, 19 deletions
diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index ba17b24d..35e8ad71 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -460,7 +460,7 @@ void PatchCanvas::copy_selection() { Serialiser serialiser(*App::instance().world()->rdf_world); - serialiser.start_to_string(); + serialiser.start_to_string(""); for (list<boost::shared_ptr<Item> >::iterator m = _selected_items.begin(); m != _selected_items.end(); ++m) { boost::shared_ptr<NodeModule> module = boost::dynamic_pointer_cast<NodeModule>(*m); diff --git a/src/libs/gui/UploadPatchWindow.cpp b/src/libs/gui/UploadPatchWindow.cpp index 959bb1ae..c64bac50 100644 --- a/src/libs/gui/UploadPatchWindow.cpp +++ b/src/libs/gui/UploadPatchWindow.cpp @@ -237,11 +237,9 @@ UploadPatchWindow::upload_clicked() Glib::ustring symbol = _symbol_entry->get_text(); Glib::ustring short_name = _short_name_entry->get_text(); - _patch->set_variable("lv2:symbol", Atom(symbol)); - App::instance().engine()->set_variable(_patch->path(), "lv2:symbol", Atom(symbol)); - - _patch->set_variable("doap:name", Atom(short_name)); - App::instance().engine()->set_variable(_patch->path(), "doap:name", Atom(short_name)); + GraphObject::Variables extra_rdf; + extra_rdf.insert(make_pair("lv2:symbol", Atom(symbol))); + extra_rdf.insert(make_pair("doap:name", Atom(short_name))); _response = 0; _progress_pct = 0; @@ -250,15 +248,13 @@ UploadPatchWindow::upload_clicked() _upload_progress->set_text(""); Serialiser s(*App::instance().world()->rdf_world); - s.start_to_string(); - s.serialise(_patch); - const string str = s.finish(); - istringstream stream(str); - string url = "http://rdf.drobilla.net/ingen_patches/"; - url += symbol + ".ingen.ttl"; + const string uri = string("http://rdf.drobilla.net/ingen_patches/") + .append(symbol).append(".ingen.ttl"); + + const string str = s.to_string(_patch, uri, extra_rdf); - _thread = new UploadThread(this, str, url); + _thread = new UploadThread(this, str, uri); _thread->start(); diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp index e3d33094..223093a0 100644 --- a/src/libs/serialisation/Serialiser.cpp +++ b/src/libs/serialisation/Serialiser.cpp @@ -67,12 +67,25 @@ Serialiser::to_file(SharedPtr<GraphObject> object, const string& filename) } + string -Serialiser::to_string(SharedPtr<GraphObject> object) +Serialiser::to_string(SharedPtr<GraphObject> object, + const string& base_uri, + const GraphObject::Variables& extra_rdf) { _root_object = object; - start_to_string(); + start_to_string(base_uri); serialise(object); + + RDF::Node base_rdf_node(_model->world(), RDF::Node::RESOURCE, base_uri); + for (GraphObject::Variables::const_iterator v = extra_rdf.begin(); v != extra_rdf.end(); ++v) { + if (v->first.find(":") != string::npos) { + _model->add_statement(base_rdf_node, v->first, v->second); + } else { + cerr << "Warning: not serialising extra RDF with key '" << v->first << "'" << endl; + } + } + return finish(); } @@ -100,11 +113,11 @@ Serialiser::start_to_filename(const string& filename) * the desired objects have been serialised. */ void -Serialiser::start_to_string() +Serialiser::start_to_string(const string& base_uri) { setlocale(LC_NUMERIC, "C"); - _base_uri = ""; + _base_uri = base_uri; _model = new RDF::Model(_world); _mode = TO_STRING; } diff --git a/src/libs/serialisation/Serialiser.hpp b/src/libs/serialisation/Serialiser.hpp index 041bbb69..fc15cd1a 100644 --- a/src/libs/serialisation/Serialiser.hpp +++ b/src/libs/serialisation/Serialiser.hpp @@ -57,9 +57,12 @@ public: Serialiser(Raul::RDF::World& world); void to_file(SharedPtr<GraphObject> object, const string& filename); - string to_string(SharedPtr<GraphObject> object); + + string to_string(SharedPtr<GraphObject> object, + const string& base_uri, + const GraphObject::Variables& extra_rdf); - void start_to_string(); + void start_to_string(const string& base_uri); void serialise(SharedPtr<GraphObject> object) throw (std::logic_error); void serialise_connection(SharedPtr<Shared::Connection> c) throw (std::logic_error); string finish(); |