te::core::PluginManager Class Reference

A singleton for managing plugins. More...

#include <PluginManager.h>

Classes

struct  Impl
 

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

Implm_pimpl
 

Detailed Description

A singleton for managing plugins.

Note
Methods in this class are not thread-safe.

Definition at line 48 of file src/terralib/core/plugin/PluginManager.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 582 of file src/terralib/core/plugin/PluginManager.cpp.

References m_pimpl.

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

Destructor.

Definition at line 587 of file src/terralib/core/plugin/PluginManager.cpp.

References m_pimpl.

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

Member Function Documentation

bool te::core::PluginManager::exists ( const std::string &  plugin_name) const

Tells if a given plugin is registered or not.

Definition at line 206 of file src/terralib/core/plugin/PluginManager.cpp.

References isBroken(), isLoaded(), and isUnloaded().

std::vector< te::core::PluginInfo > te::core::PluginManager::getBrokenPlugins ( ) const
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.

Definition at line 139 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::dependency_map, m_pimpl, and TE_TR.

Referenced by GetDependents(), and recursiveUnload().

std::vector< te::core::PluginInfo > te::core::PluginManager::getLoadedPlugins ( ) const
const te::core::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.

Definition at line 88 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::broken_plugins, m_pimpl, te::core::PluginInfo::name, p, te::core::PluginManager::Impl::plugins, and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by recursiveUnload(), and te::core::plugin::UnloadPlugin().

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.

Definition at line 63 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::broken_plugins, m_pimpl, te::core::PluginInfo::name, p, te::core::PluginManager::Impl::plugins, and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by te::qt::widgets::PluginBuilderWizard::PluginBuilderWizard(), and te::qt::af::InternalSettingsDialog::setPlugins().

std::vector< te::core::PluginInfo > te::core::PluginManager::getUnloadedPlugins ( ) const
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.

Definition at line 212 of file src/terralib/core/plugin/PluginManager.cpp.

References isBroken(), isLoaded(), isUnloaded(), m_pimpl, te::core::PluginInfo::name, TE_TR, and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by BOOST_AUTO_TEST_CASE(), CreateDataSource(), te::qt::af::ApplicationController::initializePlugins(), te::core::plugin::LoadAll(), LoadDrivers(), LoadGDALModule(), LoadModule(), LoadModules(), LoadOGRModule(), main(), te::qt::widgets::PluginManagerDialog::onAddPushButtonClicked(), and WithPluginManager().

bool te::core::PluginManager::isBroken ( const std::string &  plugin_name) const

Returns true if the plugin is in the broken list of plugins.

Definition at line 153 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::broken_plugins, m_pimpl, and p.

Referenced by exists(), insert(), isFixed(), load(), and remove().

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.

Definition at line 178 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::broken_plugins, te::core::PluginInfo::dependencies, isBroken(), isLoaded(), m_pimpl, and te::core::PluginManager::Impl::move_from_broken_to_unloaded_list().

bool te::core::PluginManager::isLoaded ( const std::string &  plugin_name) const

Returns true if the plugin is loaded otherwise returns false.

Definition at line 171 of file src/terralib/core/plugin/PluginManager.cpp.

References m_pimpl, p, and te::core::PluginManager::Impl::plugins.

Referenced by exists(), te::qt::widgets::PluginManagerDialog::getPluginStatus(), insert(), isFixed(), load(), and remove().

bool te::core::PluginManager::isUnloaded ( const std::string &  plugin_name) const

Returns true if the plugin is in the not-loaded list of plugins.

Definition at line 162 of file src/terralib/core/plugin/PluginManager.cpp.

References m_pimpl, p, and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by exists(), te::qt::widgets::PluginManagerDialog::getPluginStatus(), insert(), load(), recursiveUnload(), and remove().

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.

Definition at line 291 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::broken_plugins, d, te::core::PluginInfo::dependencies, te::core::PluginManager::Impl::dependency_map, te::core::PluginInfo::engine, te::core::PluginEngineManager::get(), te::core::PluginEngineManager::instance(), isBroken(), isLoaded(), isUnloaded(), te::core::AbstractPluginEngine::load(), m_pimpl, te::core::PluginManager::Impl::move_from_unload_to_broken_list(), te::core::PluginInfo::name, te::core::PluginManager::Impl::plugins, TE_LOG_TRACE, TE_TR, and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by BOOST_AUTO_TEST_CASE(), CreateDataSource(), te::qt::af::ApplicationController::initializePlugins(), te::core::plugin::LoadAll(), LoadDrivers(), LoadGDALModule(), LoadModule(), LoadModules(), LoadOGRModule(), te::qt::widgets::PluginManagerDialog::loadPlugins(), main(), and WithPluginManager().

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.

Definition at line 547 of file src/terralib/core/plugin/PluginManager.cpp.

References getDependents(), getPluginInfo(), isUnloaded(), stop(), and unload().

Referenced by te::qt::widgets::PluginManagerDialog::unloadPlugins().

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?)

Definition at line 247 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::broken_plugins, isBroken(), isLoaded(), isUnloaded(), m_pimpl, stop(), TE_TR, unload(), and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by te::qt::widgets::PluginManagerDialog::removeEntries().

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.

Definition at line 453 of file src/terralib/core/plugin/PluginManager.cpp.

References m_pimpl, p, te::core::PluginManager::Impl::plugins, TE_LOG_TRACE, and TE_TR.

void te::core::PluginManager::stop ( const std::string &  plugin_name)
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.

Definition at line 507 of file src/terralib/core/plugin/PluginManager.cpp.

References te::core::PluginManager::Impl::dependency_map, m_pimpl, te::core::PluginManager::Impl::plugins, TE_LOG_TRACE, TE_TR, and te::core::PluginManager::Impl::unloaded_plugins.

Referenced by recursiveUnload(), remove(), te::core::plugin::UnloadAll(), te::core::plugin::UnloadPlugin(), te::qt::widgets::PluginManagerDialog::unloadPlugins(), and WithPluginManager().

Member Data Documentation


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