summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-16 21:43:16 +0000
committerDavid Robillard <d@drobilla.net>2011-02-16 21:43:16 +0000
commit2ad0daa288aca040153b7a4dd974109b9a4fc2fc (patch)
tree2fb28b2c63f8e1a8ab36f5043b91f272b1b6cf2f
parent9879baf23904b137d38311588a3692d7456870e2 (diff)
downloadingen-2ad0daa288aca040153b7a4dd974109b9a4fc2fc.tar.gz
ingen-2ad0daa288aca040153b7a4dd974109b9a4fc2fc.tar.bz2
ingen-2ad0daa288aca040153b7a4dd974109b9a4fc2fc.zip
Tidy up serialiser interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2965 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/engine/HTTPEngineReceiver.cpp10
-rw-r--r--src/gui/ThreadedLoader.cpp5
-rw-r--r--src/serialisation/Serialiser.cpp95
-rw-r--r--src/serialisation/Serialiser.hpp25
4 files changed, 60 insertions, 75 deletions
diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp
index d2106c13..81481f02 100644
--- a/src/engine/HTTPEngineReceiver.cpp
+++ b/src/engine/HTTPEngineReceiver.cpp
@@ -99,9 +99,14 @@ HTTPEngineReceiver::deactivate_source()
void
-HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const char* path_str,
- GHashTable *query, SoupClientContext* client, void* data)
+HTTPEngineReceiver::message_callback(SoupServer* server,
+ SoupMessage* msg,
+ const char* path_str,
+ GHashTable* query,
+ SoupClientContext* client,
+ void* data)
{
+ #if 0
HTTPEngineReceiver* me = (HTTPEngineReceiver*)data;
SharedPtr<Store> store = me->_engine.world()->store();
@@ -221,6 +226,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
} else {
soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED);
}
+ #endif
}
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index cd5e5ce6..10f1f8d6 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -137,11 +137,10 @@ void
ThreadedLoader::save_patch_event(SharedPtr<PatchModel> model, const string& filename)
{
if (App::instance().serialiser()) {
- Serialiser::Record r(model, filename);
if (filename.find(INGEN_BUNDLE_EXT) != string::npos)
- App::instance().serialiser()->write_bundle(r);
+ App::instance().serialiser()->write_bundle(model, filename);
else
- App::instance().serialiser()->to_file(r);
+ App::instance().serialiser()->to_file(model, filename);
}
}
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 1ffe07c8..fb25d437 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -78,11 +78,9 @@ Serialiser::Serialiser(Shared::World& world, SharedPtr<Shared::Store> store)
}
void
-Serialiser::to_file(const Record& record)
+Serialiser::to_file(SharedPtr<Shared::GraphObject> object,
+ const std::string& filename)
{
- SharedPtr<GraphObject> object = record.object;
- const string& filename = record.uri;
-
_root_path = object->path();
start_to_filename(filename);
serialise(object);
@@ -93,61 +91,64 @@ static
std::string
uri_to_symbol(const std::string& uri)
{
- return Path::nameify(Glib::path_get_basename(Glib::filename_from_uri(uri)));
+ const std::string filename = Glib::filename_from_uri(uri);
+ return Path::nameify(Glib::path_get_basename(
+ filename.substr(0, filename.find_last_of('.'))));
}
void
-Serialiser::write_manifest(const std::string& bundle_uri,
- const Records& records)
+Serialiser::write_manifest(const std::string& bundle_uri,
+ SharedPtr<Shared::Patch> patch,
+ const std::string& patch_symbol)
{
- const string bundle_path(Glib::filename_from_uri(bundle_uri));
- const string filename(Glib::build_filename(bundle_path, "manifest.ttl"));
- start_to_filename(filename);
Sord::World& world = _model->world();
- for (Records::const_iterator i = records.begin(); i != records.end(); ++i) {
- SharedPtr<Patch> patch = PtrCast<Patch>(i->object);
- if (patch) {
- const std::string filename = uri_to_symbol(i->uri) + INGEN_PATCH_FILE_EXT;
- const Sord::URI subject(world, filename);
- _model->add_statement(subject,
- Sord::Curie(world, "rdf:type"),
- Sord::Curie(world, "ingen:Patch"));
- _model->add_statement(subject,
- Sord::Curie(world, "rdf:type"),
- Sord::Curie(world, "lv2:Plugin"));
- _model->add_statement(subject,
- Sord::Curie(world, "rdfs:seeAlso"),
- Sord::URI(world, filename));
- _model->add_statement(
- subject,
- Sord::Curie(world, "lv2:binary"),
- Sord::URI(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());
- }
- }
+
+ const string bundle_path(Glib::filename_from_uri(bundle_uri));
+ const string manifest_path(Glib::build_filename(bundle_path, "manifest.ttl"));
+ const string binary_path(Glib::Module::build_path("", "ingen_lv2"));
+
+ start_to_filename(manifest_path);
+
+ const string filename(patch_symbol + INGEN_PATCH_FILE_EXT);
+ const Sord::URI subject(world, filename);
+
+ _model->add_statement(subject,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "ingen:Patch"));
+ _model->add_statement(subject,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "lv2:Plugin"));
+ _model->add_statement(subject,
+ Sord::Curie(world, "rdfs:seeAlso"),
+ Sord::URI(world, filename));
+ _model->add_statement(subject,
+ Sord::Curie(world, "lv2:binary"),
+ Sord::URI(world, binary_path));
+
+ symlink(Glib::Module::build_path(INGEN_MODULE_DIR, "ingen_lv2").c_str(),
+ Glib::Module::build_path(bundle_path, "ingen_lv2").c_str());
+
finish();
}
void
-Serialiser::write_bundle(const Record& record)
+Serialiser::write_bundle(SharedPtr<GraphObject> object,
+ const std::string& uri)
{
- SharedPtr<GraphObject> object = record.object;
- string bundle_uri = record.uri;
+ string bundle_uri = uri;
if (bundle_uri[bundle_uri.length()-1] != '/')
bundle_uri.append("/");
g_mkdir_with_parents(Glib::filename_from_uri(bundle_uri).c_str(), 0744);
- Records records;
-
- string symbol = uri_to_symbol(record.uri);
+ const string symbol = uri_to_symbol(uri);
const string root_file = bundle_uri + symbol + INGEN_PATCH_FILE_EXT;
+
start_to_filename(root_file);
serialise(object);
finish();
- records.push_back(Record(object, bundle_uri + symbol + INGEN_PATCH_FILE_EXT));
- write_manifest(bundle_uri, records);
+
+ write_manifest(bundle_uri, PtrCast<Shared::Patch>(object), symbol);
}
string
@@ -329,7 +330,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& pa
continue;
SharedPtr<Shared::Patch> subpatch = PtrCast<Shared::Patch>(n->second);
- SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(n->second);
+ SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(n->second);
if (subpatch) {
const Sord::URI class_id(world,
string(META_PREFIX) + subpatch->path().chop_start("/"));
@@ -374,18 +375,6 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& pa
}
void
-Serialiser::serialise_plugin(const Shared::Plugin& plugin)
-{
- assert(_model);
-
- const Sord::Node plugin_id = Sord::URI(_model->world(), plugin.uri().str());
-
- _model->add_statement(plugin_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::URI(_model->world(), plugin.type_uri().str()));
-}
-
-void
Serialiser::serialise_node(SharedPtr<Shared::Node> node,
const Sord::Node& class_id,
const Sord::Node& node_id)
diff --git a/src/serialisation/Serialiser.hpp b/src/serialisation/Serialiser.hpp
index 7fc641f6..b1f7b5ef 100644
--- a/src/serialisation/Serialiser.hpp
+++ b/src/serialisation/Serialiser.hpp
@@ -57,23 +57,11 @@ public:
typedef Shared::GraphObject::Properties Properties;
- struct Record {
- Record(SharedPtr<Shared::GraphObject> o, const std::string& u)
- : object(o), uri(u)
- {}
+ void to_file(SharedPtr<Shared::GraphObject> object,
+ const std::string& filename);
- const SharedPtr<Shared::GraphObject> object;
- const std::string uri;
- };
-
- typedef std::list<Record> Records;
-
- void to_file(const Record& record);
-
- void write_bundle(const Record& record);
-
- void write_manifest(const std::string& bundle_uri,
- const Records& records);
+ void write_bundle(SharedPtr<Shared::GraphObject> object,
+ const std::string& filename);
std::string to_string(SharedPtr<Shared::GraphObject> object,
const std::string& base_uri,
@@ -81,7 +69,6 @@ public:
void start_to_string(const Raul::Path& root, const std::string& base_uri);
void serialise(SharedPtr<Shared::GraphObject> object) throw (std::logic_error);
- void serialise_plugin(const Shared::Plugin& p);
void serialise_connection(SharedPtr<Shared::GraphObject> parent,
SharedPtr<Shared::Connection> c) throw (std::logic_error);
@@ -107,6 +94,10 @@ private:
Sord::Node path_rdf_node(const Raul::Path& path);
+ void write_manifest(const std::string& bundle_uri,
+ SharedPtr<Shared::Patch> patch,
+ const std::string& patch_symbol);
+
Raul::Path _root_path;
SharedPtr<Shared::Store> _store;
Mode _mode;