BasicPluginManager< T > Class Template Reference

#include <BasicPluginManager.h>

Collaboration diagram for BasicPluginManager< T >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::list
< BasicPluginInfo * > 
infos_t

Public Member Functions

 BasicPluginManager (bool preloadDeps=false)
virtual ~BasicPluginManager ()
virtual void init (T *plugin)
void destroyPlugin (std::string pluginName)
void unload ()
 Deallocate all plugins in the correct order.
void closeLibraries ()
 Close all shared library handles.
bool dependsOn (std::string plugin1, std::string plugin2)
T * get (const std::string pluginName, bool *_pluginAlreadyRegisteredFlag=0)
bool isLoaded (std::string pluginName)
 
Returns:
True if plugin with name

const BasicPluginInfogetPluginInfo (const std::string pluginName)
 
Returns:
A reference to the named plugins info structure.

infos_tgetPluginInfos ()
void loadLibraries (const std::string path)
void loadLibrary (const std::string filename)
void registerPlugin (BasicPluginInfo *info, BasicClassFactoryBase< T > *factory)
void setPluginException (BasicException e)

Static Public Attributes

static const char libExtension [] = ".so"
 May need to ifdef this for windows dlls.

Protected Member Functions

BasicClassFactoryBase
< T > * 
getPluginFactory (const std::string pluginName)
 
Returns:
A reference to the named plugin's factory.

plugins_tgetPluginMapBPM ()
void loadSingleLibraryPath (const std::string path)

Private Types

typedef std::map
< std::string,
BasicClassFactoryBase
< T > * > 
factories_t
typedef std::map
< std::string,
BasicPluginInfo * > 
infoMap_t
typedef std::map
< std::string, T * > 
plugins_t
typedef std::map
< std::string, void * > 
libraryHandles_t

Private Attributes

factories_t factories
 A map from plugin name to registered factory.
infoMap_t infoMap
 A map from plugin name to registered info.
plugins_t plugins
 A map from plugin name to plugin instance.
libraryHandles_t libraryHandles
 A map of loaded library handles.
infos_t infos
 A list of plugin info structures.
BasicExceptionpluginException
 Holds exceptions thrown by plugins on dlopen.
bool preloadDeps
 If true dependencies will be loaded first.


Detailed Description

template<class T>
class BasicPluginManager< T >

Definition at line 40 of file BasicPluginManager.h.


Member Typedef Documentation

template<class T>
typedef std::list<BasicPluginInfo *> BasicPluginManager< T >::infos_t

Definition at line 42 of file BasicPluginManager.h.

template<class T>
typedef std::map<std::string, BasicClassFactoryBase<T> *> BasicPluginManager< T >::factories_t [private]

Definition at line 46 of file BasicPluginManager.h.

template<class T>
typedef std::map<std::string, BasicPluginInfo *> BasicPluginManager< T >::infoMap_t [private]

Definition at line 47 of file BasicPluginManager.h.

template<class T>
typedef std::map<std::string, T *> BasicPluginManager< T >::plugins_t [private]

Reimplemented in CompuCell3D::PluginManager< PluginType >, CompuCell3D::PluginManager< CompuCell3D::Steppable >, and CompuCell3D::PluginManager< CompuCell3D::Plugin >.

Definition at line 48 of file BasicPluginManager.h.

template<class T>
typedef std::map<std::string, void *> BasicPluginManager< T >::libraryHandles_t [private]

Definition at line 49 of file BasicPluginManager.h.


Constructor & Destructor Documentation

template<class T>
BasicPluginManager< T >::BasicPluginManager ( bool  preloadDeps = false  )  [inline]

Definition at line 77 of file BasicPluginManager.h.

template<class T>
virtual BasicPluginManager< T >::~BasicPluginManager (  )  [inline, virtual]

Destruct the plugin manager. Deallocates all plugins and closes all plugin libraries.

Definition at line 84 of file BasicPluginManager.h.


Member Function Documentation

template<class T>
virtual void BasicPluginManager< T >::init ( T *  plugin  )  [inline, virtual]

Initialization function called when a plugin is first loaded. Child classes should over load this function for type specific plugin initialization.

Parameters:
plugin The plugin to initialize.

Reimplemented in CompuCell3D::PluginManager< PluginType >, CompuCell3D::PluginManager< CompuCell3D::Steppable >, and CompuCell3D::PluginManager< CompuCell3D::Plugin >.

Definition at line 107 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::get().

template<class T>
void BasicPluginManager< T >::destroyPlugin ( std::string  pluginName  )  [inline]

Deallocate a specific plugin.

Definition at line 112 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::destroyPlugin(), and BasicPluginManager< CompuCell3D::Plugin >::unload().

template<class T>
void BasicPluginManager< T >::unload (  )  [inline]

Deallocate all plugins in the correct order.

Definition at line 130 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::~BasicPluginManager().

template<class T>
void BasicPluginManager< T >::closeLibraries (  )  [inline]

Close all shared library handles.

Definition at line 138 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::~BasicPluginManager().

template<class T>
bool BasicPluginManager< T >::dependsOn ( std::string  plugin1,
std::string  plugin2 
) [inline]

If plugin1 has not yet been registered this function will return false;

Returns:
True if plugin1 has plugin2 in its dependency list, false otherwise.

Definition at line 152 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::dependsOn(), BasicPluginManager< CompuCell3D::Plugin >::destroyPlugin(), and BasicPluginManager< CompuCell3D::Plugin >::registerPlugin().

template<class T>
T* BasicPluginManager< T >::get ( const std::string  pluginName,
bool *  _pluginAlreadyRegisteredFlag = 0 
) [inline]

Get a pointer to a named plugin. If an instance has not yet been allocated it will be created. If the plugin name is unknown a BasicException will be thrown.

Parameters:
pluginName The name of the plugin.
Returns:
A pointer to the named plugin.

Definition at line 174 of file BasicPluginManager.h.

template<class T>
bool BasicPluginManager< T >::isLoaded ( std::string  pluginName  )  [inline]

Returns:
True if plugin with name

Parameters:
pluginName is loaded.

Definition at line 206 of file BasicPluginManager.h.

template<class T>
const BasicPluginInfo* BasicPluginManager< T >::getPluginInfo ( const std::string  pluginName  )  [inline]

Returns:
A reference to the named plugins info structure.

Definition at line 211 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::get().

template<class T>
infos_t& BasicPluginManager< T >::getPluginInfos (  )  [inline]

Returns:
A list of registered plugin information structures.

Definition at line 222 of file BasicPluginManager.h.

template<class T>
void BasicPluginManager< T >::loadLibraries ( const std::string  path  )  [inline]

Loads all plugin libraries on a ':' separated path list.

Parameters:
path The plugin library path list.

Definition at line 230 of file BasicPluginManager.h.

template<class T>
void BasicPluginManager< T >::loadLibrary ( const std::string  filename  )  [inline]

Load a plugin library.

Parameters:
filename Path to plugin library.

Definition at line 248 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::loadSingleLibraryPath().

template<class T>
void BasicPluginManager< T >::registerPlugin ( BasicPluginInfo info,
BasicClassFactoryBase< T > *  factory 
) [inline]

Called by BasicPluginProxy to register itself with the manager.

Parameters:
info A pointer to a new plugin info structure.
factory A pointer to a new plugin class factory.

Definition at line 280 of file BasicPluginManager.h.

Referenced by BasicPluginProxy< B, T >::init().

template<class T>
void BasicPluginManager< T >::setPluginException ( BasicException  e  )  [inline]

Used by statically allocated plugins to pass any exceptions back to the library loader.

Definition at line 312 of file BasicPluginManager.h.

Referenced by BasicPluginProxy< B, T >::init().

template<class T>
BasicClassFactoryBase<T>* BasicPluginManager< T >::getPluginFactory ( const std::string  pluginName  )  [inline, protected]

Returns:
A reference to the named plugin's factory.

Definition at line 322 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::destroyPlugin(), and BasicPluginManager< CompuCell3D::Plugin >::get().

template<class T>
plugins_t& BasicPluginManager< T >::getPluginMapBPM (  )  [inline, protected]

Definition at line 330 of file BasicPluginManager.h.

Referenced by CompuCell3D::PluginManager< CompuCell3D::Plugin >::getPluginMap().

template<class T>
void BasicPluginManager< T >::loadSingleLibraryPath ( const std::string  path  )  [inline, protected]

Loads all libraries on a single path.

Parameters:
path A single path.

Definition at line 336 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::loadLibraries().


Member Data Documentation

template<class T>
factories_t BasicPluginManager< T >::factories [private]

A map from plugin name to registered factory.

Definition at line 52 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::getPluginFactory(), BasicPluginManager< CompuCell3D::Plugin >::registerPlugin(), and BasicPluginManager< CompuCell3D::Plugin >::~BasicPluginManager().

template<class T>
infoMap_t BasicPluginManager< T >::infoMap [private]

A map from plugin name to registered info.

Definition at line 55 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::dependsOn(), BasicPluginManager< CompuCell3D::Plugin >::getPluginInfo(), and BasicPluginManager< CompuCell3D::Plugin >::registerPlugin().

template<class T>
plugins_t BasicPluginManager< T >::plugins [private]

A map from plugin name to plugin instance.

Definition at line 58 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::destroyPlugin(), BasicPluginManager< CompuCell3D::Plugin >::get(), BasicPluginManager< CompuCell3D::Plugin >::getPluginMapBPM(), BasicPluginManager< CompuCell3D::Plugin >::isLoaded(), and BasicPluginManager< CompuCell3D::Plugin >::unload().

template<class T>
libraryHandles_t BasicPluginManager< T >::libraryHandles [private]

A map of loaded library handles.

Definition at line 61 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::closeLibraries(), and BasicPluginManager< CompuCell3D::Plugin >::loadLibrary().

template<class T>
infos_t BasicPluginManager< T >::infos [private]

A list of plugin info structures.

Definition at line 64 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::getPluginInfos(), BasicPluginManager< CompuCell3D::Plugin >::registerPlugin(), and BasicPluginManager< CompuCell3D::Plugin >::~BasicPluginManager().

template<class T>
BasicException* BasicPluginManager< T >::pluginException [private]

Holds exceptions thrown by plugins on dlopen.

Definition at line 67 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::loadLibrary(), and BasicPluginManager< CompuCell3D::Plugin >::setPluginException().

template<class T>
bool BasicPluginManager< T >::preloadDeps [private]

If true dependencies will be loaded first.

Definition at line 70 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::get().

template<class T>
const char BasicPluginManager< T >::libExtension = ".so" [inline, static]

May need to ifdef this for windows dlls.

Definition at line 74 of file BasicPluginManager.h.

Referenced by BasicPluginManager< CompuCell3D::Plugin >::loadSingleLibraryPath().


The documentation for this class was generated from the following file:
Generated on Thu Feb 21 14:38:19 2008 for CompuCell3D by  doxygen 1.5.3