summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-16 20:05:45 +0000
committerDavid Robillard <d@drobilla.net>2011-02-16 20:05:45 +0000
commit9879baf23904b137d38311588a3692d7456870e2 (patch)
treebc9f2ccc709134975f915432acf65df36d172008 /src
parent2c312daa5bf150e8314e0a48769afb184dd95f54 (diff)
downloadingen-9879baf23904b137d38311588a3692d7456870e2.tar.gz
ingen-9879baf23904b137d38311588a3692d7456870e2.tar.bz2
ingen-9879baf23904b137d38311588a3692d7456870e2.zip
Sord::Resource => Sord::URI.
Tidy up serialisation code. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2964 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/client/HTTPEngineSender.cpp7
-rw-r--r--src/engine/HTTPClientSender.cpp2
-rw-r--r--src/serialisation/Parser.cpp36
-rw-r--r--src/serialisation/Serialiser.cpp312
-rw-r--r--src/serialisation/Serialiser.hpp3
5 files changed, 163 insertions, 197 deletions
diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp
index ed69d7e0..6468deef 100644
--- a/src/client/HTTPEngineSender.cpp
+++ b/src/client/HTTPEngineSender.cpp
@@ -123,10 +123,9 @@ HTTPEngineSender::put(const URI& uri,
Sord::Model model(_world);
for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i)
- model.add_statement(
- Sord::Resource(_world, path),
- AtomRDF::atom_to_node(model, i->first),
- AtomRDF::atom_to_node(model, i->second));
+ model.add_statement(Sord::URI(_world, path),
+ AtomRDF::atom_to_node(model, i->first),
+ AtomRDF::atom_to_node(model, i->second));
const string str = model.write_to_string("turtle");
SoupMessage* msg = soup_message_new(SOUP_METHOD_PUT, full_uri.c_str());
diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp
index 7068911c..6f1f293a 100644
--- a/src/engine/HTTPClientSender.cpp
+++ b/src/engine/HTTPClientSender.cpp
@@ -62,7 +62,7 @@ HTTPClientSender::put(const URI& uri,
Sord::Model model(*_engine.world()->rdf_world());
for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i)
model.add_statement(
- Sord::Resource(*_engine.world()->rdf_world(), path),
+ Sord::URI(*_engine.world()->rdf_world(), path),
AtomRDF::atom_to_node(model, i->first.str()),
AtomRDF::atom_to_node(model, i->second));
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 2a7423b0..5b04a426 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -99,9 +99,9 @@ Parser::find_patches(Ingen::Shared::World* world,
Sord::Model model(*world->rdf_world(), manifest_uri);
model.load_file(manifest_uri);
- 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");
+ Sord::URI rdf_type(*world->rdf_world(), NS_RDF "type");
+ Sord::URI rdfs_seeAlso(*world->rdf_world(), NS_RDFS "seeAlso");
+ Sord::URI ingen_Patch(*world->rdf_world(), NS_INGEN "Patch");
RDFNodes patches;
for (Sord::Iter i = model.find(nil, rdf_type, ingen_Patch); !i.end(); ++i) {
@@ -196,7 +196,7 @@ Parser::parse_string(Ingen::Shared::World* world,
info << endl;
bool ret = parse(world, target, model, base_uri, data_path, parent, symbol, data);
- Sord::Resource subject(*world->rdf_world(), base_uri);
+ Sord::URI subject(*world->rdf_world(), base_uri);
parse_connections(world, target, model, subject, parent ? *parent : "/");
return ret;
@@ -246,7 +246,7 @@ Parser::parse_update(Ingen::Shared::World* world,
}
// Connections
- Sord::Resource subject(*world->rdf_world(), base_uri);
+ Sord::URI subject(*world->rdf_world(), base_uri);
parse_connections(world, target, model, subject, "/");
// Port values
@@ -279,9 +279,9 @@ Parser::parse(Ingen::Shared::World* world,
boost::optional<Raul::Symbol> symbol,
boost::optional<GraphObject::Properties> data)
{
- const Sord::Node::Type res = Sord::Node::RESOURCE;
+ const Sord::Node::Type res = Sord::Node::URI;
- const Sord::Resource rdf_type(*world->rdf_world(), NS_RDF "type");
+ const Sord::URI rdf_type(*world->rdf_world(), NS_RDF "type");
const Sord::Node patch_class (*world->rdf_world(), res, NS_INGEN "Patch");
const Sord::Node node_class (*world->rdf_world(), res, NS_INGEN "Node");
@@ -380,9 +380,9 @@ Parser::parse_patch(Ingen::Shared::World* world,
{
const LV2URIMap& uris = *world->uris().get();
- 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");
+ Sord::URI ingen_polyphony(*world->rdf_world(), NS_INGEN "polyphony");
+ Sord::URI lv2_port(*world->rdf_world(), NS_LV2 "port");
+ Sord::URI lv2_symbol(*world->rdf_world(), NS_LV2 "symbol");
const Sord::Node& patch = subject_node;
@@ -437,9 +437,9 @@ Parser::parse_patch(Ingen::Shared::World* world,
props.insert(make_pair(uris.ingen_polyphony, Raul::Atom(int32_t(patch_poly))));
target->put(patch_path, props);
- 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");
+ Sord::URI rdf_type(*world->rdf_world(), NS_RDF "type");
+ Sord::URI ingen_Patch(*world->rdf_world(), NS_INGEN "Patch");
+ Sord::URI ingen_node(*world->rdf_world(), NS_INGEN "node");
typedef multimap<Raul::URI, Raul::Atom> Properties;
typedef map<string, Sord::Node> Resources;
@@ -569,7 +569,7 @@ Parser::parse_node(Ingen::Shared::World* world,
{
const LV2URIMap& uris = *world->uris().get();
- Sord::Resource rdf_instanceOf(*world->rdf_world(), NS_RDF "instanceOf");
+ Sord::URI rdf_instanceOf(*world->rdf_world(), NS_RDF "instanceOf");
/* Get plugin */
Sord::Iter i = model.find(subject, rdf_instanceOf, nil);
@@ -579,7 +579,7 @@ Parser::parse_node(Ingen::Shared::World* world,
}
const Sord::Node& plugin_node = i.get_object();
- if (plugin_node.type() != Sord::Node::RESOURCE) {
+ if (plugin_node.type() != Sord::Node::URI) {
LOG(error) << "Node's rdf:instanceOf property is not a resource" << endl;
return boost::optional<Path>();
}
@@ -602,9 +602,9 @@ Parser::parse_connections(Ingen::Shared::World* world,
const Sord::Node& subject,
const Raul::Path& parent)
{
- 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");
+ Sord::URI ingen_connection(*world->rdf_world(), NS_INGEN "connection");
+ Sord::URI ingen_source(*world->rdf_world(), NS_INGEN "source");
+ Sord::URI ingen_destination(*world->rdf_world(), NS_INGEN "destination");
const Glib::ustring& base_uri = model.base_uri().to_string();
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index a3952343..1ffe07c8 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -57,6 +57,8 @@
#define LOG(s) s << "[Serialiser] "
+#define NS_LV2 "http://lv2plug.in/ns/lv2core#"
+
using namespace std;
using namespace Raul;
using namespace Sord;
@@ -91,11 +93,7 @@ static
std::string
uri_to_symbol(const std::string& uri)
{
- string symbol = uri;
- symbol = symbol.substr(symbol.find_last_of("/") + 1);
- symbol = symbol.substr(0, symbol.find("."));
- symbol = Path::nameify(symbol);
- return symbol;
+ return Path::nameify(Glib::path_get_basename(Glib::filename_from_uri(uri)));
}
void
@@ -105,28 +103,25 @@ Serialiser::write_manifest(const std::string& bundle_uri,
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::Resource subject(_model->world(), filename);
- _model->add_statement(
- subject,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "ingen:Patch"));
- _model->add_statement(
- subject,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "lv2:Plugin"));
- _model->add_statement(
- subject,
- Sord::Curie(_model->world(), "rdfs:seeAlso"),
- Sord::Resource(_model->world(), filename));
+ 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(_model->world(), "lv2:binary"),
- Sord::Resource(_model->world(),
- Glib::Module::build_path("", "ingen_lv2")));
+ 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());
}
@@ -163,13 +158,13 @@ Serialiser::to_string(SharedPtr<GraphObject> object,
start_to_string(object->path(), base_uri);
serialise(object);
- Sord::Resource base_rdf_node(_model->world(), base_uri);
- for (GraphObject::Properties::const_iterator v = extra_rdf.begin(); v != extra_rdf.end(); ++v) {
+ Sord::URI 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(
- base_rdf_node,
- AtomRDF::atom_to_node(*_model, v->first),
- AtomRDF::atom_to_node(*_model, v->second));
+ _model->add_statement(base_rdf_node,
+ AtomRDF::atom_to_node(*_model, v->first),
+ AtomRDF::atom_to_node(*_model, v->second));
} else {
LOG(warn) << "Not serialising extra RDF with key '" << v->first << "'" << endl;
}
@@ -243,19 +238,11 @@ Serialiser::finish()
}
Sord::Node
-Serialiser::instance_rdf_node(const Path& path)
+Serialiser::path_rdf_node(const Path& path)
{
assert(_model);
assert(path.is_child_of(_root_path));
- return Sord::Resource(_model->world(), path.chop_scheme().substr(1));
-}
-
-Sord::Node
-Serialiser::class_rdf_node(const Path& path)
-{
- assert(_model);
- assert(path.is_child_of(_root_path));
- return Sord::Resource(_model->world(), path.chop_scheme().substr(1));
+ return Sord::URI(_model->world(), path.chop_scheme().substr(1));
}
void
@@ -267,27 +254,27 @@ 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 Sord::Resource patch_id(_model->world(), "");
+ const Sord::URI patch_id(_model->world(), "");
serialise_patch(patch, patch_id);
} else {
- const Sord::Resource patch_id(_model->world(),
- string(META_PREFIX) + patch->path().chop_start("/"));
+ const Sord::URI 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()));
+ serialise_node(patch, patch_id, path_rdf_node(patch->path()));
}
return;
}
SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(object);
if (node) {
- const Sord::Resource plugin_id(_model->world(), node->plugin()->uri().str());
- serialise_node(node, plugin_id, instance_rdf_node(node->path()));
+ const Sord::URI plugin_id(_model->world(), node->plugin()->uri().str());
+ serialise_node(node, plugin_id, path_rdf_node(node->path()));
return;
}
SharedPtr<Shared::Port> port = PtrCast<Shared::Port>(object);
if (port) {
- serialise_port(port.get(), instance_rdf_node(port->path()));
+ serialise_port(port.get(), path_rdf_node(port->path()));
return;
}
@@ -299,16 +286,15 @@ void
Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& patch_id)
{
assert(_model);
+ Sord::World& world = _model->world();
- _model->add_statement(
- patch_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "ingen:Patch"));
+ _model->add_statement(patch_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "ingen:Patch"));
- _model->add_statement(
- patch_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "lv2:Plugin"));
+ _model->add_statement(patch_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "lv2:Plugin"));
const LV2URIMap& uris = *_world.uris().get();
@@ -323,17 +309,16 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& pa
_model->add_statement(
patch_id,
AtomRDF::atom_to_node(*_model, uris.lv2_symbol.c_str()),
- Sord::Literal(_model->world(), symbol));
+ Sord::Literal(world, symbol));
} else {
symbol = s->second.get_string();
}
// If the patch has no doap:name (required by LV2), use the symbol
if (patch->meta().properties().find(uris.doap_name) == patch->meta().properties().end())
- _model->add_statement(
- patch_id,
- AtomRDF::atom_to_node(*_model, uris.doap_name),
- Sord::Literal(_model->world(), symbol));
+ _model->add_statement(patch_id,
+ AtomRDF::atom_to_node(*_model, uris.doap_name),
+ Sord::Literal(world, symbol));
serialise_properties(patch_id, NULL, patch->meta().properties());
@@ -346,22 +331,20 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& pa
SharedPtr<Shared::Patch> subpatch = PtrCast<Shared::Patch>(n->second);
SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(n->second);
if (subpatch) {
- const Sord::Resource class_id(_model->world(),
- string(META_PREFIX) + subpatch->path().chop_start("/"));
- const Sord::Node node_id(instance_rdf_node(n->second->path()));
- _model->add_statement(
- patch_id,
- Sord::Curie(_model->world(), "ingen:node"),
- node_id);
+ const Sord::URI class_id(world,
+ string(META_PREFIX) + subpatch->path().chop_start("/"));
+ const Sord::Node node_id(path_rdf_node(n->second->path()));
+ _model->add_statement(patch_id,
+ Sord::Curie(world, "ingen:node"),
+ node_id);
serialise_patch(subpatch, class_id);
serialise_node(subpatch, class_id, node_id);
} else if (node) {
- 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,
- Sord::Curie(_model->world(), "ingen:node"),
- node_id);
+ const Sord::URI class_id(world, node->plugin()->uri().str());
+ const Sord::Node node_id(path_rdf_node(n->second->path()));
+ _model->add_statement(patch_id,
+ Sord::Curie(world, "ingen:node"),
+ node_id);
serialise_node(node, class_id, node_id);
}
}
@@ -370,18 +353,15 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Sord::Node& pa
for (uint32_t i=0; i < patch->num_ports(); ++i) {
Port* p = patch->port(i);
- const Sord::Node port_id = root
- ? instance_rdf_node(p->path())
- : class_rdf_node(p->path());
+ const Sord::Node port_id = path_rdf_node(p->path());
// Ensure lv2:name always exists so Patch is a valid LV2 plugin
- if (p->properties().find("http://lv2plug.in/ns/lv2core#name") == p->properties().end())
- p->set_property("http://lv2plug.in/ns/lv2core#name", Atom(p->symbol().c_str()));
+ if (p->properties().find(NS_LV2 "name") == p->properties().end())
+ p->set_property(NS_LV2 "name", Atom(p->symbol().c_str()));
- _model->add_statement(
- patch_id,
- Sord::Resource(_model->world(), "http://lv2plug.in/ns/lv2core#port"),
- port_id);
+ _model->add_statement(patch_id,
+ Sord::URI(world, NS_LV2 "port"),
+ port_id);
serialise_port_meta(p, port_id);
if (root)
serialise_properties(port_id, &p->meta(), p->properties());
@@ -398,12 +378,11 @@ Serialiser::serialise_plugin(const Shared::Plugin& plugin)
{
assert(_model);
- const Sord::Node plugin_id = Sord::Resource(_model->world(), plugin.uri().str());
+ const Sord::Node plugin_id = Sord::URI(_model->world(), plugin.uri().str());
- _model->add_statement(
- plugin_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Resource(_model->world(), plugin.type_uri().str()));
+ _model->add_statement(plugin_id,
+ Sord::Curie(_model->world(), "rdf:type"),
+ Sord::URI(_model->world(), plugin.type_uri().str()));
}
void
@@ -411,29 +390,25 @@ Serialiser::serialise_node(SharedPtr<Shared::Node> node,
const Sord::Node& class_id,
const Sord::Node& node_id)
{
- _model->add_statement(
- node_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "ingen:Node"));
- _model->add_statement(
- node_id,
- Sord::Curie(_model->world(), "rdf:instanceOf"),
- class_id);
- _model->add_statement(
- node_id,
- Sord::Curie(_model->world(), "lv2:symbol"),
- Sord::Literal(_model->world(), node->path().symbol()));
+ _model->add_statement(node_id,
+ Sord::Curie(_model->world(), "rdf:type"),
+ Sord::Curie(_model->world(), "ingen:Node"));
+ _model->add_statement(node_id,
+ Sord::Curie(_model->world(), "rdf:instanceOf"),
+ class_id);
+ _model->add_statement(node_id,
+ 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 Sord::Node port_id = instance_rdf_node(p->path());
+ for (uint32_t i = 0; i < node->num_ports(); ++i) {
+ Port* const p = node->port(i);
+ const Sord::Node port_id = path_rdf_node(p->path());
serialise_port(p, port_id);
- _model->add_statement(
- node_id,
- Sord::Curie(_model->world(), "lv2:port"),
- port_id);
+ _model->add_statement(node_id,
+ Sord::Curie(_model->world(), "lv2:port"),
+ port_id);
}
}
@@ -441,34 +416,33 @@ Serialiser::serialise_node(SharedPtr<Shared::Node> node,
void
Serialiser::serialise_port(const Port* port, const Sord::Node& port_id)
{
+ Sord::World& world = _model->world();
+
if (port->is_input())
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "lv2:InputPort"));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "lv2:InputPort"));
else
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "lv2:OutputPort"));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "lv2:OutputPort"));
for (Port::PortTypes::const_iterator i = port->types().begin();
i != port->types().end(); ++i)
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Resource(_model->world(), i->uri().str()));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::URI(world, i->uri().str()));
+ /*
if (dynamic_cast<Patch*>(port->graph_parent()))
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:instanceOf"),
- class_rdf_node(port->path()));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:instanceOf"),
+ class_rdf_node(port->path()));
+ */
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "lv2:symbol"),
- Sord::Literal(_model->world(), port->path().symbol()));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "lv2:symbol"),
+ Sord::Literal(world, port->path().symbol()));
serialise_properties(port_id, &port->meta(), port->properties());
}
@@ -477,41 +451,40 @@ Serialiser::serialise_port(const Port* port, const Sord::Node& port_id)
void
Serialiser::serialise_port_meta(const Port* port, const Sord::Node& port_id)
{
+ Sord::World& world = _model->world();
+
if (port->is_input())
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "lv2:InputPort"));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "lv2:InputPort"));
else
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "lv2:OutputPort"));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "lv2:OutputPort"));
for (Port::PortTypes::const_iterator i = port->types().begin();
i != port->types().end(); ++i)
- _model->add_statement(
- port_id,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Resource(_model->world(), i->uri().str()));
+ _model->add_statement(port_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::URI(world, i->uri().str()));
_model->add_statement(
port_id,
- Sord::Curie(_model->world(), "lv2:index"),
+ Sord::Curie(world, "lv2:index"),
AtomRDF::atom_to_node(*_model, Atom((int)port->index())));
_model->add_statement(
port_id,
- Sord::Curie(_model->world(), "lv2:symbol"),
- Sord::Literal(_model->world(), port->path().symbol()));
+ Sord::Curie(world, "lv2:symbol"),
+ Sord::Literal(world, port->path().symbol()));
- if (!port->get_property("http://lv2plug.in/ns/lv2core#default").is_valid()) {
+ if (!port->get_property(NS_LV2 "default").is_valid()) {
if (port->is_input()) {
if (port->value().is_valid()) {
_model->add_statement(
port_id,
- Sord::Curie(_model->world(), "lv2:default"),
- AtomRDF::atom_to_node(*_model, Atom(port->value())));
+ Sord::Curie(world, "lv2:default"),
+ AtomRDF::atom_to_node(*_model, port->value()));
} else if (port->is_a(PortType::CONTROL)) {
LOG(warn) << "Port " << port->path() << " has no lv2:default" << endl;
}
@@ -525,38 +498,33 @@ void
Serialiser::serialise_connection(SharedPtr<GraphObject> parent,
SharedPtr<Connection> connection) throw (std::logic_error)
{
- if (!_model)
- throw std::logic_error("serialise_connection called without serialization in progress");
-
- bool top = (parent->path() == _root_path);
- const Sord::Node src_node = top
- ? instance_rdf_node(connection->src_port_path())
- : class_rdf_node(connection->src_port_path());
- const Sord::Node dst_node = top
- ? instance_rdf_node(connection->dst_port_path())
- : class_rdf_node(connection->dst_port_path());
+ Sord::World& world = _model->world();
- const Sord::Node connection_node = Sord::Node::blank_id(*_world.rdf_world());
- _model->add_statement(
- connection_node,
- Sord::Curie(_model->world(), "ingen:source"),
- src_node);
- _model->add_statement(
- connection_node,
- Sord::Curie(_model->world(), "ingen:destination"),
- dst_node);
+ if (!_model)
+ throw std::logic_error(
+ "serialise_connection called without serialization in progress");
+
+ const Sord::Node src = path_rdf_node(connection->src_port_path());
+ const Sord::Node dst = path_rdf_node(connection->dst_port_path());
+ const Sord::Node connection_id = Sord::Node::blank_id(*_world.rdf_world());
+ _model->add_statement(connection_id,
+ Sord::Curie(world, "ingen:source"),
+ src);
+ _model->add_statement(connection_id,
+ Sord::Curie(world, "ingen:destination"),
+ dst);
+ /*
if (parent) {
- const Sord::Node parent_node = class_rdf_node(parent->path());
- _model->add_statement(
- parent_node,
- Sord::Curie(_model->world(), "ingen:connection"),
- connection_node);
+ const Sord::Node parent_id = class_rdf_node(parent->path());
+ _model->add_statement(parent_id,
+ Sord::Curie(world, "ingen:connection"),
+ connection_id);
} else {
- _model->add_statement(
- connection_node,
- Sord::Curie(_model->world(), "rdf:type"),
- Sord::Curie(_model->world(), "ingen:Connection"));
- }
+ */
+ _model->add_statement(connection_id,
+ Sord::Curie(world, "rdf:type"),
+ Sord::Curie(world, "ingen:Connection"));
+ //}
}
void
@@ -568,8 +536,8 @@ Serialiser::serialise_properties(Sord::Node subject,
v != properties.end(); ++v) {
if (v->second.is_valid()) {
if (!meta || !meta->has_property(v->first.str(), v->second)) {
- const Sord::Resource key(_model->world(), v->first.str());
- const Sord::Node value(AtomRDF::atom_to_node(*_model, v->second));
+ const Sord::URI 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 650e48e7..7fc641f6 100644
--- a/src/serialisation/Serialiser.hpp
+++ b/src/serialisation/Serialiser.hpp
@@ -105,8 +105,7 @@ private:
const Shared::Resource* meta,
const Properties& properties);
- Sord::Node instance_rdf_node(const Raul::Path& path);
- Sord::Node class_rdf_node(const Raul::Path& path);
+ Sord::Node path_rdf_node(const Raul::Path& path);
Raul::Path _root_path;
SharedPtr<Shared::Store> _store;