rtVTK  0.6.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Classes | Public Member Functions | Private Attributes
rtVTK::PluginManager Class Reference

Creates and manages plugins. More...

List of all members.

Classes

struct  dpWrap
 Wrapper class for use in PluginManager. More...

Public Member Functions

 PluginManager ()
 ~PluginManager ()
Pluginload (const string &, bool verbose=true)
bool unload (const string &)
bool findValidDLLs (vector< string > &, const QDir &)
PlugingetPluginByName (const string &)
vector< string > getInitPluginNames ()

Private Attributes

map< string, dpWrapplugins

Detailed Description

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.

Author:
QuigleyEJ1

Constructor & Destructor Documentation

A no-op default constructor

Destructor calls each initialized Plugin's close function, deletes the Plugin pointer, and frees the DLL.

References plugins.


Member Function Documentation

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.

Parameters:
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.
Returns:
bool - true if dir is a valid path; false otherwise.
Bug:
XXX(cpg) - currently ignored

References load(), and rtVTK::Plugin::name.

Referenced by rtVTK::MainWindow::MainWindow().

Compiles and returns a vector of names of plugins whose initialized flag is set to true.

Returns:
vector<string> - a vector of names of plugins that have been initialized.

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.

Parameters:
name: const string& - name of plugin to be returned.
Returns:
Plugin* - a pointer to the plugin with a given name.

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*.

Parameters:
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.
Returns:
Plugin* - pointer to a successfully loaded plugin, or a null pointer if load was unsuccessful.
Todo:
TODO(cpg) - consider a possible interface refinement to allow for error handling:


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.

Parameters:
name: const string& - name of plugin to be unloaded.
Returns:
bool - true if name corresponds to a valid plugin; false otherwise.

References rtVTK::Plugin::callClose(), rtVTK::Plugin::initialized, and plugins.

Referenced by rtVTK::MainWindow::slotUnloadDLL().


Member Data Documentation

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends