From f8ca7f3cf6f4a0e967eacfd2e1f9a8ae9625c015 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 14 Mar 2012 23:38:53 +0000 Subject: Use the host URI map/unmap when running as a plugin. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4058 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/NodeModel.cpp | 1 + src/client/ObjectModel.cpp | 5 +-- src/client/PatchModel.cpp | 1 + src/client/PluginUI.cpp | 13 ++++--- src/ingen/main.cpp | 2 +- src/serialisation/Parser.cpp | 1 + src/serialisation/Serialiser.cpp | 3 +- src/server/BufferFactory.cpp | 1 + src/server/ConnectionImpl.cpp | 1 + src/server/DuplexPort.cpp | 1 + src/server/Engine.cpp | 1 + src/server/InputPort.cpp | 1 + src/server/InternalPlugin.cpp | 1 + src/server/LV2Node.cpp | 1 + src/server/LV2Plugin.cpp | 4 +-- src/server/Notification.cpp | 1 + src/server/ObjectSender.cpp | 1 + src/server/OutputPort.cpp | 1 + src/server/PatchImpl.cpp | 5 +-- src/server/PortImpl.cpp | 1 + src/server/ServerInterfaceImpl.cpp | 2 ++ src/server/events/CreateNode.cpp | 6 ++-- src/server/events/CreatePatch.cpp | 4 ++- src/server/events/CreatePort.cpp | 1 + src/server/events/RegisterClient.cpp | 4 ++- src/server/events/SetMetadata.cpp | 4 ++- src/server/events/SetPortValue.cpp | 11 +++--- src/server/ingen_lv2.cpp | 25 +++++++------ src/server/internals/Controller.cpp | 4 ++- src/server/internals/Delay.cpp | 7 ++-- src/server/internals/Note.cpp | 7 ++-- src/server/internals/Trigger.cpp | 9 +++-- src/shared/Builder.cpp | 1 + src/shared/LV2Atom.cpp | 1 + src/shared/LV2URIMap.cpp | 69 +++++++++++++++++++++++++++++++----- src/shared/ResourceImpl.cpp | 1 + src/shared/URIs.cpp | 12 ------- src/shared/World.cpp | 23 ++++++++---- 38 files changed, 167 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/client/NodeModel.cpp b/src/client/NodeModel.cpp index f140057c..56ff1fdc 100644 --- a/src/client/NodeModel.cpp +++ b/src/client/NodeModel.cpp @@ -21,6 +21,7 @@ #include "ingen/Port.hpp" #include "ingen/shared/World.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ingen/client/NodeModel.hpp" using namespace std; diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index f8137a79..642df732 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -15,10 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "raul/TableImpl.hpp" #include "ingen/GraphObject.hpp" -#include "ingen/shared/LV2URIMap.hpp" #include "ingen/client/ObjectModel.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" +#include "raul/TableImpl.hpp" using namespace std; using namespace Raul; diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index 0d2e74e3..d5cc2ebf 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -19,6 +19,7 @@ #include "raul/log.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ingen/client/PatchModel.hpp" #include "ingen/client/NodeModel.hpp" diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index f69d189b..a3a2dabb 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -17,16 +17,15 @@ #include "raul/log.hpp" -#include "lv2/lv2plug.in/ns/ext/atom/atom.h" -#include "lv2/lv2plug.in/ns/ext/event/event.h" -#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h" - -#include "ingen/shared/LV2Atom.hpp" -#include "ingen/shared/LV2URIMap.hpp" - #include "ingen/client/NodeModel.hpp" #include "ingen/client/PluginUI.hpp" #include "ingen/client/PortModel.hpp" +#include "ingen/shared/LV2Atom.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" +#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h" +#include "lv2/lv2plug.in/ns/ext/event/event.h" using namespace std; using namespace Raul; diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp index 57e7b658..61d8a90e 100644 --- a/src/ingen/main.cpp +++ b/src/ingen/main.cpp @@ -114,7 +114,7 @@ main(int argc, char** argv) g_type_init(); #endif - world = new Ingen::Shared::World(&conf, argc, argv); + world = new Ingen::Shared::World(&conf, argc, argv, NULL, NULL); if (conf.option("uuid").get_string()) { world->set_jack_uuid(conf.option("uuid").get_string()); diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index b84bedae..120de4b1 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -36,6 +36,7 @@ #include "ingen/ServerInterface.hpp" #include "ingen/shared/World.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ingen/serialisation/Parser.hpp" diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 7f9b8cc3..f86c84a5 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -44,14 +44,15 @@ #include "sord/sordmm.hpp" #include "ingen/Connection.hpp" -#include "ingen/ServerInterface.hpp" #include "ingen/Node.hpp" #include "ingen/Patch.hpp" #include "ingen/Plugin.hpp" #include "ingen/Port.hpp" +#include "ingen/ServerInterface.hpp" #include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/ResourceImpl.hpp" #include "ingen/shared/Store.hpp" +#include "ingen/shared/URIs.hpp" #include "ingen/shared/World.hpp" #include "ingen/serialisation/Serialiser.hpp" diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp index 6e6474e9..f24f7270 100644 --- a/src/server/BufferFactory.cpp +++ b/src/server/BufferFactory.cpp @@ -18,6 +18,7 @@ #include #include "raul/log.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "AudioBuffer.hpp" #include "EventBuffer.hpp" #include "ObjectBuffer.hpp" diff --git a/src/server/ConnectionImpl.cpp b/src/server/ConnectionImpl.cpp index d752d4b2..bc0a5c53 100644 --- a/src/server/ConnectionImpl.cpp +++ b/src/server/ConnectionImpl.cpp @@ -20,6 +20,7 @@ #include "raul/log.hpp" #include "raul/Maid.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "AudioBuffer.hpp" #include "BufferFactory.hpp" #include "ConnectionImpl.hpp" diff --git a/src/server/DuplexPort.cpp b/src/server/DuplexPort.cpp index 8b8cf541..f2c2763b 100644 --- a/src/server/DuplexPort.cpp +++ b/src/server/DuplexPort.cpp @@ -20,6 +20,7 @@ #include #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ConnectionImpl.hpp" #include "DuplexPort.hpp" diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index ebfd73b3..d9878bee 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -29,6 +29,7 @@ #include "ingen/shared/LV2Features.hpp" #include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/Store.hpp" +#include "ingen/shared/URIs.hpp" #include "BufferFactory.hpp" #include "ClientBroadcaster.hpp" #include "ControlBindings.hpp" diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 9ab3692e..a07ef183 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -32,6 +32,7 @@ #include "ThreadManager.hpp" #include "mix.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "util.hpp" using namespace std; diff --git a/src/server/InternalPlugin.cpp b/src/server/InternalPlugin.cpp index 2be57051..773a30c6 100644 --- a/src/server/InternalPlugin.cpp +++ b/src/server/InternalPlugin.cpp @@ -18,6 +18,7 @@ #include #include #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "internals/Controller.hpp" #include "internals/Delay.hpp" #include "internals/Note.hpp" diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index ff886166..a22b0232 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -27,6 +27,7 @@ #include "raul/Array.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "AudioBuffer.hpp" #include "EventBuffer.hpp" diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 59028cfc..87669417 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -19,11 +19,11 @@ #include #include +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "raul/log.hpp" - #include "sord/sordmm.hpp" -#include "ingen/shared/LV2URIMap.hpp" #include "Driver.hpp" #include "Engine.hpp" #include "LV2Node.hpp" diff --git a/src/server/Notification.cpp b/src/server/Notification.cpp index c9ea9d00..7a44062f 100644 --- a/src/server/Notification.cpp +++ b/src/server/Notification.cpp @@ -16,6 +16,7 @@ */ #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ClientBroadcaster.hpp" #include "Notification.hpp" diff --git a/src/server/ObjectSender.cpp b/src/server/ObjectSender.cpp index 746e7642..9eac2911 100644 --- a/src/server/ObjectSender.cpp +++ b/src/server/ObjectSender.cpp @@ -18,6 +18,7 @@ #include "ObjectSender.hpp" #include "ingen/ClientInterface.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "EngineStore.hpp" #include "PatchImpl.hpp" #include "NodeImpl.hpp" diff --git a/src/server/OutputPort.cpp b/src/server/OutputPort.cpp index e2d8cd9c..11f637b3 100644 --- a/src/server/OutputPort.cpp +++ b/src/server/OutputPort.cpp @@ -22,6 +22,7 @@ #include "OutputPort.hpp" #include "ProcessContext.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" using namespace std; diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index f43abf39..c2d97d41 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -19,6 +19,9 @@ #include #include +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" +#include "ingen/shared/World.hpp" #include "raul/log.hpp" #include "ConnectionImpl.hpp" @@ -31,8 +34,6 @@ #include "PortImpl.hpp" #include "ProcessSlave.hpp" #include "ThreadManager.hpp" -#include "ingen/shared/LV2URIMap.hpp" -#include "ingen/shared/World.hpp" using namespace std; using namespace Raul; diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 03403a7a..67255e5f 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -22,6 +22,7 @@ #include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/LV2Atom.hpp" +#include "ingen/shared/URIs.hpp" #include "AudioBuffer.hpp" #include "BufferFactory.hpp" diff --git a/src/server/ServerInterfaceImpl.cpp b/src/server/ServerInterfaceImpl.cpp index cf08a8de..eb615e9a 100644 --- a/src/server/ServerInterfaceImpl.cpp +++ b/src/server/ServerInterfaceImpl.cpp @@ -19,6 +19,8 @@ #include "raul/log.hpp" +#include "ingen/shared/URIs.hpp" + #include "Driver.hpp" #include "Engine.hpp" #include "EventSource.hpp" diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp index 5fe7a86f..f043a321 100644 --- a/src/server/events/CreateNode.cpp +++ b/src/server/events/CreateNode.cpp @@ -15,11 +15,13 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "raul/log.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" +#include "raul/log.hpp" #include "sord/sordmm.hpp" -#include "ingen/shared/LV2URIMap.hpp" + #include "CreateNode.hpp" #include "PatchImpl.hpp" #include "NodeImpl.hpp" diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp index 6e261755..4f85be8d 100644 --- a/src/server/events/CreatePatch.cpp +++ b/src/server/events/CreatePatch.cpp @@ -15,9 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" -#include "ingen/shared/LV2URIMap.hpp" + #include "events/CreatePatch.hpp" #include "PatchImpl.hpp" #include "NodeImpl.hpp" diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 4f4753d3..39aed9d2 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -20,6 +20,7 @@ #include "raul/Maid.hpp" #include "raul/Path.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ClientBroadcaster.hpp" #include "ControlBindings.hpp" #include "CreatePort.hpp" diff --git a/src/server/events/RegisterClient.cpp b/src/server/events/RegisterClient.cpp index d95cc19c..088cf296 100644 --- a/src/server/events/RegisterClient.cpp +++ b/src/server/events/RegisterClient.cpp @@ -15,11 +15,13 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" + #include "ClientBroadcaster.hpp" #include "Driver.hpp" #include "Engine.hpp" #include "events/RegisterClient.hpp" -#include "ingen/shared/LV2URIMap.hpp" using namespace Raul; diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index 0603a150..5b2391bd 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -22,6 +22,9 @@ #include "raul/log.hpp" #include "raul/Maid.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" + #include "ClientBroadcaster.hpp" #include "ControlBindings.hpp" #include "CreateNode.hpp" @@ -37,7 +40,6 @@ #include "PortType.hpp" #include "SetMetadata.hpp" #include "SetPortValue.hpp" -#include "ingen/shared/LV2URIMap.hpp" #define LOG(s) s << "[SetMetadata] " diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index bc4cd9bf..30478f5f 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -16,12 +16,15 @@ */ #include -#include "raul/log.hpp" -#include "lv2/lv2plug.in/ns/ext/event/event.h" -#include "ingen/shared/LV2URIMap.hpp" -#include "ingen/shared/LV2Features.hpp" + #include "ingen/shared/LV2Atom.hpp" +#include "ingen/shared/LV2Features.hpp" +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "ingen/shared/World.hpp" +#include "lv2/lv2plug.in/ns/ext/event/event.h" +#include "raul/log.hpp" + #include "AudioBuffer.hpp" #include "ClientBroadcaster.hpp" #include "ControlBindings.hpp" diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index db8a642e..23aa3715 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -278,24 +278,27 @@ ingen_instantiate(const LV2_Descriptor* descriptor, return NULL; } - IngenPlugin* plugin = (IngenPlugin*)malloc(sizeof(IngenPlugin)); - plugin->conf = new Ingen::Shared::Configuration(&plugin->forge); - plugin->world = new Ingen::Shared::World(plugin->conf, - plugin->argc, - plugin->argv); - if (!plugin->world->load_module("serialisation")) { - delete plugin->world; - return NULL; - } - plugin->main = NULL; - plugin->map = NULL; + IngenPlugin* plugin = (IngenPlugin*)malloc(sizeof(IngenPlugin)); + plugin->conf = new Ingen::Shared::Configuration(&plugin->forge); + plugin->main = NULL; + plugin->map = NULL; + LV2_URID_Unmap* unmap = NULL; for (int i = 0; features[i]; ++i) { if (!strcmp(features[i]->URI, LV2_URID_URI "#map")) { plugin->map = (LV2_URID_Map*)features[i]->data; + } else if (!strcmp(features[i]->URI, LV2_URID_URI "#unmap")) { + unmap = (LV2_URID_Unmap*)features[i]->data; } } + plugin->world = new Ingen::Shared::World( + plugin->conf, plugin->argc, plugin->argv, plugin->map, unmap); + if (!plugin->world->load_module("serialisation")) { + delete plugin->world; + return NULL; + } + SharedPtr engine(new Server::Engine(plugin->world)); plugin->world->set_local_engine(engine); plugin->main = new MainThread(engine); diff --git a/src/server/internals/Controller.cpp b/src/server/internals/Controller.cpp index f29951c8..e93d5f27 100644 --- a/src/server/internals/Controller.cpp +++ b/src/server/internals/Controller.cpp @@ -16,9 +16,11 @@ */ #include -#include "raul/midi_events.h" + #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "internals/Controller.hpp" +#include "raul/midi_events.h" #include "AudioBuffer.hpp" #include "EventBuffer.hpp" diff --git a/src/server/internals/Delay.cpp b/src/server/internals/Delay.cpp index e3be103a..21cc23d5 100644 --- a/src/server/internals/Delay.cpp +++ b/src/server/internals/Delay.cpp @@ -17,11 +17,14 @@ #include #include -#include "raul/log.hpp" + +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "raul/Array.hpp" #include "raul/Maid.hpp" +#include "raul/log.hpp" #include "raul/midi_events.h" -#include "ingen/shared/LV2URIMap.hpp" + #include "internals/Delay.hpp" #include "AudioBuffer.hpp" #include "Driver.hpp" diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index fc88038b..a44c0c36 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -16,11 +16,14 @@ */ #include -#include "raul/log.hpp" + +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "raul/Array.hpp" #include "raul/Maid.hpp" +#include "raul/log.hpp" #include "raul/midi_events.h" -#include "ingen/shared/LV2URIMap.hpp" + #include "internals/Note.hpp" #include "AudioBuffer.hpp" #include "Driver.hpp" diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp index ccab41f2..885144fe 100644 --- a/src/server/internals/Trigger.cpp +++ b/src/server/internals/Trigger.cpp @@ -16,18 +16,21 @@ */ #include + +#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "raul/log.hpp" #include "raul/midi_events.h" -#include "ingen/shared/LV2URIMap.hpp" -#include "internals/Trigger.hpp" + #include "AudioBuffer.hpp" #include "EventBuffer.hpp" #include "InputPort.hpp" #include "InternalPlugin.hpp" #include "OutputPort.hpp" #include "ProcessContext.hpp" -#include "util.hpp" #include "ingen_config.h" +#include "internals/Trigger.hpp" +#include "util.hpp" #define LOG(s) s << "[TriggerNode] " diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp index 3672e388..9dea08f0 100644 --- a/src/shared/Builder.cpp +++ b/src/shared/Builder.cpp @@ -26,6 +26,7 @@ #include "ingen/Port.hpp" #include "ingen/shared/Builder.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" using namespace std; using namespace Raul; diff --git a/src/shared/LV2Atom.cpp b/src/shared/LV2Atom.cpp index 991c4f7c..63686bf5 100644 --- a/src/shared/LV2Atom.cpp +++ b/src/shared/LV2Atom.cpp @@ -18,6 +18,7 @@ #include "ingen/shared/LV2Atom.hpp" #include "ingen/shared/LV2Features.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" #include "raul/Atom.hpp" diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp index d39f0b88..43a949a8 100644 --- a/src/shared/LV2URIMap.cpp +++ b/src/shared/LV2URIMap.cpp @@ -35,20 +35,45 @@ using namespace Raul; namespace Ingen { namespace Shared { -LV2URIMap::LV2URIMap(URIs& uris) - : _uris(uris) +LV2URIMap::LV2URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap) + : _uri_map_feature(new URIMapFeature(this)) + , _urid_map_feature(new URIDMapFeature(this, map)) + , _urid_unmap_feature(new URIDUnmapFeature(this, unmap)) { - uri_map_feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id; - uri_map_feature_data.callback_data = this; - uri_map_feature.URI = LV2_URI_MAP_URI; - uri_map_feature.data = &uri_map_feature_data; +} + +LV2URIMap::URIMapFeature::URIMapFeature(LV2URIMap* map) + : Feature(LV2_URI_MAP_URI, &_feature_data) +{ + _feature_data.uri_to_id = &LV2URIMap::uri_map_uri_to_id; + _feature_data.callback_data = map; +} + +LV2URIMap::URIDMapFeature::URIDMapFeature(LV2URIMap* map, + LV2_URID_Map* urid_map) + : Feature(LV2_URID__map, urid_map ? urid_map : &_feature_data) +{ + if (!urid_map) { + _feature_data.map = &LV2URIMap::urid_map; + _feature_data.handle = map; + } +} + +LV2URIMap::URIDUnmapFeature::URIDUnmapFeature(LV2URIMap* map, + LV2_URID_Unmap* urid_unmap) + : Feature(LV2_URID__unmap, urid_unmap ? urid_unmap : &_feature_data) +{ + if (!urid_unmap) { + _feature_data.unmap = &LV2URIMap::urid_unmap; + _feature_data.handle = map; + } } uint32_t LV2URIMap::uri_to_id(const char* map, const char* uri) { - const uint32_t id = _uris.map_uri(uri); + const uint32_t id = map_uri(uri); if (map && !strcmp(map, LV2_EVENT_URI)) { GlobalToEvent::iterator i = _global_to_event.find(id); if (i != _global_to_event.end()) { @@ -79,9 +104,9 @@ LV2URIMap::id_to_uri(const char* map, error << "Failed to unmap event URI " << id << endl; return NULL; } - return _uris.unmap_uri(i->second); + return unmap_uri(i->second); } else { - return _uris.unmap_uri(id); + return unmap_uri(id); } } @@ -114,5 +139,31 @@ LV2URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data, return me->uri_to_id(map, uri); } +LV2_URID +LV2URIMap::urid_map(LV2_URID_Map_Handle handle, const char* uri) +{ + LV2URIMap* me = (LV2URIMap*)handle; + return me->uri_to_id(NULL, uri); +} + +const char* +LV2URIMap::urid_unmap(LV2_URID_Map_Handle handle, LV2_URID urid) +{ + LV2URIMap* me = (LV2URIMap*)handle; + return me->id_to_uri(NULL, urid); +} + +uint32_t +LV2URIMap::map_uri(const char* uri) +{ + return static_cast(g_quark_from_string(uri)); +} + +const char* +LV2URIMap::unmap_uri(uint32_t urid) +{ + return g_quark_to_string(urid); +} + } // namespace Shared } // namespace Ingen diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index fb50ac54..de3eae17 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -19,6 +19,7 @@ #include "raul/Atom.hpp" #include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/ResourceImpl.hpp" +#include "ingen/shared/URIs.hpp" using namespace std; using namespace Raul; diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp index bb2142e1..058049df 100644 --- a/src/shared/URIs.cpp +++ b/src/shared/URIs.cpp @@ -119,17 +119,5 @@ URIs::URIs(Raul::Forge& f) { } -uint32_t -URIs::map_uri(const char* uri) -{ - return static_cast(g_quark_from_string(uri)); -} - -const char* -URIs::unmap_uri(uint32_t urid) -{ - return g_quark_to_string(urid); -} - } // namespace Shared } // namespace Ingen diff --git a/src/shared/World.cpp b/src/shared/World.cpp index cf21cd44..140dd688 100644 --- a/src/shared/World.cpp +++ b/src/shared/World.cpp @@ -32,6 +32,7 @@ #include "ingen/shared/runtime_paths.hpp" #include "ingen/shared/LV2Features.hpp" #include "ingen/shared/LV2URIMap.hpp" +#include "ingen/shared/URIs.hpp" #define LOG(s) s << "[Module] " @@ -98,19 +99,25 @@ ingen_load_module(const string& name) class World::Pimpl { public: - Pimpl(Raul::Configuration* conf, int& a_argc, char**& a_argv) + Pimpl(Raul::Configuration* conf, + int& a_argc, + char**& a_argv, + LV2_URID_Map* map, + LV2_URID_Unmap* unmap) : argc(a_argc) , argv(a_argv) , conf(conf) , lv2_features(NULL) , forge(new Raul::Forge()) , rdf_world(new Sord::World()) + , lv2_uri_map(new Ingen::Shared::LV2URIMap(map, unmap)) , uris(new Shared::URIs(*forge)) - , lv2_uri_map(new Ingen::Shared::LV2URIMap(*uris.get())) , lilv_world(lilv_world_new()) { lv2_features = new Ingen::Shared::LV2Features(); - lv2_features->add_feature(lv2_uri_map); + lv2_features->add_feature(lv2_uri_map->uri_map_feature()); + lv2_features->add_feature(lv2_uri_map->urid_map_feature()); + lv2_features->add_feature(lv2_uri_map->urid_unmap_feature()); lilv_world_load_all(lilv_world); // Set up RDF namespaces @@ -167,8 +174,8 @@ public: LV2Features* lv2_features; Raul::Forge* forge; Sord::World* rdf_world; - SharedPtr uris; SharedPtr lv2_uri_map; + SharedPtr uris; SharedPtr engine; SharedPtr local_engine; SharedPtr serialiser; @@ -178,8 +185,12 @@ public: std::string jack_uuid; }; -World::World(Raul::Configuration* conf, int& argc, char**& argv) - : _impl(new Pimpl(conf, argc, argv)) +World::World(Raul::Configuration* conf, + int& argc, + char**& argv, + LV2_URID_Map* map, + LV2_URID_Unmap* unmap) + : _impl(new Pimpl(conf, argc, argv, map, unmap)) { } -- cgit v1.2.1