OpenAB  1.0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
OpenAB::PluginManager Class Reference

PluginManager provides way to manage OpenAB plugins. Allows to discover modules that are providing OpenAB plugins, and load/unload them. More...

#include <PluginManager.hpp>

Public Member Functions

virtual ~PluginManager ()
 Destructor, virtual by default. More...
 
void scanDirectory (const std::string &path)
 Scans directory for OpenAB modules. Updates list of available plugins. More...
 
std::string getDefaultModulesDirectory () const
 Returns default location of OpenAB modules. More...
 
std::map< std::string,
std::string > 
getListOfPlugins () const
 List all available plugins with information about which modules are providing them. Keys in returned map are pluigins names and their values are modules names that are providing them e.g. PBAP /usr/lib/OpenAB/libOpenAB_plugin_input_pbap.so. More...
 
bool isPluginAvailable (const std::string &pluginName) const
 Checks if given plugin is provided by any module. More...
 
template<typename __C , typename __P >
__C * getPluginInstance (const std::string &pluginName, const __P &params)
 Creates instance of a plugin using plugin specific parameters to initialize it. More...
 
template<typename __C >
void freePluginInstance (__C *instance)
 Frees plugin instance created by getPluginInstance function. Apart from removing instance it will check if module that was providing given instance of plugin is still required to be keep in memory. More...
 

Static Public Member Functions

static PluginManagergetInstance ()
 Returns instance of PluginManager. More...
 

Detailed Description

PluginManager provides way to manage OpenAB plugins. Allows to discover modules that are providing OpenAB plugins, and load/unload them.

Constructor & Destructor Documentation

OpenAB::PluginManager::~PluginManager ( )
virtual

Destructor, virtual by default.

Member Function Documentation

template<typename __C >
void OpenAB::PluginManager::freePluginInstance ( __C *  instance)

Frees plugin instance created by getPluginInstance function. Apart from removing instance it will check if module that was providing given instance of plugin is still required to be keep in memory.

Parameters
[in]instanceinstance of plugin to be freed
std::string OpenAB::PluginManager::getDefaultModulesDirectory ( ) const

Returns default location of OpenAB modules.

Returns
path to default OpenAB modules directory
PluginManager & OpenAB::PluginManager::getInstance ( )
static

Returns instance of PluginManager.

std::map< std::string, std::string > OpenAB::PluginManager::getListOfPlugins ( ) const

List all available plugins with information about which modules are providing them. Keys in returned map are pluigins names and their values are modules names that are providing them e.g. PBAP /usr/lib/OpenAB/libOpenAB_plugin_input_pbap.so.

Returns
Map of all available plugins
template<typename __C , typename __P >
__C * OpenAB::PluginManager::getPluginInstance ( const std::string &  pluginName,
const __P &  params 
)

Creates instance of a plugin using plugin specific parameters to initialize it.

Note
This is preferred way for creating new instances of plugins, as it automatically keeps track of modules that are providing plugins, loading and unloading them on demand, keeping memory footprint as low as possible

Example of use: OpenAB_Input::Input* instance = getPluginInstance<OpenAB_Input::Input>("PBAP", params);

Parameters
[in]pluginNamename of plugin which instance should be created
[in]paramsplugin specific parameters for initializng new instance
Returns
newly created instance of plugin. When no longer needed it should be freed using freePluginInstance().
bool OpenAB::PluginManager::isPluginAvailable ( const std::string &  pluginName) const

Checks if given plugin is provided by any module.

Parameters
[in]pluginNamename of plugin which availability should be checked
Returns
true if plugin is provided by one of the modules, false otherwise.
void OpenAB::PluginManager::scanDirectory ( const std::string &  path)

Scans directory for OpenAB modules. Updates list of available plugins.

Note
This function does not load the modules.
Parameters
[in]pathpath of dictionary to scan

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