summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac14
-rw-r--r--debian/Makefile.am4
-rw-r--r--debian/changelog16
-rw-r--r--debian/control2
-rwxr-xr-xdebian/rules4
-rw-r--r--debian/shlibs.local4
-rw-r--r--slv2/Makefile.am8
-rw-r--r--slv2/plugin.h60
-rw-r--r--slv2/pluginclasses.h4
-rw-r--r--slv2/plugins.h6
-rw-r--r--slv2/pluginuiinstance.h1
-rw-r--r--slv2/pluginuis.h6
-rw-r--r--slv2/port.h8
-rw-r--r--slv2/portsignature.h53
-rw-r--r--slv2/slv2.h16
-rw-r--r--slv2/template.h68
-rw-r--r--slv2/types.h14
-rw-r--r--slv2/util.h5
-rw-r--r--slv2/values.h20
-rw-r--r--slv2/world.h8
-rw-r--r--src/Makefile.am8
-rw-r--r--src/plugin.c132
-rw-r--r--src/port.c43
-rw-r--r--src/portsignature.c56
-rw-r--r--src/query.c1
-rw-r--r--src/slv2_internal.h40
-rw-r--r--src/template.c114
27 files changed, 608 insertions, 107 deletions
diff --git a/configure.ac b/configure.ac
index eef04b5..7c9ff13 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
AC_PREREQ(2.59)
-AC_INIT([slv2],0.4.2,[dave@drobilla.net])
+AC_INIT([slv2],0.4.4,[dave@drobilla.net])
AC_CONFIG_AUX_DIR([config])
@@ -28,13 +28,15 @@ AM_INIT_AUTOMAKE
# 0.3.1 = 4,0,0
# 0.3.2 = 5,0,1
# 0.4.0 = 6,0,0
-# 0.4.1 = 6,0,0
-# 0.4.2 = 6,0,0
+# 0.4.1 = 6,0,0 (oops, should have been 6,1,0)
+# 0.4.2 = 6,0,0 (oops, should have been 6,2,0)
+# 0.4.3 = 6,0,0 (oops, should have been 6,3,0)
+# 0.4.4 = 7,0,1
-SLV2_VERSION="0.4.2"
-SLV2_API_CURRENT="6"
+SLV2_VERSION="0.4.4"
+SLV2_API_CURRENT="7"
SLV2_API_REVISION="0"
-SLV2_API_AGE="0"
+SLV2_API_AGE="1"
AC_SUBST(SLV2_API_CURRENT)
AC_SUBST(SLV2_API_REVISION)
diff --git a/debian/Makefile.am b/debian/Makefile.am
index babeea5..e354d9f 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -5,8 +5,8 @@ EXTRA_DIST = \
control \
copyright \
docs \
- postinst \
- postrm \
+ postinst.ex \
+ postrm.ex \
rules \
shlibs.local \
shlibs
diff --git a/debian/changelog b/debian/changelog
index 16c1927..8eb91c7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,19 @@
+slv2 (0.4.4) unstable; urgency=low
+
+ * Add slv2_port_has_property
+ * Add plugin template and port signature interface for much faster plugin
+ discovery with port input/output/type inspection.
+
+ -- Dave Robillard <dave@drobilla.net> Sat, 12 Jan 2008 12:52:35 -0500
+
+slv2 (0.4.3) unstable; urgency=low
+
+ * Fix lv2_inspect command line handling bug (always prints help)
+ * Fix case where multiple plugins are described in the same file
+ (avoid port symbol clashing).
+
+ -- Dave Robillard <dave@drobilla.net> Thu, 10 Jan 2008 20:03:19 -0500
+
slv2 (0.4.2) unstable; urgency=low
* Update for LV2 specification release 1
diff --git a/debian/control b/debian/control
index 5e35a7f..9418b51 100644
--- a/debian/control
+++ b/debian/control
@@ -29,8 +29,6 @@ Description: A library for simple use of LV2 plugins
the use of LV2 plugins <http://lv2plug.in> as simple as possible.
Package: slv2-6-dev
-Provides: slv2-dev
-Conflicts: slv2-dev
Section: libdevel
Architecture: any
Pre-Depends: make
diff --git a/debian/rules b/debian/rules
index d02b169..9f3eca8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -64,7 +64,7 @@ install: build
dh_installdirs
$(MAKE) DESTDIR=$(CURDIR)/debian/slv2-6 install-exec
- $(MAKE) DESTDIR=$(CURDIR)/debian/slv2-dev install-data install-man
+ $(MAKE) DESTDIR=$(CURDIR)/debian/slv2-6-dev install-data install-man
# Build architecture-independent files here.
@@ -95,7 +95,7 @@ binary-arch: build install
dh_fixperms
# dh_perl
# dh_python
-# dh_makeshlibs
+ dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol
diff --git a/debian/shlibs.local b/debian/shlibs.local
index e79a7b7..716fd14 100644
--- a/debian/shlibs.local
+++ b/debian/shlibs.local
@@ -1,2 +1,2 @@
-libslv2 0.3.0 slv2 (>> 0.3.0-0), slv2 (<< 0.3.0-99)
-libjack 0 jack0 (>= 0.107.0)
+libslv2 0.4.3 slv2 (>> 0.4.3-0), slv2 (<< 0.4.3-99)
+libjack 0 jackd (>= 0.107.0)
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 <slv2/pluginclass.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <slv2/pluginclass.h>
+
/** \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 <slv2/types.h>
-#include <slv2/plugin.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <slv2/types.h>
+#include <slv2/plugin.h>
+
/** \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 <http://drobilla.net>
- * 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 <slv2/types.h>
-#include <slv2/plugin.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <slv2/types.h>
+#include <slv2/plugin.h>
+
/** \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 <http://drobilla.net>
+ *
+ * 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 <stdbool.h>
+#include <slv2/types.h>
+
+/** \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 <slv2/types.h>
-#include <slv2/world.h>
-#include <slv2/pluginclass.h>
#include <slv2/plugin.h>
+#include <slv2/pluginclass.h>
+#include <slv2/plugininstance.h>
+#include <slv2/plugins.h>
#include <slv2/pluginui.h>
+#include <slv2/pluginuiinstance.h>
#include <slv2/pluginuis.h>
#include <slv2/port.h>
-#include <slv2/plugins.h>
-#include <slv2/pluginuiinstance.h>
-#include <slv2/plugininstance.h>
+#include <slv2/portsignature.h>
+#include <slv2/template.h>
+#include <slv2/types.h>
+#include <slv2/util.h>
#include <slv2/value.h>
#include <slv2/values.h>
-#include <slv2/util.h>
+#include <slv2/world.h>
#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 <http://drobilla.net>
+ *
+ * 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 <stdbool.h>
+#include <slv2/types.h>
+
+/** \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 <stdbool.h>
-#include <stdint.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <stdbool.h>
+#include <stdint.h>
+
/** (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 <stdarg.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <stdarg.h>
+
+
/** \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 <stdbool.h>
-#include <slv2/value.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <stdbool.h>
+#include <slv2/value.h>
+
/** \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 <slv2/plugins.h>
-#include <slv2/pluginclasses.h>
-#include <librdf.h>
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <slv2/plugins.h>
+#include <slv2/pluginclasses.h>
+#include <librdf.h>
+
/** \defgroup slv2_world Global library state
*
* The "world" represents all library state, and the data found in bundles'
diff --git a/src/Makefile.am b/src/Makefile.am
index ec2a617..7a89f0c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,14 +8,16 @@ libslv2_la_SOURCES = \
plugin.c \
pluginclass.c \
pluginclasses.c \
- pluginui.c \
- pluginuis.c \
- pluginuiinstance.c \
plugininstance.c \
plugins.c \
+ pluginui.c \
+ pluginuiinstance.c \
+ pluginuis.c \
port.c \
+ portsignature.c \
query.c \
slv2_internal.h \
+ template.c \
util.c \
value.c \
values.c \
diff --git a/src/plugin.c b/src/plugin.c
index bdfd457..bd7f89e 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -42,6 +42,7 @@ slv2_plugin_new(SLV2World world, librdf_uri* uri, librdf_uri* bundle_uri, librdf
plugin->bundle_uri = librdf_new_uri_from_uri(bundle_uri);
plugin->binary_uri = librdf_new_uri_from_uri(binary_uri);
plugin->plugin_class = NULL;
+ plugin->templt = NULL;
plugin->data_uris = slv2_values_new();
plugin->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free, NULL);
plugin->storage = NULL;
@@ -67,6 +68,9 @@ slv2_plugin_free(SLV2Plugin p)
raptor_free_sequence(p->ports);
p->ports = NULL;
+ slv2_template_free(p->templt);
+ p->templt = NULL;
+
if (p->rdf) {
librdf_free_model(p->rdf);
p->rdf = NULL;
@@ -195,37 +199,55 @@ slv2_plugin_load(SLV2Plugin p)
// Load ports
query = (const unsigned char*)
"PREFIX : <http://lv2plug.in/ns/lv2core#>\n"
- "SELECT DISTINCT ?port ?symbol ?index WHERE {\n"
- "<> :port ?port .\n"
- "?port :symbol ?symbol ;\n"
- " :index ?index .\n"
- "}";
+ "SELECT DISTINCT ?type ?symbol ?index WHERE {\n"
+ "<> :port ?port .\n"
+ "?port a ?type ;\n"
+ " :symbol ?symbol ;\n"
+ " :index ?index .\n"
+ "} ORDER BY (?index)";
q = librdf_new_query(p->world->world, "sparql",
NULL, query, p->plugin_uri);
results = librdf_query_execute(q, p->rdf);
+ int num_ports = 0;
+ int last_index = -1;
+
+ assert(!p->templt);
+ p->templt = slv2_template_new();
+
while (!librdf_query_results_finished(results)) {
- //librdf_node* port_node = librdf_query_results_get_binding_value(results, 0);
+ librdf_node* type_node = librdf_query_results_get_binding_value(results, 0);
librdf_node* symbol_node = librdf_query_results_get_binding_value(results, 1);
librdf_node* index_node = librdf_query_results_get_binding_value(results, 2);
- //assert(librdf_node_is_blank(port_node));
assert(librdf_node_is_literal(symbol_node));
assert(librdf_node_is_literal(index_node));
//const char* id = (const char*)librdf_node_get_blank_identifier(port_node);
+ const char* type = (const char*)librdf_uri_as_string(librdf_node_get_uri(type_node));
const char* symbol = (const char*)librdf_node_get_literal_value(symbol_node);
const char* index = (const char*)librdf_node_get_literal_value(index_node);
- //printf("%s: PORT: %s %s\n", p->plugin_uri, index, symbol);
+ //printf("PORT: %s %s %s\n", type, index, symbol);
+
+ const int this_index = atoi(index);
- // Create a new SLV2Port
- SLV2Port port = slv2_port_new((unsigned)atoi(index), symbol);
- raptor_sequence_push(p->ports, port);
+ // Create a new SLV2Port, and add to template
+ if (this_index == num_ports) {
+ assert(this_index == last_index + 1);
+ SLV2Port port = slv2_port_new((unsigned)atoi(index), symbol);
+ raptor_sequence_push(p->ports, port);
+ slv2_template_add_port(p->templt);
+ ++num_ports;
+ ++last_index;
+ }
+
+ slv2_template_port_type(p->templt, this_index, type);
+ librdf_free_node(type_node);
librdf_free_node(symbol_node);
librdf_free_node(index_node);
@@ -458,6 +480,16 @@ slv2_plugin_get_num_ports(SLV2Plugin p)
}
+SLV2Template
+slv2_plugin_get_template(SLV2Plugin p)
+{
+ if (!p->rdf)
+ slv2_plugin_load(p);
+
+ return p->templt;
+}
+
+
bool
slv2_plugin_has_latency(SLV2Plugin p)
{
@@ -556,6 +588,84 @@ slv2_plugin_get_port_by_symbol(SLV2Plugin p,
}
+char*
+slv2_plugin_get_author_name(SLV2Plugin plugin)
+{
+ char* ret = NULL;
+
+ const char* const query =
+ "SELECT DISTINCT ?name WHERE {\n"
+ " <> doap:maintainer ?maint . \n"
+ " ?maint foaf:name ?name . \n"
+ "}\n";
+
+ SLV2Values result = slv2_plugin_simple_query(plugin, query, 0);
+
+ if (result && slv2_values_size(result) > 0) {
+ SLV2Value val = slv2_values_get_at(result, 0);
+ if (slv2_value_is_string(val))
+ ret = strdup(slv2_value_as_string(val));
+ }
+
+ if (result)
+ slv2_values_free(result);
+
+ return ret;
+}
+
+
+char*
+slv2_plugin_get_author_email(SLV2Plugin plugin)
+{
+ char* ret = NULL;
+
+ const char* const query =
+ "SELECT DISTINCT ?email WHERE {\n"
+ " <> doap:maintainer ?maint . \n"
+ " ?maint foaf:mbox ?email . \n"
+ "}\n";
+
+ SLV2Values result = slv2_plugin_simple_query(plugin, query, 0);
+
+ if (result && slv2_values_size(result) > 0) {
+ SLV2Value val = slv2_values_get_at(result, 0);
+ if (slv2_value_is_string(val))
+ ret = strdup(slv2_value_as_string(val));
+ }
+
+ if (result)
+ slv2_values_free(result);
+
+ return ret;
+}
+
+
+char*
+slv2_plugin_get_author_homepage(SLV2Plugin plugin)
+{
+ char* ret = NULL;
+
+ const char* const query =
+ "SELECT DISTINCT ?email WHERE {\n"
+ " <> doap:maintainer ?maint . \n"
+ " ?maint foaf:homepage ?email . \n"
+ "}\n";
+
+ SLV2Values result = slv2_plugin_simple_query(plugin, query, 0);
+
+ if (result && slv2_values_size(result) > 0) {
+ SLV2Value val = slv2_values_get_at(result, 0);
+ if (slv2_value_is_string(val))
+ ret = strdup(slv2_value_as_string(val));
+ }
+
+ if (result)
+ slv2_values_free(result);
+
+ return ret;
+}
+
+
SLV2UIs
slv2_plugin_get_uis(SLV2Plugin plugin)
{
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,
diff --git a/src/portsignature.c b/src/portsignature.c
new file mode 100644
index 0000000..7e2f535
--- /dev/null
+++ b/src/portsignature.c
@@ -0,0 +1,56 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <slv2/types.h>
+#include "slv2_internal.h"
+
+
+/* private */
+SLV2PortSignature
+slv2_port_signature_new(SLV2PortDirection direction,
+ SLV2PortDataType type)
+{
+ struct _SLV2PortSignature* ret = malloc(sizeof(struct _SLV2PortSignature));
+ ret->direction = direction;
+ ret->type = type;
+ return ret;
+}
+
+
+/* private */
+void
+slv2_port_signature_free(SLV2PortSignature sig)
+{
+ free(sig);
+}
+
+
+SLV2PortDirection
+slv2_port_signature_get_direction(SLV2PortSignature sig)
+{
+ return sig->direction;
+}
+
+
+SLV2PortDataType
+slv2_port_signature_get_type(SLV2PortSignature sig)
+{
+ return sig->type;
+}
+
diff --git a/src/query.c b/src/query.c
index 00f08e6..b226f04 100644
--- a/src/query.c
+++ b/src/query.c
@@ -32,6 +32,7 @@ static const char* slv2_query_prefixes =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n"
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
"PREFIX doap: <http://usefulinc.com/ns/doap#>\n"
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
"PREFIX lv2: <http://lv2plug.in/ns/lv2core#>\n";
#if 0
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 2f66670..07df8f5 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -58,14 +58,15 @@ void slv2_port_free(SLV2Port port);
*/
struct _SLV2Plugin {
struct _SLV2World* world;
- librdf_uri* plugin_uri;
- librdf_uri* bundle_uri; ///< Bundle directory plugin was loaded from
- librdf_uri* binary_uri; ///< lv2:binary
- SLV2PluginClass plugin_class;
- raptor_sequence* data_uris; ///< rdfs::seeAlso
- raptor_sequence* ports;
- librdf_storage* storage;
- librdf_model* rdf;
+ librdf_uri* plugin_uri;
+ librdf_uri* bundle_uri; ///< Bundle directory plugin was loaded from
+ librdf_uri* binary_uri; ///< lv2:binary
+ SLV2PluginClass plugin_class;
+ SLV2Template templt;
+ raptor_sequence* data_uris; ///< rdfs::seeAlso
+ raptor_sequence* ports;
+ librdf_storage* storage;
+ librdf_model* rdf;
};
SLV2Plugin slv2_plugin_new(SLV2World world, librdf_uri* uri, librdf_uri* bundle_uri, librdf_uri* binary_uri);
@@ -191,7 +192,6 @@ void slv2_ui_free(SLV2UI ui);
/* ********* Value ********* */
-
typedef enum _SLV2ValueType {
SLV2_VALUE_URI,
SLV2_VALUE_STRING,
@@ -212,6 +212,28 @@ SLV2Value slv2_value_new(SLV2ValueType type, const char* val);
+/* ********* PortSignature ********* */
+
+struct _SLV2PortSignature {
+ SLV2PortDirection direction;
+ SLV2PortDataType type;
+};
+
+SLV2PortSignature slv2_port_signature_new(SLV2PortDirection direction,
+ SLV2PortDataType type);
+
+void slv2_port_signature_free(SLV2PortSignature val);
+
+
+/* ********* Template ********* */
+
+SLV2Template slv2_template_new();
+void slv2_template_free(SLV2Template t);
+void slv2_template_add_port(SLV2Template t);
+void slv2_template_port_type(SLV2Template t,
+ uint32_t port_index,
+ const char* type_uri);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/template.c b/src/template.c
new file mode 100644
index 0000000..0c179f7
--- /dev/null
+++ b/src/template.c
@@ -0,0 +1,114 @@
+/* SLV2
+ * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
+ *
+ * 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.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include <raptor.h>
+#include <slv2/types.h>
+#include <slv2/template.h>
+#include "slv2_internal.h"
+
+
+/* private */
+SLV2Template
+slv2_template_new()
+{
+ return raptor_new_sequence((void (*)(void*))&slv2_port_signature_free, NULL);
+}
+
+
+/* private */
+void
+slv2_template_add_port(SLV2Template t)
+{
+ SLV2PortSignature sig = slv2_port_signature_new(
+ SLV2_PORT_DIRECTION_UNKNOWN,
+ SLV2_PORT_DATA_TYPE_UNKNOWN);
+
+ raptor_sequence_push(t, sig);
+}
+
+
+/* private */
+void slv2_template_port_type(SLV2Template t,
+ uint32_t port_index,
+ const char* type_uri)
+{
+ SLV2PortSignature sig = slv2_template_get_port(t, port_index);
+
+ if (sig) {
+ if (!strcmp(type_uri, "http://lv2plug.in/ns/lv2core#InputPort"))
+ sig->direction = SLV2_PORT_DIRECTION_INPUT;
+ else if (!strcmp(type_uri, "http://lv2plug.in/ns/lv2core#OutputPort"))
+ sig->direction = SLV2_PORT_DIRECTION_OUTPUT;
+ else if (!strcmp(type_uri, "http://lv2plug.in/ns/lv2core#ControlPort"))
+ sig->type = SLV2_PORT_DATA_TYPE_CONTROL;
+ else if (!strcmp(type_uri, "http://lv2plug.in/ns/lv2core#AudioPort"))
+ sig->type = SLV2_PORT_DATA_TYPE_AUDIO;
+ else if (!strcmp(type_uri, "http://ll-plugins.nongnu.org/lv2/ext/MidiPort"))
+ sig->type = SLV2_PORT_DATA_TYPE_MIDI;
+ else if (!strcmp(type_uri, "http://drobilla.net/ns/lv2ext/osc/0#OSCPort"))
+ sig->type = SLV2_PORT_DATA_TYPE_OSC;
+ }
+}
+
+
+SLV2PortSignature
+slv2_template_get_port(SLV2Template t,
+ uint32_t index)
+{
+ if (index > INT_MAX)
+ return NULL;
+ else
+ return (SLV2PortSignature)raptor_sequence_get_at(t, (int)index);
+}
+
+
+
+void
+slv2_template_free(SLV2Template t)
+{
+ if (t)
+ raptor_free_sequence(t);
+}
+
+
+uint32_t
+slv2_template_get_num_ports(SLV2Template t)
+{
+ return raptor_sequence_size(t);
+}
+
+
+uint32_t
+slv2_template_get_num_ports_of_type(SLV2Template t,
+ SLV2PortDirection direction,
+ SLV2PortDataType type)
+{
+ uint32_t ret = 0;
+
+ for (unsigned i=0; i < slv2_template_get_num_ports(t); ++i) {
+ SLV2PortSignature sig = slv2_template_get_port(t, i);
+ if (sig->direction == direction && sig->type == type)
+ ++ret;
+ }
+
+ return ret;
+}
+