summaryrefslogtreecommitdiffstats
path: root/src/serialisation
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-12 06:59:48 +0000
committerDavid Robillard <d@drobilla.net>2012-03-12 06:59:48 +0000
commit81e9fb3245bd461ebfee4cfa16d1792e48533f9e (patch)
treeeb1b30d79cba70dda9d832100dd7c14b08085b03 /src/serialisation
parente9d9569271ee962c09ab66c6babed1ca5655a6c6 (diff)
downloadingen-81e9fb3245bd461ebfee4cfa16d1792e48533f9e.tar.gz
ingen-81e9fb3245bd461ebfee4cfa16d1792e48533f9e.tar.bz2
ingen-81e9fb3245bd461ebfee4cfa16d1792e48533f9e.zip
Centralise atom creation in forge object.
Aside from being more greppable and making realtime violations more obvious, this is a step towards using LV2 atoms internally (which needs a factory since the type numbers are dynamic). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4054 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r--src/serialisation/Parser.cpp20
-rw-r--r--src/serialisation/Serialiser.cpp5
2 files changed, 15 insertions, 10 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index dfd5bdf6..1477e167 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -102,7 +102,8 @@ skip_property(const Sord::Node& predicate)
}
static Resource::Properties
-get_properties(Sord::Model& model,
+get_properties(Raul::Forge& forge,
+ Sord::Model& model,
const Sord::Node& subject)
{
Resource::Properties props;
@@ -110,7 +111,7 @@ get_properties(Sord::Model& model,
if (!skip_property(i.get_predicate())) {
props.insert(
make_pair(i.get_predicate().to_string(),
- AtomRDF::node_to_atom(model, i.get_object())));
+ AtomRDF::node_to_atom(forge, model, i.get_object())));
}
}
return props;
@@ -128,7 +129,7 @@ get_port(Ingen::Shared::World* world,
const URIs& uris = *world->uris().get();
// Get all properties
- Resource::Properties props = get_properties(model, subject);
+ Resource::Properties props = get_properties(world->forge(), model, subject);
// Get index
Resource::Properties::const_iterator i = props.find(uris.lv2_index);
@@ -252,7 +253,7 @@ parse_node(Ingen::Shared::World* world,
parse_patch(world, target, model, subject,
path.parent(), Raul::Symbol(path.symbol()));
} else {
- Resource::Properties props = get_properties(model, subject);
+ Resource::Properties props = get_properties(world->forge(), model, subject);
props.insert(make_pair(uris.rdf_type,
Raul::URI(uris.ingen_Node)));
target->put(path, props);
@@ -273,6 +274,7 @@ parse_patch(Ingen::Shared::World* world,
const Sord::URI ingen_polyphony(*world->rdf_world(), NS_INGEN "polyphony");
const Sord::URI lv2_port(*world->rdf_world(), NS_LV2 "port");
+ Raul::Forge& forge = world->forge();
const URIs& uris = *world->uris().get();
const Sord::Node& patch = subject_node;
@@ -321,7 +323,7 @@ parse_patch(Ingen::Shared::World* world,
// Create patch
Path patch_path(patch_path_str);
- Resource::Properties props = get_properties(model, subject_node);
+ Resource::Properties props = get_properties(forge, model, subject_node);
target->put(patch_path, props);
// For each node in this patch
@@ -440,8 +442,9 @@ parse_properties(Ingen::Shared::World* world,
const Sord::Node& key = i.get_predicate();
const Sord::Node& val = i.get_object();
if (!skip_property(key)) {
- properties.insert(make_pair(key.to_string(),
- AtomRDF::node_to_atom(model, val)));
+ properties.insert(
+ make_pair(key.to_string(),
+ AtomRDF::node_to_atom(world->forge(), model, val)));
}
}
@@ -531,6 +534,7 @@ parse(Ingen::Shared::World* world,
}
Parser::Parser(Ingen::Shared::World& world)
+ : _world(world)
{
}
@@ -614,7 +618,7 @@ Parser::parse_file(Ingen::Shared::World* world,
if (parsed_path) {
target->set_property(*parsed_path, "http://drobilla.net/ns/ingen#document",
- Atom(Atom::URI, uri.c_str()));
+ world->forge().alloc(Atom::URI, uri.c_str()));
} else {
LOG(warn) << "Document URI lost" << endl;
}
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 1e608806..7f9b8cc3 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -453,7 +453,8 @@ Serialiser::Impl::serialise_patch(SharedPtr<const Patch> patch,
// Ensure lv2:name always exists so Patch is a valid LV2 plugin
if (p->properties().find(NS_LV2 "name") == p->properties().end())
- p->set_property(NS_LV2 "name", Atom(p->symbol().c_str()));
+ p->set_property(NS_LV2 "name",
+ _world.forge().make(p->symbol().c_str()));
_model->add_statement(patch_id,
Sord::URI(world, NS_LV2 "port"),
@@ -521,7 +522,7 @@ Serialiser::Impl::serialise_port(const Port* port,
_model->add_statement(
port_id,
Sord::Curie(world, "lv2:index"),
- AtomRDF::atom_to_node(*_model, Atom((int)port->index())));
+ AtomRDF::atom_to_node(*_model, _world.forge().make((int)port->index())));
}
}