#include <Pt/System/Plugin.h>
Manages loaded plugins. More...
Classes | |
| class | Iterator |
| Iterator for loaded plugins. More... | |
Public Member Functions | |
| PluginManager () | |
| Default Constructor. | |
| ~PluginManager () | |
| Destructor. | |
| void | loadPlugin (const std::string &sym, const Path &path) |
| Loads plugins from a library. | |
| void | registerPlugin (PluginT &plugin) |
| Registers a plugin. | |
| void | unregisterPlugin (PluginT &plugin) |
| Unregisters a plugin. | |
| IfaceT * | create (const std::string &feature) |
| Creates an instance by name. | |
| IfaceT * | create (const Iterator &feature) |
| Creates an instance. | |
| void | destroy (IfaceT *inst) |
| Destroys an instance. | |
| Iterator | begin () const |
| Begin of loaded plugins. | |
| Iterator | end () const |
| End of loaded plugins. | |
PluginManager loads a PluginList from a Library and creates instances of one interface. The first template argument is that interface.
loadPlugin() opens the library and resolves the export name. The name PluginList is the usual export. Another symbol name is valid if the library exports that array.
A loaded plugin is registered when its interface matches the manager. Entries for other interfaces in the same PluginList are skipped. Plugins that already live in the process can be registered with registerPlugin(). They do not require a shared library.
destroy() must be used instead of delete. The allocator in the library may differ from the application. Creation and deletion stay on the same plugin. Remaining instances are destroyed and loaded libraries are unloaded when the manager is destroyed. Instance lifetime must not exceed the manager.
Iteration walks the loaded plugins without creating instances. create() also accepts an iterator from that walk.