# BasicPluginManager< T > Class Template Reference

`#include <BasicPluginManager.h>`

Collaboration diagram for BasicPluginManager< T >:

[legend]
List of all members.

## Public Types

typedef std::list< BasicPluginInfo * > | infos_t

## Public Member Functions

| BasicPluginManager (bool preloadDeps=false)
virtual | ~BasicPluginManager ()
| Destruct the plugin manager.
virtual void | init (T *plugin)
| Initialization function called when a plugin is first loaded.
void | destroyPlugin (std::string pluginName)
| Deallocate a specific plugin.
void | unload ()
| Deallocate all plugins in the correct order.
void | closeLibraries ()
| Close all shared library handles.
bool | dependsOn (std::string plugin1, std::string plugin2)
| If plugin1 has not yet been registered this function will return false;.
T * | get (const std::string pluginName)
| Get a pointer to a named plugin.
bool | isLoaded (std::string pluginName)
| True if plugin with name pluginName is loaded.
const BasicPluginInfo * | getPluginInfo (const std::string pluginName)
| A reference to the named plugins info structure.
infos_t & | getPluginInfos ()
void | loadLibraries (const std::string path)
| Loads all plugin libraries on a ':' separated path list.
void | loadLibrary (const std::string filename)
| Load a plugin library.
void | registerPlugin (BasicPluginInfo *info, BasicClassFactoryBase< T > *factory)
| Called by BasicPluginProxy to register itself with the manager.
void | setPluginException (BasicException e)
| Used by statically allocated plugins to pass any exceptions back to the library loader.

## Static Public Attributes

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

## Protected Member Functions

BasicClassFactoryBase< T > * | getPluginFactory (const std::string pluginName)
| A reference to the named plugin's factory.
void | loadSingleLibraryPath (const std::string path)
| Loads all libraries on a single 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, lt_dlhandle > | 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.
BasicException * | pluginException
| Holds exceptions thrown by plugins on dlopen.
bool | preloadDeps
| If true dependencies will be loaded first.

### template<class T>
class BasicPluginManager< T >

## Member Typedef Documentation

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

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

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

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

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

## Constructor & Destructor Documentation

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

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

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

## Member Function Documentation

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

| Close all shared library handles.

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.

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

| Deallocate a specific plugin.

template<class T>
T* BasicPluginManager< T >::get | ( | const std::string | pluginName | ) | `[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.

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

| A reference to the named plugin's factory.

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

| A reference to the named plugins info structure.

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

Returns:
  A list of registered plugin information structures.

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.

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

| True if plugin with name pluginName is loaded.

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.

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

Load a plugin library.

Parameters:

  | filename | Path to plugin library.

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.

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.

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

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

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

| Deallocate all plugins in the correct order.

## Member Data Documentation

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

| A map from plugin name to registered factory.

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

| A map from plugin name to registered info.

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

| A list of plugin info structures.

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

| May need to ifdef this for windows dlls.

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

| A map of loaded library handles.

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

| Holds exceptions thrown by plugins on dlopen.

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

| A map from plugin name to plugin instance.

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

| If true dependencies will be loaded first.

The documentation for this class was generated from the following file:

- BasicPluginManager.h