summaryrefslogtreecommitdiffstats
path: root/slv2
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-02-07 01:45:53 +0000
committerDavid Robillard <d@drobilla.net>2007-02-07 01:45:53 +0000
commit17ec1c5594772a89a5284449754b56ccb705ebe4 (patch)
treed3ee843acc698345b3760818b1a09f55a18517bb /slv2
parent87e016baff11bd74d905b68e48577461b36b992c (diff)
downloadlilv-17ec1c5594772a89a5284449754b56ccb705ebe4.tar.gz
lilv-17ec1c5594772a89a5284449754b56ccb705ebe4.tar.bz2
lilv-17ec1c5594772a89a5284449754b56ccb705ebe4.zip
Added lv2.ttl installation, lv2.ttl added as source by default to queries.
Changed port API to work by referring to either index or symbol. Plugged some leaks. Added access to plugin/port hints/properties. Updated lv2.ttl. git-svn-id: http://svn.drobilla.net/lad/slv2@285 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'slv2')
-rw-r--r--slv2/Makefile.am1
-rw-r--r--slv2/library.h53
-rw-r--r--slv2/plugin.h61
-rw-r--r--slv2/port.h72
-rw-r--r--slv2/query.h22
-rw-r--r--slv2/slv2.h6
-rw-r--r--slv2/types.h27
7 files changed, 185 insertions, 57 deletions
diff --git a/slv2/Makefile.am b/slv2/Makefile.am
index 2fcb5b7..5fba079 100644
--- a/slv2/Makefile.am
+++ b/slv2/Makefile.am
@@ -5,6 +5,7 @@ slv2include_HEADERS = \
types.h \
private_types.h \
slv2.h \
+ library.h \
plugin.h \
query.h \
port.h \
diff --git a/slv2/library.h b/slv2/library.h
new file mode 100644
index 0000000..9c94139
--- /dev/null
+++ b/slv2/library.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_LIBRARY_H
+#define __SLV2_LIBRARY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** Initialize SLV2.
+ *
+ * This MUST be called before calling any other SLV2 functions, or fatal
+ * errors will likely occur.
+ */
+void
+slv2_init();
+
+
+/** Finialize SLV2.
+ *
+ * Frees any resources allocated by slv2_init().
+ */
+void
+slv2_finish();
+
+
+/** The URI of the lv2.ttl file.
+ */
+extern raptor_uri* slv2_ontology_uri;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SLV2_LIBRARY_H */
diff --git a/slv2/plugin.h b/slv2/plugin.h
index 839137f..d646504 100644
--- a/slv2/plugin.h
+++ b/slv2/plugin.h
@@ -136,21 +136,45 @@ char*
slv2_plugin_get_name(const SLV2Plugin* plugin);
-/** Request some property of the plugin.
+/** Request some arbitrary RDF object of the plugin.
*
* May return NULL if the property was not found (ie is not defined in the
- * data file).
+ * data file), or if object is not sensibly represented as an SLV2Value
+ * (e.g. blank nodes).
*
- * Return value must be free()'d by caller.
+ * Return value must be freed by caller with slv2_value_free.
*
- * Note that some properties may have multiple values. If the property is a
+ * Note that this may return multiple values. If the property is a
* string with multiple languages defined, the translation according to
* $LANG will be returned if it is set. Otherwise all values will be
* returned.
*/
-SLV2Property
-slv2_plugin_get_property(const SLV2Plugin* p,
- const char* property);
+SLV2Value
+slv2_plugin_get_value(const SLV2Plugin* p,
+ const char* predicate);
+
+
+/** Get the LV2 Properties of a plugin.
+ *
+ * LV2 Properties are mandatory. Hosts MUST NOT use a plugin if they do not
+ * understand all the LV2 Properties associated with that plugin (if this is
+ * not what you want, see slv2_plugin_get_hints).
+ *
+ * Return value must be freed by caller with slv2_value_free.
+ */
+SLV2Value
+slv2_plugin_get_properties(const SLV2Plugin* p);
+
+
+/** Get the LV2 Hints of a plugin.
+ *
+ * LV2 Hints are suggestions that may be useful for a host. LV2 Hints may be
+ * ignored and the plugin will still function correctly.
+ *
+ * Return value must be freed by caller with slv2_value_free.
+ */
+SLV2Value
+slv2_plugin_get_hints(const SLV2Plugin* p);
/** Get the number of ports on this plugin.
@@ -179,29 +203,12 @@ slv2_plugin_has_latency(const SLV2Plugin* p);
uint32_t
slv2_plugin_get_latency_port(const SLV2Plugin* p);
-#if 0
-/** Return whether or not a plugin supports the given host feature / extension.
- *
- * This will return true for both supported and required host features.
- */
-bool
-slv2_plugin_supports_feature(const SLV2Plugin* p, const char* feature_uri);
-
-
-/** Return whether or not a plugin requires the given host feature / extension.
- *
- * If a plugin requires a feature, that feature MUST be passed to the plugin's
- * instantiate method or the plugin will fail to instantiate.
- */
-bool
-slv2_plugin_requires_features(const SLV2Plugin* p, const char* feature_uri);
-#endif
/** Get a plugin's supported host features / extensions.
*
* This returns a list of all supported features (both required and optional).
*/
-SLV2Property
+SLV2Value
slv2_plugin_get_supported_features(const SLV2Plugin* p);
@@ -210,7 +217,7 @@ slv2_plugin_get_supported_features(const SLV2Plugin* p);
* All feature URI's returned by this call MUST be passed to the plugin's
* instantiate method for the plugin to instantiate successfully.
*/
-SLV2Property
+SLV2Value
slv2_plugin_get_required_features(const SLV2Plugin* p);
@@ -220,7 +227,7 @@ slv2_plugin_get_required_features(const SLV2Plugin* p);
* instantiate method, those features will be used by the function, otherwise
* the plugin will act as it would if it did not support that feature at all.
*/
-SLV2Property
+SLV2Value
slv2_plugin_get_optional_features(const SLV2Plugin* p);
diff --git a/slv2/port.h b/slv2/port.h
index 4e352a8..8e5b006 100644
--- a/slv2/port.h
+++ b/slv2/port.h
@@ -31,14 +31,38 @@ extern "C" {
*/
-/** Get a property of a port, by port index.
- *
- * Return value must be freed by caller with slv2_property_free.
+/** Create an ID to reference a port by index.
*/
-SLV2Property
-slv2_port_get_property(SLV2Plugin* plugin,
- uint32_t index,
- const char* property);
+SLV2PortID
+slv2_port_by_index(uint32_t index);
+
+
+/** Create an ID to reference a port by symbol.
+ */
+SLV2PortID
+slv2_port_by_symbol(const char* symbol);
+
+
+/** Port equivalent to slv2_plugin_get_value.
+ */
+SLV2Value
+slv2_port_get_value(SLV2Plugin* plugin,
+ SLV2PortID id,
+ const char* property);
+
+
+/** Port equivalent to slv2_plugin_get_properties.
+ */
+SLV2Value
+slv2_port_get_properties(const SLV2Plugin* p,
+ SLV2PortID id);
+
+
+/** Port equivalent to slv2_plugin_get_hints.
+ */
+SLV2Value
+slv2_port_get_hints(const SLV2Plugin* p,
+ SLV2PortID id);
/** Get the symbol of a port given the index.
@@ -49,15 +73,25 @@ slv2_port_get_property(SLV2Plugin* plugin,
* \return NULL when index is out of range
*/
char*
-slv2_port_get_symbol(SLV2Plugin* plugin,
- uint32_t index);
+slv2_port_get_symbol(SLV2Plugin* plugin,
+ SLV2PortID id);
+
+/** Get the name of a port.
+ *
+ * This is guaranteed to return the untranslated name (the doap:name in the
+ * data file without a language tag). Returned value must be free()'d by
+ * the caller.
+ */
+char*
+slv2_port_get_name(SLV2Plugin* plugin,
+ SLV2PortID id);
/** Get the class (direction and rate) of a port.
*/
enum SLV2PortClass
-slv2_port_get_class(SLV2Plugin* plugin,
- uint32_t index);
+slv2_port_get_class(SLV2Plugin* plugin,
+ SLV2PortID id);
/** Get the data type of a port (as a URI).
@@ -68,8 +102,8 @@ slv2_port_get_class(SLV2Plugin* plugin,
* Returned string must be free()'d by caller.
*/
char*
-slv2_port_get_data_type(SLV2Plugin* plugin,
- uint32_t index);
+slv2_port_get_data_type(SLV2Plugin* plugin,
+ SLV2PortID id);
/** Get the default value of a port.
@@ -77,8 +111,8 @@ slv2_port_get_data_type(SLV2Plugin* plugin,
* Only valid for ports with a data type of lv2:float.
*/
float
-slv2_port_get_default_value(SLV2Plugin* plugin,
- uint32_t index);
+slv2_port_get_default_value(SLV2Plugin* plugin,
+ SLV2PortID id);
/** Get the minimum value of a port.
@@ -86,8 +120,8 @@ slv2_port_get_default_value(SLV2Plugin* plugin,
* Only valid for ports with a data type of lv2:float.
*/
float
-slv2_port_get_minimum_value(SLV2Plugin* plugin,
- uint32_t index);
+slv2_port_get_minimum_value(SLV2Plugin* plugin,
+ SLV2PortID id);
/** Get the maximum value of a port.
@@ -95,8 +129,8 @@ slv2_port_get_minimum_value(SLV2Plugin* plugin,
* Only valid for ports with a data type of lv2:float.
*/
float
-slv2_port_get_maximum_value(SLV2Plugin* plugin,
- uint32_t index);
+slv2_port_get_maximum_value(SLV2Plugin* plugin,
+ SLV2PortID id);
/** @} */
diff --git a/slv2/query.h b/slv2/query.h
index 28df4a6..3faba15 100644
--- a/slv2/query.h
+++ b/slv2/query.h
@@ -27,6 +27,10 @@ extern "C" {
#include "plugin.h"
#include "types.h"
+
+// FIXME: much of this should not be exposed
+
+
/** \defgroup query SPARQL query helpers
*
* This part is in progress, incomplete, a random mishmash of crap that
@@ -74,6 +78,16 @@ char*
slv2_query_lang_filter(const char* variable);
+rasqal_query_results*
+slv2_plugin_query(SLV2Plugin* plugin,
+ const char* sparql_str);
+
+SLV2Value
+slv2_plugin_simple_query(SLV2Plugin* plugin,
+ const char* sparql_str,
+ const char* variable);
+
+#if 0
/** Run a SPARQL query on a plugin's data file and return variable matches.
*
* Header from slv2query_header will be prepended to passed query string (so
@@ -82,12 +96,11 @@ slv2_query_lang_filter(const char* variable);
*
* Returned is a list of all matches for the query variable \a var_name.
*/
-SLV2Property
+SLV2Value
slv2_query_get_results(const SLV2Plugin* p,
const char* query_string,
const char* var_name);
-
/** Run a SPARQL query on a plugin's data file and just count the matches.
*
* Header from slv2query_header will be prepended to passed query string (so
@@ -99,12 +112,9 @@ slv2_query_get_results(const SLV2Plugin* p,
size_t
slv2_query_count_results(const SLV2Plugin* p,
const char* query_string);
+#endif
-/** Free an SLV2Property. */
-void
-slv2_property_free(SLV2Property);
-
/** @} */
diff --git a/slv2/slv2.h b/slv2/slv2.h
index b3c9f63..44744c9 100644
--- a/slv2/slv2.h
+++ b/slv2/slv2.h
@@ -22,13 +22,17 @@
#ifdef __cplusplus
extern "C" {
#endif
-
+
+#include <rasqal.h>
+
+#include <slv2/library.h>
#include <slv2/types.h>
#include <slv2/plugin.h>
#include <slv2/plugininstance.h>
#include <slv2/pluginlist.h>
#include <slv2/port.h>
+
#ifdef __cplusplus
}
#endif
diff --git a/slv2/types.h b/slv2/types.h
index ca695b4..19f1f2b 100644
--- a/slv2/types.h
+++ b/slv2/types.h
@@ -19,23 +19,42 @@
#ifndef __SLV2_TYPES_H__
#define __SLV2_TYPES_H__
+#include <stddef.h>
+#include <stdbool.h>
+#include <stdint.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#include <stddef.h>
-
/* A property, resulting from a query.
*
* Note that properties may have many values.
*/
-struct _Property {
+struct _Value {
size_t num_values;
char** values;
};
-typedef struct _Property* SLV2Property;
+typedef struct _Value* SLV2Value;
+
+
+/** Free an SLV2Value. */
+void
+slv2_value_free(SLV2Value);
+
+
+/** Port ID type, to allow passing either symbol or index
+ * to port related functions.
+ */
+struct _PortID {
+ bool is_index; /**< Otherwise, symbol */
+ uint32_t index;
+ const char* symbol;
+};
+
+typedef struct _PortID SLV2PortID;
/** Class (direction and rate) of a port */