summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-05-28 01:38:34 +0000
committerDavid Robillard <d@drobilla.net>2009-05-28 01:38:34 +0000
commitc9a25fcc6150290790457f837355735b513b7239 (patch)
tree0b234edf54525fe2e7883ffe6c10b5e15788065c /src
parent2f595631859574bfa7779ebb42f42b8590f5424c (diff)
downloadingen-c9a25fcc6150290790457f837355735b513b7239.tar.gz
ingen-c9a25fcc6150290790457f837355735b513b7239.tar.bz2
ingen-c9a25fcc6150290790457f837355735b513b7239.zip
Fix QNAMEs being serialised as URIs.
Remove vestigial variable stuff. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2017 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/client/NodeModel.cpp4
-rw-r--r--src/client/ObjectModel.cpp34
-rw-r--r--src/client/ObjectModel.hpp8
-rw-r--r--src/client/PatchModel.cpp2
-rw-r--r--src/client/PortModel.cpp2
-rw-r--r--src/engine/Engine.cpp6
-rw-r--r--src/engine/HTTPClientSender.cpp6
-rw-r--r--src/engine/events/CreatePatchEvent.cpp2
-rw-r--r--src/gui/NewSubpatchWindow.cpp2
-rw-r--r--src/gui/NodeModule.cpp2
-rw-r--r--src/gui/PatchPortModule.cpp8
-rw-r--r--src/gui/PatchView.cpp8
-rw-r--r--src/gui/PatchWindow.cpp17
-rw-r--r--src/gui/UploadPatchWindow.cpp2
-rw-r--r--src/ingen/main.cpp1
-rw-r--r--src/serialisation/Parser.cpp2
-rw-r--r--src/serialisation/Serialiser.cpp55
-rw-r--r--src/shared/ResourceImpl.cpp2
18 files changed, 58 insertions, 105 deletions
diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp
index 3f5773b0..c4ddbbaf 100644
--- a/src/client/NodeModel.cpp
+++ b/src/client/NodeModel.cpp
@@ -199,8 +199,8 @@ NodeModel::port_value_range(SharedPtr<PortModel> port, float& min, float& max) c
#endif
// Possibly overriden
- const Atom& min_atom = port->get_variable("lv2:minimum");
- const Atom& max_atom = port->get_variable("lv2:maximum");
+ const Atom& min_atom = port->get_property("lv2:minimum");
+ const Atom& max_atom = port->get_property("lv2:maximum");
if (min_atom.type() == Atom::FLOAT)
min = min_atom.get_float();
if (max_atom.type() == Atom::FLOAT)
diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp
index 367237c0..af0473a9 100644
--- a/src/client/ObjectModel.cpp
+++ b/src/client/ObjectModel.cpp
@@ -40,44 +40,18 @@ ObjectModel::~ObjectModel()
}
-/** Get a variable for this object.
- *
- * @return Metadata value with key @a key, empty string otherwise.
- */
const Atom&
-ObjectModel::get_variable(const URI& key) const
-{
- static const Atom null_atom;
-
- Properties::const_iterator i = _variables.find(key);
- if (i != _variables.end())
- return i->second;
- else
- return null_atom;
-}
-
-
-/** Get a variable for this object.
- *
- * @return Metadata value with key @a key, empty string otherwise.
- */
-Atom&
-ObjectModel::get_variable(URI& key)
+ObjectModel::get_property(const Raul::URI& key) const
{
- static Atom null_atom;
-
- Properties::iterator i = _variables.find(key);
- if (i != _variables.end())
- return i->second;
- else
- return null_atom;
+ Resource::Properties::const_iterator i = properties().find(key);
+ return (i != properties().end()) ? i->second : _meta.get_property(key);
}
bool
ObjectModel::polyphonic() const
{
- const Raul::Atom& polyphonic = get_variable("ingen:polyphonic");
+ const Raul::Atom& polyphonic = get_property("ingen:polyphonic");
return (polyphonic.is_valid() && polyphonic.get_bool());
}
diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp
index 321555fd..5029f024 100644
--- a/src/client/ObjectModel.hpp
+++ b/src/client/ObjectModel.hpp
@@ -54,8 +54,7 @@ class ObjectModel : virtual public Ingen::Shared::GraphObject
public:
virtual ~ObjectModel();
- const Raul::Atom& get_variable(const Raul::URI& key) const;
- Raul::Atom& get_variable(Raul::URI& key);
+ const Raul::Atom& get_property(const Raul::URI& key) const;
virtual void set_property(const Raul::URI& key, const Raul::Atom& value) {
ResourceImpl::set_property(key, value);
@@ -69,8 +68,7 @@ public:
Resource& meta() { return _meta; }
const Resource& meta() const { return _meta; }
- const Properties& variables() const { return _variables; }
- Properties& variables() { return _variables; }
+ const Raul::URI meta_uri() const { return _meta.uri(); }
const Raul::Path path() const { return _path; }
const Raul::Symbol symbol() const { return _path.name(); }
SharedPtr<ObjectModel> parent() const { return _parent; }
@@ -100,8 +98,6 @@ protected:
ResourceImpl _meta;
Raul::Path _path;
SharedPtr<ObjectModel> _parent;
-
- Properties _variables;
};
diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp
index b64b9e50..baaa36ba 100644
--- a/src/client/PatchModel.cpp
+++ b/src/client/PatchModel.cpp
@@ -164,7 +164,7 @@ PatchModel::remove_connection(const Path& src_port_path, const Path& dst_port_pa
bool
PatchModel::enabled() const
{
- const Raul::Atom& enabled = get_variable("ingen:enabled");
+ const Raul::Atom& enabled = get_property("ingen:enabled");
return (enabled.is_valid() && enabled.get_bool());
}
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index 4fc6654b..9d63c863 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.cpp
@@ -24,7 +24,7 @@ namespace Client {
bool
PortModel::has_hint(const std::string& qname) const
{
- const Raul::Atom& hint = get_variable(qname);
+ const Raul::Atom& hint = get_property(qname);
return (hint.is_valid() && hint.get_bool() > 0);
}
diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp
index 4d697b5e..120433fb 100644
--- a/src/engine/Engine.cpp
+++ b/src/engine/Engine.cpp
@@ -190,9 +190,9 @@ Engine::activate(size_t parallelism)
if (!root_patch) {
root_patch = new PatchImpl(*this, "", 1, NULL,
_audio_driver->sample_rate(), _audio_driver->buffer_size(), 1);
- root_patch->add_property("rdf:type", Raul::Atom(Raul::Atom::URI, "ingen:Patch"));
- root_patch->add_property("rdf:type", Raul::Atom(Raul::Atom::URI, "ingen:Node"));
- root_patch->set_property("ingen:polyphony", Raul::Atom(int32_t(1)));
+ root_patch->meta().set_property("rdf:type", Raul::Atom(Raul::Atom::URI, "ingen:Patch"));
+ root_patch->meta().set_property("ingen:polyphony", Raul::Atom(int32_t(1)));
+ root_patch->set_property("rdf:type", Raul::Atom(Raul::Atom::URI, "ingen:Node"));
root_patch->activate();
_world->store->add(root_patch);
root_patch->compiled_patch(root_patch->compile());
diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp
index fa6421b9..41f517cb 100644
--- a/src/engine/HTTPClientSender.cpp
+++ b/src/engine/HTTPClientSender.cpp
@@ -77,8 +77,7 @@ HTTPClientSender::connect(const Path& src_path, const Path& dst_path)
{
const string msg = string(
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"
- "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n"
- "@prefix lv2var: <http://lv2plug.in/ns/ext/instance-var#> .\n\n<").append(
+ "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n").append(
"<> ingen:connection [\n"
"\tingen:destination <").append(dst_path.str()).append("> ;\n"
"\tingen:source <").append(src_path.str()).append(">\n] .\n");
@@ -100,8 +99,7 @@ HTTPClientSender::set_property(const URI& subject, const URI& key, const Atom& v
const string msg = string(
"@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"
"@prefix ingen: <http://drobilla.net/ns/ingen#> .\n"
- "@prefix ingenuity: <http://drobilla.net/ns/ingenuity#> .\n"
- "@prefix lv2var: <http://lv2plug.in/ns/ext/instance-var#> .\n\n<").append(
+ "@prefix ingenuity: <http://drobilla.net/ns/ingenuity#> .\n").append(
subject.str()).append("> ingen:property [\n"
"rdf:predicate ").append(key.str()).append(" ;\n"
"rdf:value ").append(node.to_string()).append("\n] .\n");
diff --git a/src/engine/events/CreatePatchEvent.cpp b/src/engine/events/CreatePatchEvent.cpp
index 16f749a3..ccb4f887 100644
--- a/src/engine/events/CreatePatchEvent.cpp
+++ b/src/engine/events/CreatePatchEvent.cpp
@@ -84,8 +84,8 @@ CreatePatchEvent::pre_process()
_patch = new PatchImpl(_engine, path.name(), poly, _parent, _engine.audio_driver()->sample_rate(), _engine.audio_driver()->buffer_size(), _poly);
_patch->meta().properties().insert(_properties.begin(), _properties.end());
+ _patch->meta().set_property("rdf:type", Atom(Atom::URI, "ingen:Patch"));
_patch->set_property("rdf:type", Atom(Atom::URI, "ingen:Node"));
- _patch->set_property("rdf:instanceOf", Atom(Atom::URI, _patch->meta_uri().str()));
if (_parent != NULL) {
_parent->add_node(new PatchImpl::Nodes::Node(_patch));
diff --git a/src/gui/NewSubpatchWindow.cpp b/src/gui/NewSubpatchWindow.cpp
index 0a0f11f5..3c697d81 100644
--- a/src/gui/NewSubpatchWindow.cpp
+++ b/src/gui/NewSubpatchWindow.cpp
@@ -97,7 +97,7 @@ NewSubpatchWindow::ok_clicked()
Resource::Properties props;
props.insert(make_pair("rdf:type", Atom(Atom::URI, "ingen:Patch")));
props.insert(make_pair("ingen:polyphony", Atom(int32_t(poly))));
- App::instance().engine()->put(path, props);
+ App::instance().engine()->put(ResourceImpl::meta_uri(Path::root_uri, path), props);
for (GraphObject::Properties::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i)
App::instance().engine()->set_property(path, i->first, i->second);
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index b507bba7..b330ab8d 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -92,7 +92,7 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n
else
ret = boost::shared_ptr<NodeModule>(new NodeModule(canvas, node));
- for (GraphObject::Properties::const_iterator m = node->variables().begin(); m != node->variables().end(); ++m)
+ for (GraphObject::Properties::const_iterator m = node->meta().properties().begin(); m != node->meta().properties().end(); ++m)
ret->set_property(m->first, m->second);
for (GraphObject::Properties::const_iterator m = node->properties().begin(); m != node->properties().end(); ++m)
diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp
index bdd93f63..6ceea483 100644
--- a/src/gui/PatchPortModule.cpp
+++ b/src/gui/PatchPortModule.cpp
@@ -62,8 +62,8 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod
ret->set_port(port);
ret->set_menu(port->menu());
- for (GraphObject::Properties::const_iterator m = model->variables().begin();
- m != model->variables().end(); ++m)
+ for (GraphObject::Properties::const_iterator m = model->meta().properties().begin();
+ m != model->meta().properties().end(); ++m)
ret->set_property(m->first, m->second);
for (GraphObject::Properties::const_iterator m = model->properties().begin();
@@ -101,8 +101,8 @@ PatchPortModule::store_location()
if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT
|| existing_x.get_float() != x || existing_y.get_float() != y) {
- App::instance().engine()->set_property(_model->path(), "ingenuity:canvas-x", Atom(x));
- App::instance().engine()->set_property(_model->path(), "ingenuity:canvas-y", Atom(y));
+ App::instance().engine()->set_property(_model->meta_uri(), "ingenuity:canvas-x", Atom(x));
+ App::instance().engine()->set_property(_model->meta_uri(), "ingenuity:canvas-y", Atom(y));
}
}
diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp
index 812c3115..ad62d43e 100644
--- a/src/gui/PatchView.cpp
+++ b/src/gui/PatchView.cpp
@@ -81,12 +81,12 @@ PatchView::set_patch(SharedPtr<PatchModel> patch)
_poly_spin->set_value(patch->poly());
- for (GraphObject::Properties::const_iterator i = patch->properties().begin();
- i != patch->properties().end(); ++i)
+ for (GraphObject::Properties::const_iterator i = patch->meta().properties().begin();
+ i != patch->meta().properties().end(); ++i)
property_changed(i->first, i->second);
- for (GraphObject::Properties::const_iterator i = patch->variables().begin();
- i != patch->variables().end(); ++i)
+ for (GraphObject::Properties::const_iterator i = patch->properties().begin();
+ i != patch->properties().end(); ++i)
property_changed(i->first, i->second);
// Connect model signals to track state
diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp
index 3984c9be..3b5c3f9b 100644
--- a/src/gui/PatchWindow.cpp
+++ b/src/gui/PatchWindow.cpp
@@ -396,14 +396,13 @@ PatchWindow::event_import_location()
void
PatchWindow::event_save()
{
- GraphObject::Properties::const_iterator doc = _patch->variables().find("ingen:document");
- if (doc == _patch->variables().end()) {
+ const Raul::Atom& document = _patch->get_property("ingen:document");
+ if (!document.is_valid() || document.type() != Raul::Atom::URI) {
event_save_as();
} else {
- const Glib::ustring& document_uri = doc->second.get_string();
- App::instance().loader()->save_patch(_patch, document_uri);
+ App::instance().loader()->save_patch(_patch, document.get_uri());
_status_bar->push(
- (boost::format("Wrote %1% to %2%") % _patch->path() % document_uri).str(),
+ (boost::format("Wrote %1% to %2%") % _patch->path() % document.get_uri()).str(),
STATUS_CONTEXT_PATCH);
}
}
@@ -427,9 +426,9 @@ PatchWindow::event_save_as()
dialog.set_filter(filt);
// Set current folder to most sensible default
- GraphObject::Properties::const_iterator doc = _patch->variables().find("ingen:document");
- if (doc != _patch->variables().end())
- dialog.set_uri(doc->second.get_string());
+ const Raul::Atom& document = _patch->get_property("ingen:document");
+ if (document.type() == Raul::Atom::URI)
+ dialog.set_uri(document.get_uri());
else if (App::instance().configuration()->patch_folder().length() > 0)
dialog.set_current_folder(App::instance().configuration()->patch_folder());
@@ -477,7 +476,7 @@ PatchWindow::event_save_as()
if (confirm) {
const Glib::ustring uri = Glib::filename_to_uri(filename);
App::instance().loader()->save_patch(_patch, uri);
- _patch->set_property("ingen:document", Atom(uri.c_str()));
+ _patch->set_property("ingen:document", Atom(Atom::URI, uri.c_str()));
_status_bar->push(
(boost::format("Wrote %1% to %2%") % _patch->path() % uri).str(),
STATUS_CONTEXT_PATCH);
diff --git a/src/gui/UploadPatchWindow.cpp b/src/gui/UploadPatchWindow.cpp
index 0057ec18..1d930cb5 100644
--- a/src/gui/UploadPatchWindow.cpp
+++ b/src/gui/UploadPatchWindow.cpp
@@ -79,7 +79,7 @@ UploadPatchWindow::on_show()
if (atom.is_valid())
_symbol_entry->set_text(atom.get_string());
- atom = _patch->get_variable("doap:name");
+ atom = _patch->get_property("doap:name");
if (atom.is_valid())
_short_name_entry->set_text(atom.get_string());
}
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index c49ae668..d3f6d8f0 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -114,7 +114,6 @@ main(int argc, char** argv)
world->rdf_world->add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#");
world->rdf_world->add_prefix("lv2", "http://lv2plug.in/ns/lv2core#");
world->rdf_world->add_prefix("lv2ev", "http://lv2plug.in/ns/ext/event#");
- world->rdf_world->add_prefix("lv2var", "http://lv2plug.in/ns/ext/instance-var#");
world->rdf_world->add_prefix("lv2midi", "http://lv2plug.in/ns/ext/midi");
world->rdf_world->add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
world->rdf_world->add_prefix("owl", "http://www.w3.org/2002/07/owl#");
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index d1e16664..647c90be 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -158,7 +158,7 @@ Parser::parse_document(
= parse(world, target, model, document_uri, data_path, parent, symbol, data);
if (parsed_path) {
- target->set_property(*parsed_path, "ingen:document", Atom(document_uri.c_str()));
+ target->set_property(*parsed_path, "ingen:document", Atom(Atom::URI, document_uri.c_str()));
} else {
cerr << "WARNING: document URI lost" << endl;
}
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 231d19fa..239ce22c 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -316,7 +316,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node&
cerr << "WARNING: Patch has no lv2:symbol" << endl;
}
- serialise_meta_properties(patch_id, patch->properties());
+ serialise_properties(patch_id, patch->meta().properties());
for (GraphObject::const_iterator n = _store->children_begin(patch);
n != _store->children_end(patch); ++n) {
@@ -387,14 +387,14 @@ Serialiser::serialise_node(SharedPtr<Shared::Node> node,
_model->add_statement(node_id, "lv2:symbol",
Redland::Literal(_model->world(), node->path().name()));
+ serialise_properties(node_id, node->properties());
+
for (uint32_t i=0; i < node->num_ports(); ++i) {
Port* p = node->port(i);
const Redland::Node port_id = instance_rdf_node(p->path());
serialise_port(p, port_id);
_model->add_statement(node_id, "lv2:port", port_id);
}
-
- serialise_properties(node_id, node->properties());
}
@@ -452,7 +452,7 @@ Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id)
}
}
- serialise_meta_properties(port_id, port->properties());
+ serialise_properties(port_id, port->meta().properties());
}
@@ -463,8 +463,13 @@ Serialiser::serialise_connection(SharedPtr<GraphObject> parent,
if (!_model)
throw std::logic_error("serialise_connection called without serialization in progress");
- const Redland::Node src_node = class_rdf_node(connection->src_port_path());
- const Redland::Node dst_node = class_rdf_node(connection->dst_port_path());
+ bool top = (parent->path() == _root_path);
+ const Redland::Node src_node = top
+ ? instance_rdf_node(connection->src_port_path())
+ : class_rdf_node(connection->src_port_path());
+ const Redland::Node dst_node = top
+ ? instance_rdf_node(connection->dst_port_path())
+ : class_rdf_node(connection->dst_port_path());
const Redland::Node connection_node = _world.blank_id();
_model->add_statement(connection_node, "ingen:source", src_node);
@@ -480,42 +485,24 @@ Serialiser::serialise_connection(SharedPtr<GraphObject> parent,
void
-Serialiser::serialise_meta_properties(
- Redland::Node subject,
- const GraphObject::Properties& properties)
-{
- for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) {
- if (v->first.find(":") && v->second.is_valid()) {
- const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
- _model->add_statement(subject, v->first.str(), value);
- } else {
- cerr << "Warning: unable to serialize property \'" << v->first << "\'" << endl;
- }
- }
-}
-
-
-void
Serialiser::serialise_properties(
Redland::Node subject,
const GraphObject::Properties& properties)
{
for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) {
- if (v->first.find(":") && v->first.str() != "ingen:document") {
- if (v->second.is_valid()) {
- const Redland::Resource key(_model->world(), v->first.str());
- const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
- if (value.is_valid()) {
- _model->add_statement(subject, key, value);
- } else {
- cerr << "WARNING: can not serialise variable '" << v->first << "' :: "
- << (int)v->second.type() << endl;
- }
+ if (v->second.is_valid()) {
+ const Redland::Resource key(_model->world(), v->first.str());
+ const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
+ if (value.is_valid()) {
+ cerr << "serialise property '" << v->first << "' = " << value << " :: "
+ << (int)v->second.type() << endl;
+ _model->add_statement(subject, key, value);
} else {
- cerr << "WARNING: variable '" << v->first << "' has no value" << endl;
+ cerr << "WARNING: can not serialise variable '" << v->first << "' :: "
+ << (int)v->second.type() << endl;
}
} else {
- cerr << "Not serialising special variable '" << v->first << "'" << endl;
+ cerr << "WARNING: property '" << v->first << "' has no value" << endl;
}
}
}
diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp
index 69d294a4..784c82b8 100644
--- a/src/shared/ResourceImpl.cpp
+++ b/src/shared/ResourceImpl.cpp
@@ -28,7 +28,7 @@ namespace Shared {
const Raul::URI
ResourceImpl::meta_uri(const Raul::URI& base, const Raul::URI& uri)
{
- return string("#") + uri.chop_start("/");
+ return string("meta:#") + uri.chop_start("/");
}