summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-26 23:30:35 +0000
committerDavid Robillard <d@drobilla.net>2012-04-26 23:30:35 +0000
commitb9de87b822a4fd61ffd4f0c899f7b8f81955c3f1 (patch)
tree59eb1a1fa7b239ede24e0f29c9a07abd81b5a3c5 /src/shared
parent35edd6670930041f8d655612a275b2d453fc5c56 (diff)
downloadingen-b9de87b822a4fd61ffd4f0c899f7b8f81955c3f1.tar.gz
ingen-b9de87b822a4fd61ffd4f0c899f7b8f81955c3f1.tar.bz2
ingen-b9de87b822a4fd61ffd4f0c899f7b8f81955c3f1.zip
Implement delta via atoms.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4278 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/AtomReader.cpp71
1 files changed, 53 insertions, 18 deletions
diff --git a/src/shared/AtomReader.cpp b/src/shared/AtomReader.cpp
index f7c5d7e4..343bb23e 100644
--- a/src/shared/AtomReader.cpp
+++ b/src/shared/AtomReader.cpp
@@ -32,6 +32,25 @@ AtomReader::AtomReader(LV2URIMap& map, URIs& uris, Forge& forge, Interface& ifac
}
void
+AtomReader::get_props(const LV2_Atom_Object* obj,
+ Ingen::Resource::Properties& props)
+{
+ LV2_ATOM_OBJECT_FOREACH(obj, p) {
+ Raul::Atom val;
+ if (p->value.type == _uris.atom_URID) {
+ const LV2_Atom_URID* urid = (const LV2_Atom_URID*)&p->value;
+ val = _forge.alloc_uri(_map.unmap_uri(urid->body));
+ } else {
+ val = _forge.alloc(p->value.size,
+ p->value.type,
+ LV2_ATOM_BODY(&p->value));
+ }
+
+ props.insert(std::make_pair(_map.unmap_uri(p->key), val));
+ }
+}
+
+void
AtomReader::write(const LV2_Atom* msg)
{
if (msg->type != _uris.atom_Blank) {
@@ -59,32 +78,48 @@ AtomReader::write(const LV2_Atom* msg)
if (!body) {
Raul::warn << "Put message has no body" << std::endl;
return;
+ } else if (!subject_uri) {
+ Raul::warn << "Put message has no subject" << std::endl;
+ return;
}
Ingen::Resource::Properties props;
- LV2_ATOM_OBJECT_FOREACH(body, p) {
- Raul::Atom val;
- if (p->value.type == _uris.atom_URID) {
- const LV2_Atom_URID* urid = (const LV2_Atom_URID*)&p->value;
- val = _forge.alloc_uri(_map.unmap_uri(urid->body));
- } else {
- val = _forge.alloc(p->value.size,
- p->value.type,
- LV2_ATOM_BODY(&p->value));
- }
-
- props.insert(std::make_pair(_map.unmap_uri(p->key), val));
+ get_props(body, props);
+
+ _iface.set_response_id(obj->body.id);
+ _iface.put(subject_uri, props);
+ } else if (obj->body.otype == _uris.patch_Patch) {
+ if (!subject_uri) {
+ Raul::warn << "Put message has no subject" << std::endl;
+ return;
}
- if (subject_uri) {
- _iface.set_response_id(obj->body.id);
- _iface.put(subject_uri, props);
- } else {
- Raul::warn << "Put message has no subject, ignored" << std::endl;
+ const LV2_Atom_Object* remove = NULL;
+ lv2_atom_object_get(obj, (LV2_URID)_uris.patch_remove, &remove, 0);
+ if (!remove) {
+ Raul::warn << "Patch message has no remove" << std::endl;
+ return;
}
+ const LV2_Atom_Object* add = NULL;
+ lv2_atom_object_get(obj, (LV2_URID)_uris.patch_add, &add, 0);
+ if (!add) {
+ Raul::warn << "Patch message has no add" << std::endl;
+ return;
+ }
+
+ Ingen::Resource::Properties add_props;
+ get_props(remove, add_props);
+
+ Ingen::Resource::Properties remove_props;
+ get_props(remove, remove_props);
+
+ _iface.delta(subject_uri, remove_props, add_props);
+
} else {
- Raul::warn << "Unknown object type " << obj->body.otype << std::endl;
+ Raul::warn << "Unknown object type <"
+ << _map.unmap_uri(obj->body.otype)
+ << ">" << std::endl;
}
}