| Lunchbox
    1.12.0
    Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs. | 
Factory for Plugin classes. More...
#include <pluginFactory.h>
 Inheritance diagram for lunchbox::PluginFactory< PluginT, InitDataT >:
 Inheritance diagram for lunchbox::PluginFactory< PluginT, InitDataT >: Collaboration diagram for lunchbox::PluginFactory< PluginT, InitDataT >:
 Collaboration diagram for lunchbox::PluginFactory< PluginT, InitDataT >:| Public Types | |
| typedef Plugin< PluginT, InitDataT > | PluginHolder | 
| typedef std::vector< PluginHolder > | Plugins | 
| Public Member Functions | |
| PluginT * | create (const InitDataT &initData) | 
| Create a plugin instance.  More... | |
| void | register_ (const Plugin< PluginT, InitDataT > &plugin) | 
| Register a plugin type.  More... | |
| bool | deregister (const Plugin< PluginT, InitDataT > &plugin) | 
| Deregister a plugin type.  More... | |
| void | deregisterAll () | 
| Unregister all plugin types.  More... | |
| Automatic loading of plugin DSOs. | |
| DSOs | load (const int version, const std::string &path, const std::string &pattern) | 
| Load all compatible plugin libraries from a directory matching a pattern.  More... | |
| DSOs | load (const int version, const Strings &paths, const std::string &pattern) | 
| bool | unload (DSO *dso) | 
| Unload and deregister a previously loaded plugin.  More... | |
| Static Public Member Functions | |
| static PluginFactory & | getInstance () | 
| Get the single class instance.  More... | |
Factory for Plugin classes.
The PluginFactory selects the a plugin for a given InitDataT, based on a plugin's handles() function. In case a InitDataT can be handled by multiple plugins, which plugin is chosen is undefined.
This class has been designed as a singleton to allow for link time plugin registration, but nothing prevents an application from registering new types at run time.
To do the registration of a plugin during the static initialization phase use the PluginRegisterer.
Example:
Definition at line 59 of file pluginFactory.h.
| PluginT * lunchbox::PluginFactory< PluginT, InitDataT >::create | ( | const InitDataT & | initData | ) | 
Create a plugin instance.
| initData | The initData passed to the plugin constructor. | 
| std::runtime_error | if no plugin can handle the initData. | 
Definition at line 43 of file pluginFactory.ipp.
References LBTHROW.
| bool lunchbox::PluginFactory< PluginT, InitDataT >::deregister | ( | const Plugin< PluginT, InitDataT > & | plugin | ) | 
| void lunchbox::PluginFactory< PluginT, InitDataT >::deregisterAll | ( | ) | 
| 
 | static | 
Get the single class instance.
Definition at line 26 of file pluginFactory.ipp.
Referenced by lunchbox::PluginRegisterer< Impl, false >::PluginRegisterer().
 Here is the caller graph for this function:
 Here is the caller graph for this function:| DSOs lunchbox::PluginFactory< PluginT, InitDataT >::load | ( | const int | version, | 
| const std::string & | path, | ||
| const std::string & | pattern | ||
| ) | 
Load all compatible plugin libraries from a directory matching a pattern.
The pattern is the core name of the library, and is extended by the system-specific shared library suffix and postfix. The plugin has to implement the C functions 'int LunchboxPluginGetVersion()' and 'bool LunchboxPluginRegister()'. Only plugins with the same ABI version as the given one are registered.
| version | the current ABI version of the application loading the plugins. | 
| path | the directory to search for plugins. | 
| pattern | the core pattern of plugin names. | 
Definition at line 97 of file pluginFactory.ipp.
| void lunchbox::PluginFactory< PluginT, InitDataT >::register_ | ( | const Plugin< PluginT, InitDataT > & | plugin | ) | 
| bool lunchbox::PluginFactory< PluginT, InitDataT >::unload | ( | DSO * | dso | ) | 
Unload and deregister a previously loaded plugin.
Definition at line 167 of file pluginFactory.ipp.