diff options
author | David Robillard <d@drobilla.net> | 2017-03-26 19:47:45 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2017-03-26 19:47:45 +0200 |
commit | 1f58c5f16ab295d1649fbcdf2774fdc1e4b4ea10 (patch) | |
tree | c1b78dc7d6148f1177da57a0585533c00a82ec72 /src/Serialiser.cpp | |
parent | 3c3feab0d385a927e77e75485a6f9c0320c954d3 (diff) | |
download | ingen-1f58c5f16ab295d1649fbcdf2774fdc1e4b4ea10.tar.gz ingen-1f58c5f16ab295d1649fbcdf2774fdc1e4b4ea10.tar.bz2 ingen-1f58c5f16ab295d1649fbcdf2774fdc1e4b4ea10.zip |
Factor out object RDF node construction
Diffstat (limited to 'src/Serialiser.cpp')
-rw-r--r-- | src/Serialiser.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/Serialiser.cpp b/src/Serialiser.cpp index c6d1bb59..3b8ccfbe 100644 --- a/src/Serialiser.cpp +++ b/src/Serialiser.cpp @@ -85,7 +85,9 @@ struct Serialiser::Impl { void write_bundle(SPtr<const Node> graph, const std::string& uri); - Sord::Node path_rdf_node(const Raul::Path& path); + Sord::Node path_rdf_node(const Raul::Path& path) const; + + Sord::Node rdf_node(SPtr<const Node> node) const; void write_manifest(const std::string& bundle_path, SPtr<const Node> graph); @@ -288,7 +290,7 @@ Serialiser::Impl::finish() } Sord::Node -Serialiser::Impl::path_rdf_node(const Raul::Path& path) +Serialiser::Impl::path_rdf_node(const Raul::Path& path) const { assert(_model); assert(path == _root_path || path.is_child_of(_root_path)); @@ -297,6 +299,12 @@ Serialiser::Impl::path_rdf_node(const Raul::Path& path) _base_uri); } +Sord::Node +Serialiser::Impl::rdf_node(const SPtr<const Node> node) const +{ + return path_rdf_node(node->path()); +} + void Serialiser::serialise(SPtr<const Node> object) throw (std::logic_error) { @@ -305,17 +313,17 @@ Serialiser::serialise(SPtr<const Node> object) throw (std::logic_error) const URIs& uris = me->_world.uris(); if (object->has_property(uris.rdf_type, uris.ingen_Graph)) { - me->serialise_graph(object, me->path_rdf_node(object->path())); + me->serialise_graph(object, me->rdf_node(object)); } else if (object->has_property(uris.rdf_type, uris.ingen_Block)) { const Sord::URI plugin_id(me->_model->world(), object->plugin()->uri()); - me->serialise_block(object, plugin_id, me->path_rdf_node(object->path())); + me->serialise_block(object, plugin_id, me->rdf_node(object)); } else if (object->has_property(uris.rdf_type, uris.lv2_InputPort) || object->has_property(uris.rdf_type, uris.lv2_OutputPort)) { me->serialise_port(object, Resource::Graph::DEFAULT, - me->path_rdf_node(object->path())); + me->rdf_node(object)); } else { - me->serialise_properties(me->path_rdf_node(object->path()), + me->serialise_properties(me->rdf_node(object), object->properties()); } } @@ -391,7 +399,7 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph, _model = my_model; // Serialise reference to graph block - const Sord::Node block_id(path_rdf_node(subgraph->path())); + const Sord::Node block_id(rdf_node(subgraph)); _model->add_statement(graph_id, Sord::URI(world, uris.ingen_block), block_id); @@ -400,7 +408,7 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph, const SPtr<const Node> block = n->second; const Sord::URI class_id(world, block->plugin()->uri()); - const Sord::Node block_id(path_rdf_node(n->second->path())); + const Sord::Node block_id(rdf_node(n->second)); _model->add_statement(graph_id, Sord::URI(world, uris.ingen_block), block_id); @@ -412,7 +420,7 @@ Serialiser::Impl::serialise_graph(SPtr<const Node> graph, const SPtr<const Node> p = n->second; // Ensure lv2:name always exists so Graph is a valid LV2 plugin - const Sord::Node port_id(path_rdf_node(p->path())); + const Sord::Node port_id(rdf_node(p)); if (p->properties().find(uris.lv2_name) == p->properties().end()) _model->add_statement(port_id, Sord::URI(world, uris.lv2_name), @@ -477,7 +485,7 @@ Serialiser::Impl::serialise_block(SPtr<const Node> block, if (n->second->has_property(uris.rdf_type, uris.lv2_InputPort) || n->second->has_property(uris.rdf_type, uris.lv2_InputPort)) { const SPtr<const Node> p = n->second; - const Sord::Node port_id = path_rdf_node(p->path()); + const Sord::Node port_id = rdf_node(p); serialise_port(p, Resource::Graph::DEFAULT, port_id); _model->add_statement(block_id, Sord::URI(_model->world(), uris.lv2_port), |