summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-01-28 01:18:25 +0000
committerDavid Robillard <d@drobilla.net>2008-01-28 01:18:25 +0000
commitcbeb09ee0a31a8bec670864b03d4f743f968d1b1 (patch)
tree1839dcf4cb4b9e572e313b0a1a9c594fadca14f6
parent6de587b04154f2efdc2a94c0a78225f7adc88ff9 (diff)
downloadlilv-cbeb09ee0a31a8bec670864b03d4f743f968d1b1.tar.gz
lilv-cbeb09ee0a31a8bec670864b03d4f743f968d1b1.tar.bz2
lilv-cbeb09ee0a31a8bec670864b03d4f743f968d1b1.zip
Add slv2_plugin_get_num_ports_of_class.
git-svn-id: http://svn.drobilla.net/lad/slv2@1116 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--slv2/plugin.h12
-rw-r--r--src/plugin.c35
-rw-r--r--utils/lv2_inspect.c2
3 files changed, 48 insertions, 1 deletions
diff --git a/slv2/plugin.h b/slv2/plugin.h
index a3ae1f0..0592bfd 100644
--- a/slv2/plugin.h
+++ b/slv2/plugin.h
@@ -270,6 +270,18 @@ uint32_t
slv2_plugin_get_num_ports(SLV2Plugin p);
+/** Get the number of ports on this plugin that are members of some class(es).
+ *
+ * Note that this is a varargs function so ports fitting any type 'profile'
+ * desired can be found quickly. REMEMBER TO TERMINATE THE PARAMETER LIST
+ * OF THIS FUNCTION WITH NULL OR VERY NASTY THINGS WILL HAPPEN.
+ *
+ * Time = O(1)
+ */
+uint32_t
+slv2_plugin_get_num_ports_of_class(SLV2Plugin p,
+ SLV2Value class_1, ...);
+
/** Return whether or not the plugin introduces (and reports) latency.
*
* The index of the latency port can be found with slv2_plugin_get_latency_port
diff --git a/src/plugin.c b/src/plugin.c
index 437bcb6..4745135 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -473,6 +473,41 @@ slv2_plugin_get_num_ports(SLV2Plugin p)
}
+uint32_t
+slv2_plugin_get_num_ports_of_class(SLV2Plugin p,
+ SLV2Value class_1, ...)
+{
+ uint32_t ret = 0;
+ va_list args;
+
+ for (unsigned i=0; i < slv2_plugin_get_num_ports(p); ++i) {
+ SLV2Port port = raptor_sequence_get_at(p->ports, i);
+ if (!slv2_port_is_a(p, port, class_1))
+ continue;
+
+ va_start(args, class_1);
+
+ bool matches = true;
+ for (SLV2Value class_i = NULL; (class_i = va_arg(args, SLV2Value)) != NULL ; ) {
+ if (!slv2_port_is_a(p, port, class_i)) {
+ va_end(args);
+ matches = false;
+ break;
+ }
+ }
+
+ if (matches) {
+ printf("HIT: %s\n", slv2_value_as_string(slv2_port_get_name(p, port)));
+ ++ret;
+ }
+
+ va_end(args);
+ }
+
+ return ret;
+}
+
+
bool
slv2_plugin_has_latency(SLV2Plugin p)
{
diff --git a/utils/lv2_inspect.c b/utils/lv2_inspect.c
index 266d9e6..5aa6a6b 100644
--- a/utils/lv2_inspect.c
+++ b/utils/lv2_inspect.c
@@ -96,7 +96,7 @@ print_plugin(SLV2Plugin p)
SLV2Value val = NULL;
printf("%s\n\n", slv2_value_as_uri(slv2_plugin_get_uri(p)));
-
+
val = slv2_plugin_get_name(p);
printf("\tName: %s\n", slv2_value_as_string(val));
slv2_value_free(val);