From d175e2de6d3b51dfa1af5ea95bdad6e8c97df795 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 27 Feb 2012 23:30:54 +0000 Subject: Implement lv2:relation. git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@4002 a436a847-0d15-0410-975c-d299462d15a1 --- src/lilv_internal.h | 1 + src/plugin.c | 28 ++++++++++++++++++++++++++-- src/world.c | 1 + 3 files changed, 28 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lilv_internal.h b/src/lilv_internal.h index 18aaed5..a6d53f7 100644 --- a/src/lilv_internal.h +++ b/src/lilv_internal.h @@ -150,6 +150,7 @@ struct LilvWorldImpl { SordNode* lv2_Plugin; SordNode* lv2_port; SordNode* lv2_portProperty; + SordNode* lv2_relation; SordNode* lv2_reportsLatency; SordNode* lv2_requiredFeature; SordNode* lv2_Specification; diff --git a/src/plugin.c b/src/plugin.c index c6d36a7..df113a0 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -585,8 +585,7 @@ lilv_plugin_has_latency(const LilvPlugin* p) return ret; } -LILV_API -LilvPort* +static LilvPort* lilv_plugin_get_port_by_property(const LilvPlugin* plugin, const LilvNode* port_property) { @@ -610,6 +609,31 @@ lilv_plugin_get_port_by_property(const LilvPlugin* plugin, return NULL; } +LILV_API +LilvPort* +lilv_plugin_get_port_by_relation(const LilvPlugin* plugin, + const LilvNode* relation) +{ + lilv_plugin_load_ports_if_necessary(plugin); + for (uint32_t i = 0; i < plugin->num_ports; ++i) { + LilvPort* port = plugin->ports[i]; + SordIter* iter = lilv_world_query_internal( + plugin->world, + port->node, + plugin->world->uris.lv2_relation, + relation->val.uri_val); + + const bool found = !lilv_matches_end(iter); + lilv_match_end(iter); + + if (found) { + return port; + } + } + + return NULL; +} + LILV_API uint32_t lilv_plugin_get_latency_port_index(const LilvPlugin* p) diff --git a/src/world.c b/src/world.c index 28a58c5..198a02a 100644 --- a/src/world.c +++ b/src/world.c @@ -62,6 +62,7 @@ lilv_world_new(void) world->uris.lv2_Plugin = NEW_URI(LILV_NS_LV2 "Plugin"); world->uris.lv2_port = NEW_URI(LILV_NS_LV2 "port"); world->uris.lv2_portProperty = NEW_URI(LILV_NS_LV2 "portProperty"); + world->uris.lv2_relation = NEW_URI(LILV_NS_LV2 "relation"); world->uris.lv2_reportsLatency = NEW_URI(LILV_NS_LV2 "reportsLatency"); world->uris.lv2_requiredFeature = NEW_URI(LILV_NS_LV2 "requiredFeature"); world->uris.lv2_Specification = NEW_URI(LILV_NS_LV2 "Specification"); -- cgit v1.2.1