summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--slv2/world.h7
-rw-r--r--src/world.c27
2 files changed, 34 insertions, 0 deletions
diff --git a/slv2/world.h b/slv2/world.h
index 6cd1402..b5a4f30 100644
--- a/slv2/world.h
+++ b/slv2/world.h
@@ -21,6 +21,7 @@
#include <slv2/plugins.h>
#include <slv2/pluginclasses.h>
+#include <librdf.h>
#ifdef __cplusplus
extern "C" {
@@ -52,6 +53,12 @@ SLV2World
slv2_world_new();
+/** Initialize a new, empty world, using an existing Redland context.
+ */
+SLV2World
+slv2_world_new_using_rdf_world(librdf_world* world);
+
+
/** Destroy the world, mwahaha.
*
* NB: Destroying the world will leave dangling references in any plugin lists,
diff --git a/src/world.c b/src/world.c
index 556ccf4..dab7532 100644
--- a/src/world.c
+++ b/src/world.c
@@ -57,6 +57,33 @@ slv2_world_new()
}
+SLV2World
+slv2_world_new_using_rdf_world(librdf_world* rdf_world)
+{
+ struct _World* world = (struct _World*)malloc(sizeof(struct _World));
+
+ world->world = rdf_world;
+
+ world->storage = librdf_new_storage(world->world, "hashes", NULL,
+ "hash-type='memory'");
+
+ world->model = librdf_new_model(world->world, world->storage, NULL);
+
+ world->parser = librdf_new_parser(world->world, "turtle", NULL, NULL);
+
+ world->plugin_classes = slv2_plugin_classes_new();
+
+ // Add the ever-present lv2:Plugin to classes
+ static const char* lv2_plugin_uri = "http://lv2plug.in/ontology#Plugin";
+ raptor_sequence_push(world->plugin_classes, slv2_plugin_class_new(
+ world, NULL, lv2_plugin_uri, "Plugin"));
+
+ world->plugins = slv2_plugins_new();
+
+ return world;
+}
+
+
void
slv2_world_free(SLV2World world)
{