Mercurial > hg > vamp-plugin-sdk
comparison vamp-sdk/hostext/PluginLoader.h @ 62:fe5486ee1c70 host-factory-stuff
* Documentation
author | cannam |
---|---|
date | Fri, 01 Jun 2007 15:00:51 +0000 |
parents | 97c5ac99d725 |
children |
comparison
equal
deleted
inserted
replaced
61:97c5ac99d725 | 62:fe5486ee1c70 |
---|---|
47 | 47 |
48 class Plugin; | 48 class Plugin; |
49 | 49 |
50 namespace HostExt { | 50 namespace HostExt { |
51 | 51 |
52 /** | |
53 * Vamp::HostExt::PluginLoader is a convenience class for discovering | |
54 * and loading Vamp plugins using the typical plugin-path, library | |
55 * naming, and categorisation conventions described in the Vamp SDK | |
56 * documentation. This class is intended to greatly simplify the task | |
57 * of becoming a Vamp plugin host for any C++ application. | |
58 * | |
59 * Hosts are not required by the Vamp specification to use the same | |
60 * plugin search path and naming conventions as implemented by this | |
61 * class, and are certainly not required to use this actual class. | |
62 * But it's recommended, for sound practical reasons. | |
63 */ | |
64 | |
52 class PluginLoader | 65 class PluginLoader |
53 { | 66 { |
54 public: | 67 public: |
68 /** | |
69 * PluginLoader is a singleton class. This function returns a | |
70 * pointer to the single instance of it. Use this to obtain your | |
71 * loader object. | |
72 */ | |
55 static PluginLoader *getInstance(); | 73 static PluginLoader *getInstance(); |
56 | 74 |
75 /** | |
76 * PluginKey is a string type that is used to identify a plugin | |
77 * uniquely within the scope of "the current system". It consists | |
78 * of the base name of the plugin library, a colon separator, and | |
79 * the identifier string for the plugin. It is only meaningful in | |
80 * the context of a given plugin path (the one returned by | |
81 * PluginHostAdapter::getPluginPath()). | |
82 * | |
83 * Use composePluginKey to construct a plugin key from a known | |
84 * plugin library name and identifier. | |
85 */ | |
57 typedef std::string PluginKey; | 86 typedef std::string PluginKey; |
87 | |
88 /** | |
89 * PluginKeyList is a sequence of plugin keys, such as returned by | |
90 * a plugin lookup function. | |
91 */ | |
58 typedef std::vector<PluginKey> PluginKeyList; | 92 typedef std::vector<PluginKey> PluginKeyList; |
93 | |
94 /** | |
95 * PluginCategoryHierarchy is a sequence of general->specific | |
96 * category names, as may be associated with a single plugin. | |
97 * This sequence describes the location of a plugin within a | |
98 * category forest, containing the human-readable names of the | |
99 * plugin's category tree root, followed by each of the nodes down | |
100 * to the leaf containing the plugin. | |
101 */ | |
59 typedef std::vector<std::string> PluginCategoryHierarchy; | 102 typedef std::vector<std::string> PluginCategoryHierarchy; |
60 | 103 |
61 PluginKeyList listPlugins(); //!!! pass in version number? | 104 /** |
62 | 105 * Search for all available Vamp plugins, and return a list of |
63 PluginKey composePluginKey(std::string libraryName, std::string identifier); | 106 * them in the order in which they were found. |
64 | 107 */ |
108 PluginKeyList listPlugins(); | |
109 | |
110 /** | |
111 * AdapterFlags contains a set of values that may be OR'd together | |
112 * to indicate in which circumstances PluginLoader should use a | |
113 * plugin adapter to make a plugin easier to use for a host that | |
114 * does not want to cater for complex features. | |
115 * | |
116 * The available flags are: | |
117 * | |
118 * ADAPT_INPUT_DOMAIN - If the plugin expects frequency domain | |
119 * input, wrap it in a PluginInputDomainAdapter that automatically | |
120 * converts the plugin to one that expects time-domain input. | |
121 * This enables a host to accommodate time- and frequency-domain | |
122 * plugins without needing to do any conversion itself. | |
123 * | |
124 * ADAPT_CHANNEL_COUNT - Wrap the plugin in a PluginChannelAdapter | |
125 * to handle any mismatch between the number of channels of audio | |
126 * the plugin can handle and the number available in the host. | |
127 * This enables a host to use plugins that may require the input | |
128 * to be mixed down to mono, etc., without having to worry about | |
129 * doing that itself. | |
130 * | |
131 * See PluginInputDomainAdapter and PluginChannelAdapter for more | |
132 * details of the classes that the loader may use if these flags | |
133 * are set. | |
134 */ | |
65 enum AdapterFlags { | 135 enum AdapterFlags { |
66 ADAPT_INPUT_DOMAIN = 0x01, | 136 ADAPT_INPUT_DOMAIN = 0x01, |
67 ADAPT_CHANNEL_COUNT = 0x02, | 137 ADAPT_CHANNEL_COUNT = 0x02, |
68 ADAPT_ALL = 0xff | 138 ADAPT_ALL = 0xff |
69 }; | 139 }; |
70 | 140 |
71 Plugin *loadPlugin(PluginKey plugin, | 141 /** |
142 * Load a Vamp plugin, given its identifying key. If the plugin | |
143 * could not be loaded, returns 0. | |
144 * | |
145 * adapterFlags is a bitwise OR of the values in the AdapterFlags | |
146 * enum, indicating under which circumstances an adapter should be | |
147 * used to wrap the original plugin. See AdapterFlags for more | |
148 * details. If adapterFlags is 0, no optional adapters will be | |
149 * used. | |
150 * | |
151 * The returned plugin should be deleted (using the standard C++ | |
152 * delete) after use. | |
153 */ | |
154 Plugin *loadPlugin(PluginKey key, | |
72 float inputSampleRate, | 155 float inputSampleRate, |
73 int adapterFlags = 0); | 156 int adapterFlags = 0); |
74 | 157 |
158 /** | |
159 * Given a Vamp plugin library name and plugin identifier, return | |
160 * the corresponding plugin key in a form suitable for passing in to | |
161 * loadPlugin. | |
162 */ | |
163 PluginKey composePluginKey(std::string libraryName, | |
164 std::string identifier); | |
165 | |
166 /** | |
167 * Return the category hierarchy for a Vamp plugin, given its | |
168 * identifying key. See PluginCategoryHierarchy documentation for | |
169 * more details. | |
170 * | |
171 * If the plugin has no category information, return an empty | |
172 * hierarchy. | |
173 */ | |
75 PluginCategoryHierarchy getPluginCategory(PluginKey plugin); | 174 PluginCategoryHierarchy getPluginCategory(PluginKey plugin); |
76 | 175 |
176 /** | |
177 * Return the file path of the dynamic library from which the | |
178 * given plugin will be loaded (if available). | |
179 */ | |
77 std::string getLibraryPathForPlugin(PluginKey plugin); | 180 std::string getLibraryPathForPlugin(PluginKey plugin); |
78 | 181 |
79 protected: | 182 protected: |
80 PluginLoader(); | 183 PluginLoader(); |
81 virtual ~PluginLoader(); | 184 virtual ~PluginLoader(); |