summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-04-21 01:23:59 +0000
committerDavid Robillard <d@drobilla.net>2007-04-21 01:23:59 +0000
commit081352a14c7c4f73113d9a491280e327eec14c83 (patch)
tree41887d3ffce2709a6d0fd7a9ea72a99f54186475 /src
parent09e5c017b096bc84bbbc0b273baffd221144213a (diff)
downloadlilv-081352a14c7c4f73113d9a491280e327eec14c83.tar.gz
lilv-081352a14c7c4f73113d9a491280e327eec14c83.tar.bz2
lilv-081352a14c7c4f73113d9a491280e327eec14c83.zip
Changed "categories" to "plugin classes" to better match RDF.
Renamed files to match API. git-svn-id: http://svn.drobilla.net/lad/slv2@466 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am8
-rw-r--r--src/plugin.c33
-rw-r--r--src/pluginclass.c (renamed from src/category.c)30
-rw-r--r--src/pluginclasses.c (renamed from src/categories.c)30
-rw-r--r--src/plugins.c (renamed from src/pluginlist.c)2
-rw-r--r--src/private_types.h26
-rw-r--r--src/query.c2
-rw-r--r--src/strings.c (renamed from src/stringlist.c)2
-rw-r--r--src/world.c39
9 files changed, 97 insertions, 75 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index cc5a774..11f7aa8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,12 +7,12 @@ libslv2_la_LIBADD = @REDLAND_LIBS@
libslv2_la_SOURCES = \
private_types.h \
world.c \
- category.c \
- categories.c \
+ pluginclass.c \
+ pluginclasses.c \
plugin.c \
query.c \
port.c \
- pluginlist.c \
+ plugins.c \
plugininstance.c \
- stringlist.c \
+ strings.c \
util.c
diff --git a/src/plugin.c b/src/plugin.c
index 7fe8e1d..6216ab7 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -25,7 +25,7 @@
#include <slv2/plugin.h>
#include <slv2/types.h>
#include <slv2/util.h>
-#include <slv2/stringlist.h>
+#include <slv2/strings.h>
#include "private_types.h"
@@ -37,7 +37,7 @@ slv2_plugin_new(SLV2World world, librdf_uri* uri, const char* binary_uri)
plugin->world = world;
plugin->plugin_uri = librdf_new_uri_from_uri(uri);
plugin->binary_uri = strdup(binary_uri);
- plugin->category = NULL;
+ plugin->plugin_class = NULL;
plugin->data_uris = slv2_strings_new();
plugin->ports = raptor_new_sequence((void (*)(void*))&slv2_port_free, NULL);
plugin->storage = NULL;
@@ -146,7 +146,7 @@ slv2_plugin_load(SLV2Plugin p)
librdf_free_uri(data_uri);
}
- // Load category
+ // Load plugin_class
const unsigned char* query = (const unsigned char*)
"SELECT DISTINCT ?class WHERE { <> a ?class }";
@@ -160,16 +160,20 @@ slv2_plugin_load(SLV2Plugin p)
librdf_uri* class_uri = librdf_node_get_uri(class_node);
const char* class_uri_str = (const char*)librdf_uri_as_string(class_uri);
- SLV2Category category = slv2_categories_get_by_uri(p->world->categories, class_uri_str);
+ SLV2PluginClass plugin_class = slv2_plugin_classes_get_by_uri(
+ p->world->plugin_classes, class_uri_str);
- if (category) {
- p->category = category;
+ if (plugin_class) {
+ p->plugin_class = plugin_class;
break;
}
librdf_query_results_next(results);
}
+ if (p->plugin_class == NULL)
+ fprintf(stderr, "Warning: Unclassy plugin: %s\n", slv2_plugin_get_uri(p));
+
// Load ports
query = (const unsigned char*)
"PREFIX : <http://lv2plug.in/ontology#>\n"
@@ -242,13 +246,13 @@ slv2_plugin_get_library_uri(SLV2Plugin p)
}
-SLV2Category
-slv2_plugin_get_category(SLV2Plugin p)
+SLV2PluginClass
+slv2_plugin_get_plugin_class(SLV2Plugin p)
{
- if (!p->category)
+ if (!p->plugin_class)
slv2_plugin_load(p);
- return p->category;
+ return p->plugin_class;
}
@@ -325,6 +329,15 @@ slv2_plugin_get_name(SLV2Plugin plugin)
}
+/** Get the class this plugin belongs to (ie Filters).
+ */
+SLV2PluginClass
+slv2_plugin_get_class(SLV2Plugin plugin)
+{
+ return plugin->plugin_class;
+}
+
+
SLV2Strings
slv2_plugin_get_value(SLV2Plugin p,
const char* predicate)
diff --git a/src/category.c b/src/pluginclass.c
index 5eae2af..3669b9b 100644
--- a/src/category.c
+++ b/src/pluginclass.c
@@ -20,38 +20,38 @@
#include <stdlib.h>
#include <string.h>
-#include <slv2/category.h>
+#include <slv2/pluginclass.h>
#include "private_types.h"
-SLV2Category
-slv2_category_new(const char* uri, const char* label)
+SLV2PluginClass
+slv2_plugin_class_new(const char* uri, const char* label)
{
- SLV2Category category = (SLV2Category)malloc(sizeof(struct _Category));
- category->uri = strdup(uri);
- category->label = strdup(label);
- return category;
+ SLV2PluginClass plugin_class = (SLV2PluginClass)malloc(sizeof(struct _PluginClass));
+ plugin_class->uri = strdup(uri);
+ plugin_class->label = strdup(label);
+ return plugin_class;
}
void
-slv2_category_free(SLV2Category category)
+slv2_plugin_class_free(SLV2PluginClass plugin_class)
{
- free(category->uri);
- free(category->label);
- free(category);
+ free(plugin_class->uri);
+ free(plugin_class->label);
+ free(plugin_class);
}
const char*
-slv2_category_get_uri(SLV2Category category)
+slv2_plugin_class_get_uri(SLV2PluginClass plugin_class)
{
- return category->uri;
+ return plugin_class->uri;
}
const char*
-slv2_category_get_label(SLV2Category category)
+slv2_plugin_class_get_label(SLV2PluginClass plugin_class)
{
- return category->label;
+ return plugin_class->label;
}
diff --git a/src/categories.c b/src/pluginclasses.c
index 133e7ee..919201e 100644
--- a/src/categories.c
+++ b/src/pluginclasses.c
@@ -21,35 +21,35 @@
#include <string.h>
#include <limits.h>
#include <librdf.h>
-#include <slv2/category.h>
-#include <slv2/categories.h>
+#include <slv2/pluginclass.h>
+#include <slv2/pluginclasses.h>
#include "private_types.h"
-SLV2Categories
-slv2_categories_new()
+SLV2PluginClasses
+slv2_plugin_classes_new()
{
- return raptor_new_sequence((void (*)(void*))&slv2_category_free, NULL);
+ return raptor_new_sequence((void (*)(void*))&slv2_plugin_class_free, NULL);
}
void
-slv2_categories_free(SLV2Categories list)
+slv2_plugin_classes_free(SLV2PluginClasses list)
{
- //if (list != world->categories)
+ //if (list != world->plugin_classes)
raptor_free_sequence(list);
}
unsigned
-slv2_categories_size(SLV2Categories list)
+slv2_plugin_classes_size(SLV2PluginClasses list)
{
return raptor_sequence_size(list);
}
-SLV2Category
-slv2_categories_get_by_uri(SLV2Categories list, const char* uri)
+SLV2PluginClass
+slv2_plugin_classes_get_by_uri(SLV2PluginClasses list, const char* uri)
{
// good old fashioned binary search
@@ -63,9 +63,9 @@ slv2_categories_get_by_uri(SLV2Categories list, const char* uri)
while (upper >= lower) {
i = lower + ((upper - lower) / 2);
- SLV2Category p = raptor_sequence_get_at(list, i);
+ SLV2PluginClass p = raptor_sequence_get_at(list, i);
- int cmp = strcmp(slv2_category_get_uri(p), uri);
+ int cmp = strcmp(slv2_plugin_class_get_uri(p), uri);
if (cmp == 0)
return p;
@@ -79,12 +79,12 @@ slv2_categories_get_by_uri(SLV2Categories list, const char* uri)
}
-SLV2Category
-slv2_categories_get_at(SLV2Categories list, unsigned index)
+SLV2PluginClass
+slv2_plugin_classes_get_at(SLV2PluginClasses list, unsigned index)
{
if (index > INT_MAX)
return NULL;
else
- return (SLV2Category)raptor_sequence_get_at(list, (int)index);
+ return (SLV2PluginClass)raptor_sequence_get_at(list, (int)index);
}
diff --git a/src/pluginlist.c b/src/plugins.c
index da003a5..9d62398 100644
--- a/src/pluginlist.c
+++ b/src/plugins.c
@@ -26,7 +26,7 @@
#include <slv2/types.h>
#include <slv2/plugin.h>
#include <slv2/pluginlist.h>
-#include <slv2/stringlist.h>
+#include <slv2/strings.h>
#include <slv2/util.h>
#include "private_types.h"
diff --git a/src/private_types.h b/src/private_types.h
index ff4580c..a0337ac 100644
--- a/src/private_types.h
+++ b/src/private_types.h
@@ -27,7 +27,7 @@ extern "C" {
#include <stddef.h>
#include <librdf.h>
#include <slv2/pluginlist.h>
-#include <slv2/categories.h>
+#include <slv2/pluginclasses.h>
/** Reference to a port on some plugin.
@@ -54,7 +54,7 @@ struct _Plugin {
librdf_uri* plugin_uri;
// char* bundle_url; // Bundle directory plugin was loaded from
char* binary_uri; // lv2:binary
- SLV2Category category;
+ SLV2PluginClass plugin_class;
raptor_sequence* data_uris; // rdfs::seeAlso
raptor_sequence* ports;
librdf_storage* storage;
@@ -80,26 +80,26 @@ struct _InstanceImpl {
};
-struct _Category {
+struct _PluginClass {
char* uri;
char* label;
};
-SLV2Category slv2_category_new(const char* uri, const char* label);
-void slv2_category_free(SLV2Category category);
+SLV2PluginClass slv2_plugin_class_new(const char* uri, const char* label);
+void slv2_plugin_class_free(SLV2PluginClass class);
-SLV2Categories slv2_categories_new();
-void slv2_categories_free();
+SLV2PluginClasses slv2_plugin_classes_new();
+void slv2_plugin_classes_free();
/** Model of LV2 (RDF) data loaded from bundles.
*/
struct _World {
- librdf_world* world;
- librdf_storage* storage;
- librdf_model* model;
- librdf_parser* parser;
- SLV2Categories categories;
- SLV2Plugins plugins;
+ librdf_world* world;
+ librdf_storage* storage;
+ librdf_model* model;
+ librdf_parser* parser;
+ SLV2PluginClasses plugin_classes;
+ SLV2Plugins plugins;
};
/** Load all bundles found in \a search_path.
diff --git a/src/query.c b/src/query.c
index 56a7412..a4d8e16 100644
--- a/src/query.c
+++ b/src/query.c
@@ -23,7 +23,7 @@
#include <librdf.h>
#include <slv2/plugin.h>
#include <slv2/util.h>
-#include <slv2/stringlist.h>
+#include <slv2/strings.h>
#include "private_types.h"
diff --git a/src/stringlist.c b/src/strings.c
index 2233e7e..39da54f 100644
--- a/src/stringlist.c
+++ b/src/strings.c
@@ -20,7 +20,7 @@
#include <stdlib.h>
#include <limits.h>
#include <raptor.h>
-#include <slv2/stringlist.h>
+#include <slv2/strings.h>
SLV2Strings
diff --git a/src/world.c b/src/world.c
index c8735ea..d4d47b2 100644
--- a/src/world.c
+++ b/src/world.c
@@ -44,7 +44,7 @@ slv2_world_new()
world->parser = librdf_new_parser(world->world, "turtle", NULL, NULL);
- world->categories = slv2_categories_new();
+ world->plugin_classes = slv2_plugin_classes_new();
world->plugins = slv2_plugins_new();
@@ -60,8 +60,8 @@ slv2_world_free(SLV2World world)
raptor_free_sequence(world->plugins);
world->plugins = NULL;
- slv2_categories_free(world->categories);
- world->categories = NULL;
+ slv2_plugin_classes_free(world->plugin_classes);
+ world->plugin_classes = NULL;
librdf_free_parser(world->parser);
world->parser = NULL;
@@ -164,17 +164,18 @@ slv2_plugin_compare_by_uri(const void* a, const void* b)
void
-slv2_world_load_categories(SLV2World world)
+slv2_world_load_plugin_classes(SLV2World world)
{
// FIXME: This will need to be a bit more clever when more data is around
- // then the ontology (ie classes which aren't LV2 categories)
+ // then the ontology (ie classes which aren't LV2 plugin_classes)
unsigned char* query_string = (unsigned char*)
"PREFIX : <http://lv2plug.in/ontology#>\n"
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n"
- "SELECT DISTINCT ?category ?label\n"
- "WHERE { ?category a rdfs:Class; rdfs:label ?label }\n"
- "ORDER BY ?category\n";
+ "SELECT DISTINCT ?class ?label WHERE {\n"
+ //" ?plugin a :Plugin; a ?class .\n"
+ " ?class a rdfs:Class; rdfs:label ?label\n"
+ "} ORDER BY ?class\n";
librdf_query* q = librdf_new_query(world->world, "sparql",
NULL, query_string, NULL);
@@ -182,16 +183,17 @@ slv2_world_load_categories(SLV2World world)
librdf_query_results* results = librdf_query_execute(q, world->model);
while (!librdf_query_results_finished(results)) {
- librdf_node* category_node = librdf_query_results_get_binding_value(results, 0);
- librdf_uri* category_uri = librdf_node_get_uri(category_node);
+ librdf_node* class_node = librdf_query_results_get_binding_value(results, 0);
+ librdf_uri* class_uri = librdf_node_get_uri(class_node);
librdf_node* label_node = librdf_query_results_get_binding_value(results, 1);
const char* label = (const char*)librdf_node_get_literal_value(label_node);
- //printf("CATEGORY: %s (%s)\n", librdf_uri_as_string(category_uri), label);
- SLV2Category category = slv2_category_new(
- (const char*)librdf_uri_as_string(category_uri),
+ //printf("CLASS: %s (%s)\n", librdf_uri_as_string(class_uri), label);
+
+ SLV2PluginClass plugin_class = slv2_plugin_class_new(
+ (const char*)librdf_uri_as_string(class_uri),
label);
- raptor_sequence_push(world->categories, category);
+ raptor_sequence_push(world->plugin_classes, plugin_class);
librdf_query_results_next(results);
}
@@ -228,7 +230,7 @@ slv2_world_load_all(SLV2World world)
/* 3. Query out things to cache */
- slv2_world_load_categories(world);
+ slv2_world_load_plugin_classes(world);
// Find all plugins and associated data files
unsigned char* query_string = (unsigned char*)
@@ -307,6 +309,13 @@ slv2_world_serialize(const char* filename)
#endif
+SLV2PluginClasses
+slv2_world_get_plugin_classes(SLV2World world)
+{
+ return world->plugin_classes;
+}
+
+
SLV2Plugins
slv2_world_get_all_plugins(SLV2World world)
{