te::core::PluginManager Class Reference

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< PluginInfogetBrokenPlugins () 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< PluginInfogetLoadedPlugins () const
 Return the list of plugins that are loaded. More...
 
const PluginInfogetPluginInfo (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< PluginInfogetUnloadedPlugins () 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 PluginManagerinstance ()
 Access the singleton. More...
 

Private Member Functions

PluginManageroperator= (const PluginManager &)
 
 PluginManager ()
 Constructor. More...
 
 PluginManager (const PluginManager &)
 
 ~PluginManager ()
 Destructor. More...
 

Private Attributes

Impl * m_pimpl
 

Detailed Description

A singleton for managing plugins.

Note
Methods in this class are not thread-safe.

Definition at line 48 of file PluginManager.h.

Constructor & Destructor Documentation

te::core::PluginManager::PluginManager ( )
private

Constructor.

te::core::PluginManager::~PluginManager ( )
private

Destructor.

te::core::PluginManager::PluginManager ( const PluginManager )
private

Member Function Documentation

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.

Parameters
plugin_nameName of the plugin to be search.
Exceptions
OutOfRangeExceptionif 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.

Parameters
nameThe plugin name.
Returns
A plugin identified by the given name.
Exceptions
te::OutOfRangeExceptionIt 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.

Parameters
pluginsA vector to output the name of plugins managed by this singleton.
Note
The list will contain: loaded, not-loaded and broken plugins.
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.

Exceptions
plugin_already_registered_errorThrow an exception if a plugin with the same name already exists and it is registered in the manager.
static PluginManager& te::core::PluginManager::instance ( )
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.

Precondition
plugins must be in the manager before calling this method.
Parameters
plugin_nameThe plugin to be loaded
startIf true it will try to startup the plugin if false it doesn't automatically call plugin startup method.
Exceptions
te::plugin::exceptionIt throws an exception if any plugin can not be loaded or started.
Note
If the plugin in the list is already loaded this method will throw an exception.
If the plugin load fails this method will add it to the list of broken plugins and continues. In this case at the end an exception is thrown.
If the plugin is in the broken list, on success load it will be removed from the broken list.
PluginManager& te::core::PluginManager::operator= ( const PluginManager )
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.

Parameters
plugin_nameThe 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.

Parameters
plugin_nameName of the plugin to be removed.
Exceptions
te::InvalidArgumentExceptionIf the plugin can not be removed an exception is raised.
Note
Don't change the type of parameter to a const reference! (guess?)
void te::core::PluginManager::start ( const std::string &  plugin_name)

Start a loaded plugin.

Exceptions
te::core::PluginStartupExceptionIt throws an exception if any plugin can not be started.
void te::core::PluginManager::stop ( const std::string &  plugin_name)

Stop a loaded plugin.

Exceptions
te::core::PluginShutdownExceptionthrows 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.

Parameters
plugin_nameThe plugin to be unloaded.
Exceptions
PluginUnloadExceptionIt 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.

Member Data Documentation

Impl* te::core::PluginManager::m_pimpl
private

Definition at line 227 of file PluginManager.h.


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