summaryrefslogtreecommitdiffstats
path: root/src/serialisation
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-01-29 07:58:13 +0000
committerDavid Robillard <d@drobilla.net>2010-01-29 07:58:13 +0000
commitf02ac2f82a0342c3e548a81950734b4bce383b7d (patch)
tree06a51f5be2d41bdd8a52f1a6f8888f5f4d3db5f5 /src/serialisation
parent96613df7830699dbbfb5c2d9fe3ebdb0598e6aca (diff)
downloadingen-f02ac2f82a0342c3e548a81950734b4bce383b7d.tar.gz
ingen-f02ac2f82a0342c3e548a81950734b4bce383b7d.tar.bz2
ingen-f02ac2f82a0342c3e548a81950734b4bce383b7d.zip
Improved/quicker/easier handling of control port ranges.
* Add "Set minimum to current value", "Set maximum to current value", and "Reset range" to control port context menu. * Only serialise properties (e.g. lv2:minimum) if they differ from the meta object's (prototype's, e.g. plugin) value. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2395 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r--src/serialisation/Serialiser.cpp28
-rw-r--r--src/serialisation/Serialiser.hpp5
2 files changed, 20 insertions, 13 deletions
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 18a6d9d9..97b84e4e 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -44,6 +44,7 @@
#include "interface/Node.hpp"
#include "interface/Port.hpp"
#include "interface/Connection.hpp"
+#include "shared/ResourceImpl.hpp"
#include "Serialiser.hpp"
#define LOG(s) s << "[Serialiser] "
@@ -318,7 +319,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node&
LOG(warn) << "Patch has no lv2:symbol" << endl;
}
- serialise_properties(patch_id, patch->meta().properties());
+ serialise_properties(patch_id, NULL, patch->meta().properties());
for (Store::const_iterator n = _store->children_begin(patch);
n != _store->children_end(patch); ++n) {
@@ -358,7 +359,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node&
_model->add_statement(patch_id, "lv2:port", port_id);
serialise_port_meta(p, port_id);
if (root)
- serialise_properties(port_id, p->properties());
+ serialise_properties(port_id, &p->meta(), p->properties());
}
for (Shared::Patch::Connections::const_iterator c = patch->connections().begin();
@@ -391,7 +392,7 @@ 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());
+ serialise_properties(node_id, &node->meta(), node->properties());
for (uint32_t i=0; i < node->num_ports(); ++i) {
Port* p = node->port(i);
@@ -424,7 +425,7 @@ Serialiser::serialise_port(const Port* port, const Redland::Node& port_id)
_model->add_statement(port_id, "ingen:value",
AtomRDF::atom_to_node(_model->world(), port->value()));
- serialise_properties(port_id, port->properties());
+ serialise_properties(port_id, &port->meta(), port->properties());
}
@@ -456,7 +457,7 @@ Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id)
}
}
- serialise_properties(port_id, port->meta().properties());
+ serialise_properties(port_id, NULL, port->meta().properties());
}
@@ -491,17 +492,20 @@ Serialiser::serialise_connection(SharedPtr<GraphObject> parent,
void
Serialiser::serialise_properties(
Redland::Node subject,
+ const Shared::Resource* meta,
const GraphObject::Properties& properties)
{
for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) {
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 {
- LOG(warn) << "Can not serialise variable '" << v->first << "' :: "
- << (int)v->second.type() << endl;
+ if (!meta || !meta->has_property(v->first.str(), v->second)) {
+ 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 {
+ LOG(warn) << "Can not serialise variable '" << v->first << "' :: "
+ << (int)v->second.type() << endl;
+ }
}
} else {
LOG(warn) << "Property '" << v->first << "' has no value" << endl;
diff --git a/src/serialisation/Serialiser.hpp b/src/serialisation/Serialiser.hpp
index 4264f05e..2515417e 100644
--- a/src/serialisation/Serialiser.hpp
+++ b/src/serialisation/Serialiser.hpp
@@ -100,7 +100,10 @@ private:
void serialise_port_meta(const Shared::Port* p, const Redland::Node& id);
void serialise_meta_properties(Redland::Node subject, const Properties& properties);
- void serialise_properties(Redland::Node subject, const Properties& variables);
+ void serialise_properties(
+ Redland::Node subject,
+ const Shared::Resource* meta,
+ const Properties& properties);
Redland::Node instance_rdf_node(const Raul::Path& path);
Redland::Node class_rdf_node(const Raul::Path& path);