A singleton for managing plugins. More...
#include <PluginManager.h>
Public Member Functions | |
void | clear () |
Stop and unload all plugins, then clear the internal list of plugins. More... | |
bool | exists (const std::string &plugin_name) const |
Tells if a given plugin is registered or not. More... | |
std::vector< PluginInfo > | getBrokenPlugins () const |
Return the list of plugins that could not be loaded. More... | |
std::vector< std::string > | getDependents (const std::string plugin_name) |
Return the list of plugins that depends of a given plugin. More... | |
std::vector< PluginInfo > | getLoadedPlugins () const |
Return the list of plugins that are loaded. More... | |
const PluginInfo & | getPluginInfo (const std::string &name) const |
Return information about a plugin identified by the given name. More... | |
std::vector< std::string > | getPlugins () const |
Return the list of plugins managed by PluginManager. More... | |
std::vector< PluginInfo > | getUnloadedPlugins () const |
Return the list of plugins that were not loaded. More... | |
void | insert (const PluginInfo &pinfo) |
Adds plugin with its plugin information to the list of unloaded plugins. More... | |
bool | isBroken (const std::string &plugin_name) const |
Returns true if the plugin is in the broken list of plugins. More... | |
bool | isFixed (const std::string &plugin_name) |
Returns true if the plugin has been fixed and moves it to the unloaded list otherwise returns false. More... | |
bool | isLoaded (const std::string &plugin_name) const |
Returns true if the plugin is loaded otherwise returns false. More... | |
bool | isUnloaded (const std::string &plugin_name) const |
Returns true if the plugin is in the not-loaded list of plugins. More... | |
void | load (const std::string &plugin_name, const bool start=true) |
It tries to load the informed plugin. More... | |
void | recursiveUnload (const std::string &plugin_name) |
Try to unload a given plugin and its dependents recursively. More... | |
void | remove (const std::string &plugin_name) |
Remove plugin from the manager. More... | |
void | start (const std::string &plugin_name) |
Start a loaded plugin. More... | |
void | stop (const std::string &plugin_name) |
Stop a loaded plugin. More... | |
void | unload (const std::string &plugin_name) |
Try to unload a given plugin. More... | |
Static Public Member Functions | |
static PluginManager & | instance () |
Access the singleton. More... | |
Private Member Functions | |
PluginManager & | operator= (const PluginManager &) |
PluginManager () | |
Constructor. More... | |
PluginManager (const PluginManager &) | |
~PluginManager () | |
Destructor. More... | |
Private Attributes | |
Impl * | m_pimpl |
A singleton for managing plugins.
Definition at line 48 of file PluginManager.h.
|
private |
Constructor.
|
private |
Destructor.
|
private |
void te::core::PluginManager::clear | ( | ) |
Stop and unload all plugins, then clear the internal list of plugins.
bool te::core::PluginManager::exists | ( | const std::string & | plugin_name | ) | const |
Tells if a given plugin is registered or not.
std::vector<PluginInfo> te::core::PluginManager::getBrokenPlugins | ( | ) | const |
Return the list of plugins that could not be loaded.
std::vector<std::string> te::core::PluginManager::getDependents | ( | const std::string | plugin_name | ) |
Return the list of plugins that depends of a given plugin.
plugin_name | Name of the plugin to be search. |
OutOfRangeException | if the plugin is not found. |
std::vector<PluginInfo> te::core::PluginManager::getLoadedPlugins | ( | ) | const |
Return the list of plugins that are loaded.
const PluginInfo& te::core::PluginManager::getPluginInfo | ( | const std::string & | name | ) | const |
Return information about a plugin identified by the given name.
name | The plugin name. |
te::OutOfRangeException | It throws an exception if there isn't a plugin with the given name in the manager. |
std::vector<std::string> te::core::PluginManager::getPlugins | ( | ) | const |
Return the list of plugins managed by PluginManager.
plugins | A vector to output the name of plugins managed by this singleton. |
std::vector<PluginInfo> te::core::PluginManager::getUnloadedPlugins | ( | ) | const |
Return the list of plugins that were not loaded.
void te::core::PluginManager::insert | ( | const PluginInfo & | pinfo | ) |
Adds plugin with its plugin information to the list of unloaded plugins.
plugin_already_registered_error | Throw an exception if a plugin with the same name already exists and it is registered in the manager. |
|
static |
Access the singleton.
bool te::core::PluginManager::isBroken | ( | const std::string & | plugin_name | ) | const |
Returns true if the plugin is in the broken list of plugins.
bool te::core::PluginManager::isFixed | ( | const std::string & | plugin_name | ) |
Returns true if the plugin has been fixed and moves it to the unloaded list otherwise returns false.
bool te::core::PluginManager::isLoaded | ( | const std::string & | plugin_name | ) | const |
Returns true if the plugin is loaded otherwise returns false.
bool te::core::PluginManager::isUnloaded | ( | const std::string & | plugin_name | ) | const |
Returns true if the plugin is in the not-loaded list of plugins.
void te::core::PluginManager::load | ( | const std::string & | plugin_name, |
const bool | start = true |
||
) |
It tries to load the informed plugin.
The manager will check the plugin's dependencies before trying to load it.
This method can be used to retry loading a broken plugin.
plugin_name | The plugin to be loaded |
start | If true it will try to startup the plugin if false it doesn't automatically call plugin startup method. |
te::plugin::exception | It throws an exception if any plugin can not be loaded or started. |
|
private |
void te::core::PluginManager::recursiveUnload | ( | const std::string & | plugin_name | ) |
Try to unload a given plugin and its dependents recursively.
This method will call plugin's shutdown method if needed.
plugin_name | The plugin to be unloaded. |
void te::core::PluginManager::remove | ( | const std::string & | plugin_name | ) |
Remove plugin from the manager.
This method removes the plugin from the manager. If the plugin was loaded, unload it and remove it from the manager. If it was unloaded or broked, just removes it from the correct list. Note that all its dependents will be moved to the broken list.
plugin_name | Name of the plugin to be removed. |
te::InvalidArgumentException | If the plugin can not be removed an exception is raised. |
void te::core::PluginManager::start | ( | const std::string & | plugin_name | ) |
Start a loaded plugin.
te::core::PluginStartupException | It throws an exception if any plugin can not be started. |
void te::core::PluginManager::stop | ( | const std::string & | plugin_name | ) |
Stop a loaded plugin.
te::core::PluginShutdownException | throws an exception if any plugin can not be stoped. |
void te::core::PluginManager::unload | ( | const std::string & | plugin_name | ) |
Try to unload a given plugin.
plugin_name | The plugin to be unloaded. |
PluginUnloadException | It will raise an exception if plugin's code is not unloaded, if it is started or if the plugin's is not managed by PluginManager. |
|
private |
Definition at line 227 of file PluginManager.h.