Creates and manages plugins. More...
Classes | |
struct | dpWrap |
Wrapper class for use in PluginManager. More... | |
Public Member Functions | |
PluginManager () | |
~PluginManager () | |
Plugin * | load (const string &, bool verbose=true) |
bool | unload (const string &) |
bool | findValidDLLs (vector< string > &, const QDir &) |
Plugin * | getPluginByName (const string &) |
vector< string > | getInitPluginNames () |
Private Attributes | |
map< string, dpWrap > | plugins |
Creates and manages plugins.
PluginManager is responsible for the loading of DLL files containing plugin classes. According to the current implementation, exactly one object per class is permitted. Pointers to the objects and their interface functions are stored in objects of type Plugin, which are aggregated here.
PluginManager is also responsible for the destruction of Plugin objects and the unloading of DLL files.
Note that objects of plugin classes are not instantiated by PluginManager; a Plugin's callCreate() function must be invoked by a class that has knowledge of glWidget because of the requirements of a plugin class' constructor.
rtVTK::PluginManager::PluginManager | ( | ) | [inline] |
A no-op default constructor
bool rtVTK::PluginManager::findValidDLLs | ( | vector< string > & | names, |
const QDir & | dir | ||
) |
This function finds and loads all valid plugins in the directory specified by dir. The names of valid plugins are placed in names, except for special cases glRenderer and rlRenderer - these are loaded like normal plugins, but are not stored in names so that they do not appear on the Load menu. They are loaded automatically in MainWindow's constructor.
names | : vector<string>& - reference to a vector that will be populated with the names of valid plugins found. |
dir | : const string& = "plugins/" - directory to be searched for DLLs. |
References load(), and rtVTK::Plugin::name.
Referenced by rtVTK::MainWindow::MainWindow().
vector< string > rtVTK::PluginManager::getInitPluginNames | ( | ) |
Compiles and returns a vector of names of plugins whose initialized flag is set to true.
References plugins.
Referenced by rtVTK::MainWindow::slotEstablishTabsForActivePlugins(), and rtVTK::MainWindow::slotShowPipeline().
Plugin * rtVTK::PluginManager::getPluginByName | ( | const string & | name | ) |
Given a plugin name, returns a pointer to that plugin, or a null pointer if the name is new to PluginManager.
name | : const string& - name of plugin to be returned. |
References plugins.
Referenced by rtVTK::MainWindow::MainWindow(), rtVTK::MainWindow::slotEstablishTabsForActivePlugins(), rtVTK::MainWindow::slotLoadDLL(), rtVTK::MainWindow::slotSetActivePlugins(), and rtVTK::MainWindow::slotUnloadDLL().
Plugin * rtVTK::PluginManager::load | ( | const string & | path, |
bool | verbose = true |
||
) |
Given a file path, attempts to load a DLL and checks to see whether the DLL is a valid plugin (in other words, whether it conforms to the plugin interface).
If the load is successful, PluginManager adds information about the plugin to its map and returns a Plugin*.
path | : const string& - fully qualified file name of DLL to be loaded. |
verbose | : bool = true - output messages will be displayed if true; no output will be written if false. |
bool load(Plugin&, const string&);
References rtVTK::Plugin::closer, rtVTK::Plugin::create, rtVTK::Plugin::idle, rtVTK::Plugin::init, rtVTK::Plugin::name, plugins, rtVTK::Plugin::render, rtVTK::Plugin::requiresTab, rtVTK::Plugin::resize, and rtVTK::Plugin::traceRay.
Referenced by findValidDLLs().
bool rtVTK::PluginManager::unload | ( | const string & | name | ) |
This function is not a true "unload" - no library is freed. The function just performs some cleanup so that a plugin will be created anew if it is reloaded from the menu.
name | : const string& - name of plugin to be unloaded. |
References rtVTK::Plugin::callClose(), rtVTK::Plugin::initialized, and plugins.
Referenced by rtVTK::MainWindow::slotUnloadDLL().
map<string,dpWrap> rtVTK::PluginManager::plugins [private] |
Maps a Plugin's name to dpWrap, a struct that aggregates a dll_t (for use with OS-dependant loading/unloading function calls), a Plugin*, and a DLL filename.
Referenced by getInitPluginNames(), getPluginByName(), load(), unload(), and ~PluginManager().