summaryrefslogtreecommitdiffstats
path: root/src/shared/AtomReader.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-27 19:20:53 +0000
committerDavid Robillard <d@drobilla.net>2012-04-27 19:20:53 +0000
commitfd1e2ef17c7799e8c5d5965932c3bec1570262bd (patch)
tree7fbe21dd87d688ae2d1a124e479e36698cf63bad /src/shared/AtomReader.cpp
parent6dfca027bb8981322b6d2671d687b1e970a4f6f1 (diff)
downloadingen-fd1e2ef17c7799e8c5d5965932c3bec1570262bd.tar.gz
ingen-fd1e2ef17c7799e8c5d5965932c3bec1570262bd.tar.bz2
ingen-fd1e2ef17c7799e8c5d5965932c3bec1570262bd.zip
Implement connecting via atom interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4285 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared/AtomReader.cpp')
-rw-r--r--src/shared/AtomReader.cpp51
1 files changed, 37 insertions, 14 deletions
diff --git a/src/shared/AtomReader.cpp b/src/shared/AtomReader.cpp
index a7ea5e68..fa14243a 100644
--- a/src/shared/AtomReader.cpp
+++ b/src/shared/AtomReader.cpp
@@ -18,6 +18,7 @@
#include "ingen/shared/AtomReader.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+#include "raul/Path.hpp"
#include "raul/log.hpp"
namespace Ingen {
@@ -32,20 +33,23 @@ AtomReader::AtomReader(LV2URIMap& map, URIs& uris, Forge& forge, Interface& ifac
}
void
+AtomReader::get_uri(const LV2_Atom* in, Raul::Atom& out)
+{
+ if (in->type == _uris.atom_URID) {
+ const LV2_Atom_URID* urid = (const LV2_Atom_URID*)in;
+ out = _forge.alloc_uri(_map.unmap_uri(urid->body));
+ } else {
+ out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY(in));
+ }
+}
+
+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));
- }
-
+ get_uri(&p->value, val);
props.insert(std::make_pair(_map.unmap_uri(p->key), val));
}
}
@@ -83,11 +87,30 @@ AtomReader::write(const LV2_Atom* msg)
return;
}
- Ingen::Resource::Properties props;
- get_props(body, props);
-
- _iface.set_response_id(obj->body.id);
- _iface.put(subject_uri, props);
+ if (body->body.otype == _uris.ingen_Edge) {
+ LV2_Atom* tail = NULL;
+ LV2_Atom* head = NULL;
+ lv2_atom_object_get(body,
+ (LV2_URID)_uris.ingen_tail, &tail,
+ (LV2_URID)_uris.ingen_head, &head,
+ NULL);
+ if (!tail || !head) {
+ Raul::warn << "Edge has no tail or head" << std::endl;
+ return;
+ }
+
+ Raul::Atom tail_atom;
+ Raul::Atom head_atom;
+ get_uri(tail, tail_atom);
+ get_uri(head, head_atom);
+ _iface.connect(Raul::Path(tail_atom.get_uri()),
+ Raul::Path(head_atom.get_uri()));
+ } else {
+ Ingen::Resource::Properties props;
+ 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;