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 --- include/ingen/client/ClientStore.hpp | 2 + include/ingen/shared/LV2URIMap.hpp | 71 +++++++++++++++++++++++++++-------- include/ingen/shared/ResourceImpl.hpp | 6 +-- include/ingen/shared/URIs.hpp | 3 -- include/ingen/shared/World.hpp | 9 ++++- 5 files changed, 69 insertions(+), 22 deletions(-) (limited to 'include/ingen') diff --git a/include/ingen/client/ClientStore.hpp b/include/ingen/client/ClientStore.hpp index 12392db6..b6042086 100644 --- a/include/ingen/client/ClientStore.hpp +++ b/include/ingen/client/ClientStore.hpp @@ -36,6 +36,8 @@ namespace Raul { class Atom; } namespace Ingen { +namespace Shared { class URIs; } + class GraphObject; namespace Client { diff --git a/include/ingen/shared/LV2URIMap.hpp b/include/ingen/shared/LV2URIMap.hpp index 98508fd1..fc41f3bf 100644 --- a/include/ingen/shared/LV2URIMap.hpp +++ b/include/ingen/shared/LV2URIMap.hpp @@ -24,22 +24,62 @@ #include #include "ingen/shared/LV2Features.hpp" -#include "ingen/shared/URIs.hpp" #include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" +#include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "raul/URI.hpp" namespace Ingen { namespace Shared { -/** Implementation of the LV2 URI Map extension - */ -class LV2URIMap : public boost::noncopyable, public LV2Features::Feature { +/** URI to Integer Map */ +class LV2URIMap : public boost::noncopyable { public: - LV2URIMap(URIs& uris); - - SharedPtr feature(Shared::World*, Node*) { - return SharedPtr(&uri_map_feature, NullDeleter); - } + LV2URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap); + virtual ~LV2URIMap() {} + + uint32_t map_uri(const char* uri); + const char* unmap_uri(uint32_t urid); + + class Feature : public LV2Features::Feature { + public: + Feature(const char* URI, void* data) { + _feature.URI = URI; + _feature.data = data; + } + + SharedPtr feature(Shared::World*, Node*) { + return SharedPtr(&_feature, NullDeleter); + } + + private: + LV2_Feature _feature; + }; + + class URIMapFeature : public Feature { + public: + URIMapFeature(LV2URIMap* map); + + private: + LV2_URI_Map_Feature _feature_data; + }; + + class URIDMapFeature : public Feature { + public: + URIDMapFeature(LV2URIMap* map, LV2_URID_Map* urid_map); + private: + LV2_URID_Map _feature_data; + }; + + class URIDUnmapFeature : public Feature { + public: + URIDUnmapFeature(LV2URIMap* map, LV2_URID_Unmap* urid_unmap); + private: + LV2_URID_Unmap _feature_data; + }; + + SharedPtr uri_map_feature() { return _uri_map_feature; } + SharedPtr urid_map_feature() { return _urid_map_feature; } + SharedPtr urid_unmap_feature() { return _urid_unmap_feature; } virtual uint32_t uri_to_id(const char* map, const char* uri); virtual const char* id_to_uri(const char* map, uint32_t id); @@ -52,16 +92,17 @@ private: const char* map, const char* uri); - LV2_Feature uri_map_feature; - LV2_URI_Map_Feature uri_map_feature_data; + static LV2_URID urid_map(LV2_URID_Map_Handle handle, const char* uri); + static const char* urid_unmap(LV2_URID_Map_Handle handle, LV2_URID urid); typedef std::map EventToGlobal; typedef std::map GlobalToEvent; - EventToGlobal _event_to_global; - GlobalToEvent _global_to_event; - - URIs& _uris; + SharedPtr _uri_map_feature; + SharedPtr _urid_map_feature; + SharedPtr _urid_unmap_feature; + EventToGlobal _event_to_global; + GlobalToEvent _global_to_event; }; } // namespace Shared diff --git a/include/ingen/shared/ResourceImpl.hpp b/include/ingen/shared/ResourceImpl.hpp index fea21023..8069c480 100644 --- a/include/ingen/shared/ResourceImpl.hpp +++ b/include/ingen/shared/ResourceImpl.hpp @@ -18,10 +18,10 @@ #ifndef INGEN_SHARED_RESOURCEIMPL_HPP #define INGEN_SHARED_RESOURCEIMPL_HPP -#include "raul/URI.hpp" -#include "raul/SharedPtr.hpp" - #include "ingen/Resource.hpp" +#include "ingen/shared/URIs.hpp" +#include "raul/SharedPtr.hpp" +#include "raul/URI.hpp" namespace Ingen { namespace Shared { diff --git a/include/ingen/shared/URIs.hpp b/include/ingen/shared/URIs.hpp index 01464589..7490526d 100644 --- a/include/ingen/shared/URIs.hpp +++ b/include/ingen/shared/URIs.hpp @@ -33,9 +33,6 @@ class URIs : public boost::noncopyable { public: URIs(Raul::Forge& forge); - uint32_t map_uri(const char* uri); - const char* unmap_uri(uint32_t urid); - struct Quark : public Raul::URI { Quark(const char* str); const char* c_str() const; diff --git a/include/ingen/shared/World.hpp b/include/ingen/shared/World.hpp index fba565e5..e062dea6 100644 --- a/include/ingen/shared/World.hpp +++ b/include/ingen/shared/World.hpp @@ -23,6 +23,8 @@ #include #include +#include "lv2/lv2plug.in/ns/ext/urid/urid.h" + #include "raul/Configuration.hpp" #include "raul/SharedPtr.hpp" @@ -56,7 +58,12 @@ class Store; */ class World : public boost::noncopyable { public: - World(Raul::Configuration* conf, int& argc, char**& argv); + World(Raul::Configuration* conf, + int& argc, + char**& argv, + LV2_URID_Map* map, + LV2_URID_Unmap* unmap); + virtual ~World(); virtual bool load_module(const char* name); -- cgit v1.2.1