summaryrefslogtreecommitdiffstats
path: root/src/plugin.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/plugin.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/plugin.c')
-rw-r--r--src/plugin.c132
1 files changed, 121 insertions, 11 deletions
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)
{