summaryrefslogtreecommitdiffstats
path: root/src/port.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-12 17:58:12 +0000
committerDavid Robillard <d@drobilla.net>2008-01-12 17:58:12 +0000
commit98cc3bd853c47f6cd1cf02cf14e00413993fd6f5 (patch)
treefc31d4304b5a9bb4ba5df30704c3b773558359b1 /src/port.c
parent2ea341ef3313b189315367ad6beadc23eec227e3 (diff)
downloadlilv-98cc3bd853c47f6cd1cf02cf14e00413993fd6f5.tar.gz
lilv-98cc3bd853c47f6cd1cf02cf14e00413993fd6f5.tar.bz2
lilv-98cc3bd853c47f6cd1cf02cf14e00413993fd6f5.zip
Add plugin template interface (fast discovery of plugins with certain I/O
characteristics). git-svn-id: http://svn.drobilla.net/lad/slv2@1051 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/port.c')
-rw-r--r--src/port.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/src/port.c b/src/port.c
index ec38bfa..851cb38 100644
--- a/src/port.c
+++ b/src/port.c
@@ -122,40 +122,31 @@ slv2_port_get_data_type(SLV2Plugin p,
return ret;
}
-#if 0
bool
-slv2_port_has_property(SLV2Plugin p,
- SLV2Port port,
- SLV2Value hint)
+slv2_port_has_property(SLV2Plugin p,
+ SLV2Port port,
+ const char* property)
{
- /* FIXME: Add SLV2Value QName stuff to make this not suck to use */
+ assert(property);
- SLV2Values hints = slv2_port_get_value(p, port, "lv2:portHint");
+ SLV2Values result = NULL;
- if (!hints)
- return false;
-
- for (unsigned i=0; i < slv2_values_size(type); ++i) {
- const SLV2Value val = slv2_values_get_at(type, i);
- if (slv2_value_is_uri(val)) {
- const char* uri = slv2_value_as_uri(val);
- if (!strcmp(uri, "http://lv2plug.in/ns/lv2core#connectionOptional"))
- return true;
- ret = SLV2_PORT_DATA_TYPE_CONTROL;
- else if (!strcmp(uri, "http://lv2plug.in/ns/lv2core#AudioPort"))
- ret = SLV2_PORT_DATA_TYPE_AUDIO;
- else if (!strcmp(uri, "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"))
- ret = SLV2_PORT_DATA_TYPE_MIDI;
- else if (!strcmp(uri, "http://drobilla.net/ns/lv2ext/osc/0#OSCPort"))
- ret = SLV2_PORT_DATA_TYPE_OSC;
- }
- }
+ char* query = slv2_strjoin(
+ "SELECT DISTINCT ?port WHERE {\n"
+ "<", librdf_uri_as_string(p->plugin_uri), "> lv2:port ?port ."
+ "?port lv2:symbol \"", port->symbol, "\";\n",
+ " lv2:portProperty <", property, "> .\n}", NULL);
+
+ result = slv2_plugin_simple_query(p, query, 0);
- slv2_values_free(type);
+ const bool ret = (slv2_values_size(result) > 0);
+ free(query);
+ free(result);
+
return ret;
}
-#endif
+
SLV2Values
slv2_port_get_value(SLV2Plugin p,