From 98cc3bd853c47f6cd1cf02cf14e00413993fd6f5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 Jan 2008 17:58:12 +0000 Subject: 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 --- slv2/Makefile.am | 8 +++--- slv2/plugin.h | 60 ++++++++++++++++++++++++++++++++++++++++++- slv2/pluginclasses.h | 4 +-- slv2/plugins.h | 6 ++--- slv2/pluginuiinstance.h | 1 - slv2/pluginuis.h | 6 ++--- slv2/port.h | 8 +++--- slv2/portsignature.h | 53 ++++++++++++++++++++++++++++++++++++++ slv2/slv2.h | 16 +++++++----- slv2/template.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ slv2/types.h | 14 +++++++--- slv2/util.h | 5 ++-- slv2/values.h | 20 +++++++-------- slv2/world.h | 8 +++--- 14 files changed, 233 insertions(+), 44 deletions(-) create mode 100644 slv2/portsignature.h create mode 100644 slv2/template.h (limited to 'slv2') diff --git a/slv2/Makefile.am b/slv2/Makefile.am index 924fbec..8d3ee26 100644 --- a/slv2/Makefile.am +++ b/slv2/Makefile.am @@ -5,13 +5,15 @@ slv2include_HEADERS = \ plugin.h \ pluginclass.h \ pluginclasses.h \ - pluginui.h \ - pluginuis.h \ - pluginuiinstance.h \ plugininstance.h \ plugins.h \ + pluginui.h \ + pluginuiinstance.h \ + pluginuis.h \ port.h \ + portsignature.h \ slv2.h \ + template.h \ types.h \ util.h \ value.h \ diff --git a/slv2/plugin.h b/slv2/plugin.h index b7a436e..3a386fc 100644 --- a/slv2/plugin.h +++ b/slv2/plugin.h @@ -128,7 +128,6 @@ const char* slv2_plugin_get_library_uri(SLV2Plugin plugin); - /** Get the name of \a plugin. * * This is guaranteed to return the untranslated name (the doap:name in the @@ -250,6 +249,32 @@ uint32_t slv2_plugin_get_num_ports(SLV2Plugin p); +/** Get the "template" (port signature) of this plugin. + * + * The template is intended to be all the basic information a host might + * want to know about a plugin's inputs and outputs (e.g. to determine if the + * plugin is appropriate for a given situation). Using this function is much, + * much faster than using the individual functions repeatedly to get the same + * information (since each call results in a single query). + * + * Time = Query + */ +SLV2Template +slv2_plugin_get_template(SLV2Plugin p); + + +/** Get the number of ports on this plugin of a given direction and/or type. + * + * Use SLV2_PORT_DATA_TYPE_ANY and SLV2_PORT_DIRECTION_ANY for a wildcard. + * + * Time = O(1) + */ +uint32_t +slv2_plugin_get_num_ports_of_type(SLV2Plugin p, + SLV2PortDirection dir, + SLV2PortDataType type); + + /** 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 @@ -344,6 +369,39 @@ SLV2UIs slv2_plugin_get_uis(SLV2Plugin plugin); +/** Get the full name of the plugin's author. + * + * Returns NULL if author name is not present. + * Returned value must be freed by caller. + * + * Time = Query + */ +char* +slv2_plugin_get_author_name(SLV2Plugin plugin); + + +/** Get the email address of the plugin's author. + * + * Returns NULL if author email address is not present. + * Returned value must be freed by caller. + * + * Time = Query + */ +char* +slv2_plugin_get_author_email(SLV2Plugin plugin); + + +/** Get the email address of the plugin's author. + * + * Returns NULL if author homepage is not present. + * Returned value must be freed by caller. + * + * Time = Query + */ +char* +slv2_plugin_get_author_homepage(SLV2Plugin plugin); + + /** @} */ #ifdef __cplusplus diff --git a/slv2/pluginclasses.h b/slv2/pluginclasses.h index b4cd08d..f283356 100644 --- a/slv2/pluginclasses.h +++ b/slv2/pluginclasses.h @@ -19,12 +19,12 @@ #ifndef __SLV2_PLUGIN_CLASSES_H__ #define __SLV2_PLUGIN_CLASSES_H__ -#include - #ifdef __cplusplus extern "C" { #endif +#include + /** \addtogroup slv2_collections * @{ */ diff --git a/slv2/plugins.h b/slv2/plugins.h index 6b8eead..274696e 100644 --- a/slv2/plugins.h +++ b/slv2/plugins.h @@ -19,13 +19,13 @@ #ifndef __SLV2_PLUGINS_H__ #define __SLV2_PLUGINS_H__ -#include -#include - #ifdef __cplusplus extern "C" { #endif +#include +#include + /** \addtogroup slv2_collections * @{ */ diff --git a/slv2/pluginuiinstance.h b/slv2/pluginuiinstance.h index 1384d7c..e0e6349 100644 --- a/slv2/pluginuiinstance.h +++ b/slv2/pluginuiinstance.h @@ -1,6 +1,5 @@ /* SLV2 * Copyright (C) 2007 Dave Robillard - * Author: Lars Luthman * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/slv2/pluginuis.h b/slv2/pluginuis.h index b14e61a..6c91d45 100644 --- a/slv2/pluginuis.h +++ b/slv2/pluginuis.h @@ -19,13 +19,13 @@ #ifndef __SLV2_PLUGIN_UIS_H__ #define __SLV2_PLUGIN_UIS_H__ -#include -#include - #ifdef __cplusplus extern "C" { #endif +#include +#include + /** \addtogroup slv2_collections * * @{ diff --git a/slv2/port.h b/slv2/port.h index 2cf0e30..7846541 100644 --- a/slv2/port.h +++ b/slv2/port.h @@ -52,16 +52,14 @@ slv2_port_get_properties(SLV2Plugin plugin, SLV2Port port); -#if 0 /** Return whether a port has a certain property. * * Time = Query */ bool -slv2_port_has_property(SLV2Plugin p, - SLV2Port port, - SLV2Value hint) -#endif +slv2_port_has_property(SLV2Plugin p, + SLV2Port port, + const char* property_uri); /** Get the symbol of a port given the index. diff --git a/slv2/portsignature.h b/slv2/portsignature.h new file mode 100644 index 0000000..700b572 --- /dev/null +++ b/slv2/portsignature.h @@ -0,0 +1,53 @@ +/* SLV2 + * Copyright (C) 2007 Dave Robillard + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SLV2_PORTSIGNATURE_H__ +#define __SLV2_PORTSIGNATURE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** \addtogroup slv2_data + * @{ + */ + + +/** Get the direction (input or output) of the port. + */ +SLV2PortDirection +slv2_port_signature_get_direction(SLV2PortSignature sig); + + +/** Get the type (e.g. audio, midi) of the port. + */ +SLV2PortDataType +slv2_port_signature_get_type(SLV2PortSignature sig); + + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* __SLV2_PORTSIGNATURE_H__ */ + diff --git a/slv2/slv2.h b/slv2/slv2.h index 8aaf958..9aa5c8c 100644 --- a/slv2/slv2.h +++ b/slv2/slv2.h @@ -23,19 +23,21 @@ extern "C" { #endif -#include -#include -#include #include +#include +#include +#include #include +#include #include #include -#include -#include -#include +#include +#include +#include +#include #include #include -#include +#include #ifdef __cplusplus } diff --git a/slv2/template.h b/slv2/template.h new file mode 100644 index 0000000..a65ae40 --- /dev/null +++ b/slv2/template.h @@ -0,0 +1,68 @@ +/* SLV2 + * Copyright (C) 2007 Dave Robillard + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SLV2_TEMPLATE_H__ +#define __SLV2_TEMPLATE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** \addtogroup slv2_data + * @{ + */ + + +/** Free an SLV2Template. + */ +void +slv2_template_free(SLV2Template); + + +/** Get the signature (direction and type) of a port + */ +SLV2PortSignature +slv2_template_get_port(SLV2Template t, + uint32_t index); + + +/** Get the total number of ports. + */ +uint32_t +slv2_template_get_num_ports(SLV2Template t); + + +/** Get the number of ports of a given direction and type. + */ +uint32_t +slv2_template_get_num_ports_of_type(SLV2Template t, + SLV2PortDirection direction, + SLV2PortDataType type); + + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* __SLV2_TEMPLATE_H__ */ + diff --git a/slv2/types.h b/slv2/types.h index df818ce..1342934 100644 --- a/slv2/types.h +++ b/slv2/types.h @@ -19,13 +19,13 @@ #ifndef __SLV2_TYPES_H__ #define __SLV2_TYPES_H__ -#include -#include - #ifdef __cplusplus extern "C" { #endif +#include +#include + /** (Data) Type of a port * @@ -73,6 +73,10 @@ typedef enum _SLV2URIType { typedef struct _SLV2Port* SLV2Port; +/** The port (I/O) signature of a plugin. Opaque, but valid to compare to NULL. */ +typedef struct _SLV2PortSignature* SLV2PortSignature; + + /** A plugin. Opaque, but valid to compare to NULL. */ typedef struct _SLV2Plugin* SLV2Plugin; @@ -97,6 +101,10 @@ typedef void* SLV2PluginClasses; typedef struct _SLV2Value* SLV2Value; +/** A plugin template (collection of port signatures). */ +typedef void* SLV2Template; + + /** A collection of typed values. */ typedef void* SLV2Values; diff --git a/slv2/util.h b/slv2/util.h index 0313f6e..60c5d4d 100644 --- a/slv2/util.h +++ b/slv2/util.h @@ -19,12 +19,13 @@ #ifndef __SLV2_UTIL_H__ #define __SLV2_UTIL_H__ -#include - #ifdef __cplusplus extern "C" { #endif +#include + + /** \defgroup slv2_util Utility functions * * @{ diff --git a/slv2/values.h b/slv2/values.h index 9d6c717..40da342 100644 --- a/slv2/values.h +++ b/slv2/values.h @@ -19,13 +19,13 @@ #ifndef __SLV2_VALUES_H__ #define __SLV2_VALUES_H__ -#include -#include - #ifdef __cplusplus extern "C" { #endif +#include +#include + /** \defgroup slv2_collections Collections of values/objects * * Ordered collections of typed values which are fast for random @@ -41,6 +41,12 @@ SLV2Values slv2_values_new(); +/** Free an SLV2Values. + */ +void +slv2_values_free(SLV2Values); + + /** Get the number of elements in a string list. */ unsigned @@ -57,7 +63,7 @@ SLV2Value slv2_values_get_at(SLV2Values list, unsigned index); -/** Return whether \a list contains \a string. +/** Return whether \a list contains \a value. * * Time = O(n) */ @@ -65,12 +71,6 @@ bool slv2_values_contains(SLV2Values list, SLV2Value value); -/** Free a string list. - */ -void -slv2_values_free(SLV2Values); - - /** @} */ #ifdef __cplusplus diff --git a/slv2/world.h b/slv2/world.h index 610d830..9d82dd7 100644 --- a/slv2/world.h +++ b/slv2/world.h @@ -19,14 +19,14 @@ #ifndef __SLV2_WORLD_H__ #define __SLV2_WORLD_H__ -#include -#include -#include - #ifdef __cplusplus extern "C" { #endif +#include +#include +#include + /** \defgroup slv2_world Global library state * * The "world" represents all library state, and the data found in bundles' -- cgit v1.2.1