summaryrefslogtreecommitdiffstats
path: root/src/serialisation
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-19 02:57:26 +0000
committerDavid Robillard <d@drobilla.net>2012-08-19 02:57:26 +0000
commitba1f169967f64b9657074fba2de803b29829345c (patch)
treeb46baed3c4d96f2129cb58686b09b2b86d86d05e /src/serialisation
parent800c329a0b77f9044923885abe0728028eca8350 (diff)
downloadingen-ba1f169967f64b9657074fba2de803b29829345c.tar.gz
ingen-ba1f169967f64b9657074fba2de803b29829345c.tar.bz2
ingen-ba1f169967f64b9657074fba2de803b29829345c.zip
GraphObject => Node
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4722 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r--src/serialisation/Parser.cpp94
-rw-r--r--src/serialisation/Serialiser.cpp104
2 files changed, 99 insertions, 99 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 9a5c52ed..e54cb9f2 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -215,12 +215,12 @@ parse_edges(
const Raul::Path& graph);
static boost::optional<Raul::Path>
-parse_block(Ingen::World* world,
- Ingen::Interface* target,
- Sord::Model& model,
- const Sord::Node& subject,
- const Raul::Path& path,
- boost::optional<GraphObject::Properties> data)
+parse_block(Ingen::World* world,
+ Ingen::Interface* target,
+ Sord::Model& model,
+ const Sord::Node& subject,
+ const Raul::Path& path,
+ boost::optional<Node::Properties> data)
{
const URIs& uris = world->uris();
@@ -272,19 +272,19 @@ parse_block(Ingen::World* world,
Resource::Properties props = get_properties(world, model, subject);
props.insert(make_pair(uris.rdf_type,
uris.forge.alloc_uri(uris.ingen_Block)));
- target->put(GraphObject::path_to_uri(path), props);
+ target->put(Node::path_to_uri(path), props);
}
return path;
}
static boost::optional<Raul::Path>
-parse_graph(Ingen::World* world,
- Ingen::Interface* target,
- Sord::Model& model,
- const Sord::Node& subject_node,
- boost::optional<Raul::Path> parent,
- boost::optional<Raul::Symbol> a_symbol,
- boost::optional<GraphObject::Properties> data)
+parse_graph(Ingen::World* world,
+ Ingen::Interface* target,
+ Sord::Model& model,
+ const Sord::Node& subject_node,
+ boost::optional<Raul::Path> parent,
+ boost::optional<Raul::Symbol> a_symbol,
+ boost::optional<Node::Properties> data)
{
URIs& uris = world->uris();
@@ -317,7 +317,7 @@ parse_graph(Ingen::World* world,
// Create graph
Raul::Path graph_path(graph_path_str);
Resource::Properties props = get_properties(world, model, subject_node);
- target->put(GraphObject::path_to_uri(graph_path), props);
+ target->put(Node::path_to_uri(graph_path), props);
// For each block in this graph
for (Sord::Iter n = model.find(subject_node, ingen_block, nil); !n.end(); ++n) {
@@ -327,7 +327,7 @@ parse_graph(Ingen::World* world,
// Parse and create block
parse_block(world, target, model, node, block_path,
- boost::optional<GraphObject::Properties>());
+ boost::optional<Node::Properties>());
// For each port on this block
for (Sord::Iter p = model.find(node, lv2_port, nil); !p.end(); ++p) {
@@ -343,7 +343,7 @@ parse_graph(Ingen::World* world,
}
// Create port and/or set all port properties
- target->put(GraphObject::path_to_uri(port_record->first),
+ target->put(Node::path_to_uri(port_record->first),
port_record->second);
}
}
@@ -369,7 +369,7 @@ parse_graph(Ingen::World* world,
// Create ports in order by index
for (PortRecords::const_iterator i = ports.begin(); i != ports.end(); ++i) {
- target->put(GraphObject::path_to_uri(i->second.first),
+ target->put(Node::path_to_uri(i->second.first),
i->second.second);
}
@@ -449,12 +449,12 @@ parse_edges(Ingen::World* world,
}
static bool
-parse_properties(Ingen::World* world,
- Ingen::Interface* target,
- Sord::Model& model,
- const Sord::Node& subject,
- const Raul::URI& uri,
- boost::optional<GraphObject::Properties> data)
+parse_properties(Ingen::World* world,
+ Ingen::Interface* target,
+ Sord::Model& model,
+ const Sord::Node& subject,
+ const Raul::URI& uri,
+ boost::optional<Node::Properties> data)
{
Resource::Properties properties = get_properties(world, model, subject);
@@ -468,14 +468,14 @@ parse_properties(Ingen::World* world,
}
static boost::optional<Raul::Path>
-parse(Ingen::World* world,
- Ingen::Interface* target,
- Sord::Model& model,
- Glib::ustring document_uri,
- Sord::Node& subject,
- boost::optional<Raul::Path> parent,
- boost::optional<Raul::Symbol> symbol,
- boost::optional<GraphObject::Properties> data)
+parse(Ingen::World* world,
+ Ingen::Interface* target,
+ Sord::Model& model,
+ Glib::ustring document_uri,
+ Sord::Node& subject,
+ boost::optional<Raul::Path> parent,
+ boost::optional<Raul::Symbol> symbol,
+ boost::optional<Node::Properties> data)
{
URIs& uris = world->uris();
@@ -526,7 +526,7 @@ parse(Ingen::World* world,
} else if (types.find(in_port_class) != types.end() ||
types.find(out_port_class) != types.end()) {
parse_properties(
- world, target, model, s, GraphObject::path_to_uri(path), data);
+ world, target, model, s, Node::path_to_uri(path), data);
ret = path;
} else if (types.find(edge_class) != types.end()) {
Raul::Path parent_path(parent ? parent.get() : Raul::Path("/"));
@@ -543,12 +543,12 @@ parse(Ingen::World* world,
* @return whether or not load was successful.
*/
bool
-Parser::parse_file(Ingen::World* world,
- Ingen::Interface* target,
- Glib::ustring path,
- boost::optional<Raul::Path> parent,
- boost::optional<Raul::Symbol> symbol,
- boost::optional<GraphObject::Properties> data)
+Parser::parse_file(Ingen::World* world,
+ Ingen::Interface* target,
+ Glib::ustring path,
+ boost::optional<Raul::Path> parent,
+ boost::optional<Raul::Symbol> symbol,
+ boost::optional<Node::Properties> data)
{
if (Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
// This is a bundle, append "/name.ttl" to get graph file path
@@ -589,7 +589,7 @@ Parser::parse_file(Ingen::World* world,
= parse(world, target, model, path, subject, parent, symbol, data);
if (parsed_path) {
- target->set_property(GraphObject::path_to_uri(*parsed_path),
+ target->set_property(Node::path_to_uri(*parsed_path),
Raul::URI("http://drobilla.net/ns/ingen#document"),
world->forge().alloc_uri(uri));
} else {
@@ -600,13 +600,13 @@ Parser::parse_file(Ingen::World* world,
}
bool
-Parser::parse_string(Ingen::World* world,
- Ingen::Interface* target,
- const Glib::ustring& str,
- const Glib::ustring& base_uri,
- boost::optional<Raul::Path> parent,
- boost::optional<Raul::Symbol> symbol,
- boost::optional<GraphObject::Properties> data)
+Parser::parse_string(Ingen::World* world,
+ Ingen::Interface* target,
+ const Glib::ustring& str,
+ const Glib::ustring& base_uri,
+ boost::optional<Raul::Path> parent,
+ boost::optional<Raul::Symbol> symbol,
+ boost::optional<Node::Properties> data)
{
// Load string into model
Sord::Model model(*world->rdf_world(), base_uri, SORD_SPO|SORD_PSO, false);
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index e1b1548d..ec8ca9d2 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -27,9 +27,9 @@
#include <glibmm/module.h>
#include "ingen/Edge.hpp"
-#include "ingen/GraphObject.hpp"
#include "ingen/Interface.hpp"
#include "ingen/Log.hpp"
+#include "ingen/Node.hpp"
#include "ingen/Plugin.hpp"
#include "ingen/Resource.hpp"
#include "ingen/Store.hpp"
@@ -66,30 +66,30 @@ struct Serialiser::Impl {
void start_to_filename(const std::string& filename);
- void serialise_graph(SharedPtr<const GraphObject> p,
- const Sord::Node& id);
+ void serialise_graph(SharedPtr<const Node> p,
+ const Sord::Node& id);
- void serialise_block(SharedPtr<const GraphObject> n,
- const Sord::Node& class_id,
- const Sord::Node& id);
+ void serialise_block(SharedPtr<const Node> n,
+ const Sord::Node& class_id,
+ const Sord::Node& id);
- void serialise_port(const GraphObject* p,
- Resource::Graph context,
- const Sord::Node& id);
+ void serialise_port(const Node* p,
+ Resource::Graph context,
+ const Sord::Node& id);
void serialise_properties(Sord::Node id,
const Resource::Properties& props);
- void write_bundle(SharedPtr<const GraphObject> graph,
- const std::string& uri);
+ void write_bundle(SharedPtr<const Node> graph,
+ const std::string& uri);
Sord::Node path_rdf_node(const Raul::Path& path);
- void write_manifest(const std::string& bundle_path,
- SharedPtr<const GraphObject> graph,
- const std::string& graph_symbol);
+ void write_manifest(const std::string& bundle_path,
+ SharedPtr<const Node> graph,
+ const std::string& graph_symbol);
- void serialise_edge(const Sord::Node& parent,
+ void serialise_edge(const Sord::Node& parent,
SharedPtr<const Edge> c)
throw (std::logic_error);
@@ -113,8 +113,8 @@ Serialiser::~Serialiser()
}
void
-Serialiser::to_file(SharedPtr<const GraphObject> object,
- const std::string& filename)
+Serialiser::to_file(SharedPtr<const Node> object,
+ const std::string& filename)
{
me->_root_path = object->path();
me->start_to_filename(filename);
@@ -123,9 +123,9 @@ Serialiser::to_file(SharedPtr<const GraphObject> object,
}
void
-Serialiser::Impl::write_manifest(const std::string& bundle_path,
- SharedPtr<const GraphObject> graph,
- const std::string& graph_symbol)
+Serialiser::Impl::write_manifest(const std::string& bundle_path,
+ SharedPtr<const Node> graph,
+ const std::string& graph_symbol)
{
const string manifest_path(Glib::build_filename(bundle_path, "manifest.ttl"));
const string binary_path(Glib::Module::build_path("", "ingen_lv2"));
@@ -158,15 +158,15 @@ Serialiser::Impl::write_manifest(const std::string& bundle_path,
}
void
-Serialiser::write_bundle(SharedPtr<const GraphObject> graph,
- const std::string& path)
+Serialiser::write_bundle(SharedPtr<const Node> graph,
+ const std::string& path)
{
me->write_bundle(graph, path);
}
void
-Serialiser::Impl::write_bundle(SharedPtr<const GraphObject> graph,
- const std::string& a_path)
+Serialiser::Impl::write_bundle(SharedPtr<const Node> graph,
+ const std::string& a_path)
{
std::string path = Glib::filename_from_uri(a_path);
if (Glib::file_test(path, Glib::FILE_TEST_EXISTS)
@@ -195,8 +195,8 @@ Serialiser::Impl::write_bundle(SharedPtr<const GraphObject> graph,
}
string
-Serialiser::to_string(SharedPtr<const GraphObject> object,
- const string& base_uri)
+Serialiser::to_string(SharedPtr<const Node> object,
+ const string& base_uri)
{
start_to_string(object->path(), base_uri);
serialise(object);
@@ -279,17 +279,17 @@ Serialiser::Impl::path_rdf_node(const Raul::Path& path)
}
void
-Serialiser::serialise(SharedPtr<const GraphObject> object) throw (std::logic_error)
+Serialiser::serialise(SharedPtr<const Node> object) throw (std::logic_error)
{
if (!me->_model)
throw std::logic_error("serialise called without serialisation in progress");
- if (object->graph_type() == GraphObject::GRAPH) {
+ if (object->graph_type() == Node::GRAPH) {
me->serialise_graph(object, me->path_rdf_node(object->path()));
- } else if (object->graph_type() == GraphObject::BLOCK) {
+ } else if (object->graph_type() == Node::BLOCK) {
const Sord::URI plugin_id(me->_model->world(), object->plugin()->uri());
me->serialise_block(object, plugin_id, me->path_rdf_node(object->path()));
- } else if (object->graph_type() == GraphObject::PORT) {
+ } else if (object->graph_type() == Node::PORT) {
me->serialise_port(object.get(),
Resource::DEFAULT,
me->path_rdf_node(object->path()));
@@ -300,8 +300,8 @@ Serialiser::serialise(SharedPtr<const GraphObject> object) throw (std::logic_err
}
void
-Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
- const Sord::Node& graph_id)
+Serialiser::Impl::serialise_graph(SharedPtr<const Node> graph,
+ const Sord::Node& graph_id)
{
Sord::World& world = _model->world();
const URIs& uris = _world.uris();
@@ -324,7 +324,7 @@ Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
// Always write a symbol (required by Ingen)
Raul::Symbol symbol("_");
- GraphObject::Properties::const_iterator s = graph->properties().find(uris.lv2_symbol);
+ Node::Properties::const_iterator s = graph->properties().find(uris.lv2_symbol);
if (s == graph->properties().end()
|| !s->second.type() == _world.forge().String
|| !Raul::Symbol::is_valid(s->second.get_string())) {
@@ -345,7 +345,7 @@ Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
Sord::URI(world, uris.doap_name),
Sord::Literal(world, symbol.c_str()));
- const GraphObject::Properties props = graph->properties(Resource::INTERNAL);
+ const Node::Properties props = graph->properties(Resource::INTERNAL);
serialise_properties(graph_id, props);
const Store::const_range kids = _world.store()->children_range(graph);
@@ -353,8 +353,8 @@ Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
if (n->first.parent() != graph->path())
continue;
- if (n->second->graph_type() == GraphObject::GRAPH) {
- SharedPtr<GraphObject> subgraph = n->second;
+ if (n->second->graph_type() == Node::GRAPH) {
+ SharedPtr<Node> subgraph = n->second;
SerdURI base_uri;
serd_uri_parse((const uint8_t*)_base_uri.c_str(), &base_uri);
@@ -386,8 +386,8 @@ Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
Sord::URI(world, uris.ingen_block),
block_id);
serialise_block(subgraph, subgraph_id, block_id);
- } else if (n->second->graph_type() == GraphObject::BLOCK) {
- SharedPtr<const GraphObject> block = n->second;
+ } else if (n->second->graph_type() == Node::BLOCK) {
+ SharedPtr<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()));
@@ -399,7 +399,7 @@ Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
}
for (uint32_t i = 0; i < graph->num_ports(); ++i) {
- GraphObject* p = graph->port(i);
+ Node* p = graph->port(i);
const Sord::Node port_id = path_rdf_node(p->path());
// Ensure lv2:name always exists so Graph is a valid LV2 plugin
@@ -413,16 +413,16 @@ Serialiser::Impl::serialise_graph(SharedPtr<const GraphObject> graph,
serialise_port(p, Resource::INTERNAL, port_id);
}
- for (GraphObject::Edges::const_iterator c = graph->edges().begin();
+ for (Node::Edges::const_iterator c = graph->edges().begin();
c != graph->edges().end(); ++c) {
serialise_edge(graph_id, c->second);
}
}
void
-Serialiser::Impl::serialise_block(SharedPtr<const GraphObject> block,
- const Sord::Node& class_id,
- const Sord::Node& block_id)
+Serialiser::Impl::serialise_block(SharedPtr<const Node> block,
+ const Sord::Node& class_id,
+ const Sord::Node& block_id)
{
const URIs& uris = _world.uris();
@@ -436,11 +436,11 @@ Serialiser::Impl::serialise_block(SharedPtr<const GraphObject> block,
Sord::URI(_model->world(), uris.lv2_symbol),
Sord::Literal(_model->world(), block->path().symbol()));
- const GraphObject::Properties props = block->properties(Resource::EXTERNAL);
+ const Node::Properties props = block->properties(Resource::EXTERNAL);
serialise_properties(block_id, props);
for (uint32_t i = 0; i < block->num_ports(); ++i) {
- GraphObject* const p = block->port(i);
+ Node* const p = block->port(i);
const Sord::Node port_id = path_rdf_node(p->path());
serialise_port(p, Resource::EXTERNAL, port_id);
_model->add_statement(block_id,
@@ -450,9 +450,9 @@ Serialiser::Impl::serialise_block(SharedPtr<const GraphObject> block,
}
void
-Serialiser::Impl::serialise_port(const GraphObject* port,
- Resource::Graph context,
- const Sord::Node& port_id)
+Serialiser::Impl::serialise_port(const Node* port,
+ Resource::Graph context,
+ const Sord::Node& port_id)
{
URIs& uris = _world.uris();
Sord::World& world = _model->world();
@@ -461,7 +461,7 @@ Serialiser::Impl::serialise_port(const GraphObject* port,
Sord::URI(world, uris.lv2_symbol),
Sord::Literal(world, port->path().symbol()));
- GraphObject::Properties props = port->properties(context);
+ Node::Properties props = port->properties(context);
if (context == Resource::INTERNAL &&
port->has_property(uris.rdf_type, uris.lv2_ControlPort) &&
port->has_property(uris.rdf_type, uris.lv2_InputPort))
@@ -525,8 +525,8 @@ skip_property(const Sord::Node& predicate)
}
void
-Serialiser::Impl::serialise_properties(Sord::Node id,
- const GraphObject::Properties& props)
+Serialiser::Impl::serialise_properties(Sord::Node id,
+ const Node::Properties& props)
{
LV2_URID_Unmap* unmap = &_world.uri_map().urid_unmap_feature()->urid_unmap;
SerdNode base = serd_node_from_string(SERD_URI,
@@ -540,7 +540,7 @@ Serialiser::Impl::serialise_properties(Sord::Node id,
sratom_set_pretty_numbers(_sratom, true);
- typedef GraphObject::Properties::const_iterator iterator;
+ typedef Node::Properties::const_iterator iterator;
for (iterator v = props.begin(); v != props.end(); ++v) {
const Sord::URI key(_model->world(), v->first);
if (!skip_property(key)) {