Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/hostext/PluginLoader.h @ 59:fa79c4ec847d host-factory-stuff
* Put hostext stuff in the HostExt sub-namespace
* Tidy up system-specific stuff in PluginLoader
* Make PluginLoader return a deletion-notifying wrapper which permits the
library to be unloaded when no longer in use
* Add PluginChannelAdapter
* Make vamp-simple-host use PluginChannelAdapter, and use the PluginLoader
for plugin-running task. Also some other enhancements to host
author | cannam |
---|---|
date | Thu, 24 May 2007 15:17:07 +0000 |
parents | 0284955e31e5 |
children | 087c16cca0d6 |
comparison
equal
deleted
inserted
replaced
58:0284955e31e5 | 59:fa79c4ec847d |
---|---|
39 | 39 |
40 #include <vector> | 40 #include <vector> |
41 #include <string> | 41 #include <string> |
42 #include <map> | 42 #include <map> |
43 | 43 |
44 #include "PluginWrapper.h" | |
45 | |
44 namespace Vamp { | 46 namespace Vamp { |
45 | 47 |
46 class Plugin; | 48 class Plugin; |
47 | 49 |
50 namespace HostExt { | |
51 | |
48 class PluginLoader | 52 class PluginLoader |
49 { | 53 { |
50 public: | 54 public: |
51 PluginLoader(); | 55 static PluginLoader *getInstance(); |
52 virtual ~PluginLoader(); | |
53 | 56 |
54 typedef std::string PluginKey; | 57 typedef std::string PluginKey; |
55 typedef std::vector<std::string> PluginCategoryHierarchy; | 58 typedef std::vector<std::string> PluginCategoryHierarchy; |
56 | 59 |
57 std::vector<PluginKey> listPlugins(); //!!! pass in version number? | 60 std::vector<PluginKey> listPlugins(); //!!! pass in version number? |
58 | 61 |
59 //!!! want to be able to just "delete" the plugin later -- hence | 62 PluginKey composePluginKey(std::string libraryName, std::string identifier); |
60 //have to consider library loading issues -- do we have a wrapper | 63 |
61 //class that tells us when it's been deleted, and keep a reference | 64 Plugin *loadPlugin(PluginKey plugin, float inputSampleRate); |
62 //count for the dynamic library? | |
63 Plugin *load(PluginKey plugin, float inputSampleRate); | |
64 | 65 |
65 PluginCategoryHierarchy getPluginCategory(PluginKey plugin); | 66 PluginCategoryHierarchy getPluginCategory(PluginKey plugin); |
66 | 67 |
67 std::string getLibraryPathForPlugin(PluginKey plugin); | 68 std::string getLibraryPathForPlugin(PluginKey plugin); |
68 | 69 |
69 protected: | 70 protected: |
70 std::map<PluginKey, std::string> m_pluginLibraryMap; | 71 PluginLoader(); |
72 virtual ~PluginLoader(); | |
73 | |
74 class PluginDeletionNotifyAdapter : public PluginWrapper { | |
75 public: | |
76 PluginDeletionNotifyAdapter(Plugin *plugin, PluginLoader *loader); | |
77 virtual ~PluginDeletionNotifyAdapter(); | |
78 protected: | |
79 PluginLoader *m_loader; | |
80 }; | |
81 | |
82 virtual void pluginDeleted(PluginDeletionNotifyAdapter *adapter); | |
83 | |
84 std::map<PluginKey, std::string> m_pluginLibraryNameMap; | |
85 void generateLibraryMap(); | |
86 | |
71 std::map<PluginKey, PluginCategoryHierarchy> m_taxonomy; | 87 std::map<PluginKey, PluginCategoryHierarchy> m_taxonomy; |
72 void generateTaxonomy(); | 88 void generateTaxonomy(); |
73 std::vector<std::string> getFilesInDir(std::string dir, std::string ext); | 89 |
90 std::map<Plugin *, void *> m_pluginLibraryHandleMap; | |
91 | |
92 void *loadLibrary(std::string path); | |
93 void unloadLibrary(void *handle); | |
94 void *lookupInLibrary(void *handle, const char *symbol); | |
95 | |
96 std::string splicePath(std::string a, std::string b); | |
97 std::vector<std::string> listFiles(std::string dir, std::string ext); | |
98 | |
99 static PluginLoader *m_instance; | |
74 }; | 100 }; |
75 | 101 |
76 } | 102 } |
77 | 103 |
104 } | |
78 | 105 |
79 #endif | 106 #endif |
80 | 107 |