diff options
author | David Robillard <d@drobilla.net> | 2012-05-02 19:33:26 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-02 19:33:26 +0000 |
commit | c4fce4b2214cc88978c182d9bdbd4d3bfdf48eca (patch) | |
tree | 9d765beb38dee7e12f9409ac5e40dcb50594f337 | |
parent | f3d50e437022f0d2aabcaea056a8203afc3e32c3 (diff) | |
download | ingen-c4fce4b2214cc88978c182d9bdbd4d3bfdf48eca.tar.gz ingen-c4fce4b2214cc88978c182d9bdbd4d3bfdf48eca.tar.bz2 ingen-c4fce4b2214cc88978c182d9bdbd4d3bfdf48eca.zip |
On-demand loading of individual plugins.
This makes it possible to load a patch, particularly when running as a plugin,
without loading every LV2 plugin on the system.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4313 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/server/NodeFactory.cpp | 21 | ||||
-rw-r--r-- | src/server/NodeFactory.hpp | 5 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/server/NodeFactory.cpp b/src/server/NodeFactory.cpp index 94282fef..ea8132d1 100644 --- a/src/server/NodeFactory.cpp +++ b/src/server/NodeFactory.cpp @@ -50,8 +50,8 @@ using namespace Internals; NodeFactory::NodeFactory(Ingen::Shared::World* world) : _world(world) - , _has_loaded(false) , _lv2_info(new LV2Info(world)) + , _has_loaded(false) { } @@ -76,6 +76,7 @@ NodeFactory::plugins() PluginImpl* NodeFactory::plugin(const Raul::URI& uri) { + load_plugin(uri); const Plugins::const_iterator i = _plugins.find(uri); return ((i != _plugins.end()) ? i->second : NULL); } @@ -113,13 +114,29 @@ NodeFactory::load_internal_plugins() _plugins.insert(make_pair(trigger_plug->uri(), trigger_plug)); } +void +NodeFactory::load_plugin(const Raul::URI& uri) +{ + if (_has_loaded || _plugins.find(uri) != _plugins.end()) { + return; + } + + LilvNode* node = lilv_new_uri(_world->lilv_world(), uri.c_str()); + const LilvPlugins* plugs = lilv_world_get_all_plugins(_world->lilv_world()); + const LilvPlugin* plug = lilv_plugins_get_by_uri(plugs, node); + if (plug) { + LV2Plugin* const ingen_plugin = new LV2Plugin(_lv2_info, uri.str()); + ingen_plugin->lilv_plugin(plug); + _plugins.insert(make_pair(uri, ingen_plugin)); + } +} + /** Loads information about all LV2 plugins into internal plugin database. */ void NodeFactory::load_lv2_plugins() { const LilvPlugins* plugins = lilv_world_get_all_plugins(_world->lilv_world()); - LILV_FOREACH(plugins, i, plugins) { const LilvPlugin* lv2_plug = lilv_plugins_get(plugins, i); diff --git a/src/server/NodeFactory.hpp b/src/server/NodeFactory.hpp index 37e46ddb..2188266b 100644 --- a/src/server/NodeFactory.hpp +++ b/src/server/NodeFactory.hpp @@ -42,6 +42,7 @@ public: explicit NodeFactory(Ingen::Shared::World* world); ~NodeFactory(); + void load_plugin(const Raul::URI& uri); void load_plugins(); typedef std::map<Raul::URI, PluginImpl*> Plugins; @@ -55,10 +56,8 @@ private: Plugins _plugins; Ingen::Shared::World* _world; - bool _has_loaded; - SharedPtr<LV2Info> _lv2_info; - + bool _has_loaded; }; } // namespace Server |