SOFA API  3944ba52
Open source framework for multi-physics simuation
sofa::core::PluginManager Class Reference

#include <PluginManager.h>

Detailed Description

This class manages a collection of plugins: loading, unloading, initialization, etc

Classes

struct  LoadedPlugin
 An entry corresponding to a plugin that in loaded in the PluginManager. More...
 

Protected Attributes

std::map< std::string, LoadedPluginm_loadedPlugins
 
std::map< std::string, LoadedPluginm_loadedLegacyPlugins
 
std::map< std::string, std::string > m_pluginFiles
 The paths of the plugin libraries, indexed by the name of the plugin. More...
 
ComponentDatabase m_componentDatabase
 
std::vector< std::string > m_pluginDirectories
 The paths to the plugin directories. More...
 

Public Member Functions

 PluginManager ()
 
 PluginManager (const std::string &pluginDirectory)
 
 ~PluginManager ()
 
void addPluginDirectory (const std::string &path)
 Add a directory where to look for plugins. More...
 
sofa::core::PluginloadPlugin (const std::string &plugin)
 
bool unloadPlugin (const std::string &pluginName)
 
void unloadAllPlugins ()
 Unload all the loaded plugins. More...
 
void addComponentsToFactory (sofa::core::ObjectFactory &factory, const sofa::core::Plugin &plugin)
 
void removeComponentsFromFactory (sofa::core::ObjectFactory &factory, const sofa::core::Plugin &plugin)
 
void refreshPluginInfo ()
 
bool canFindComponent (std::string componentName, std::string templateParameters="")
 
sofa::core::PluginloadPluginContaining (std::string componentName, std::string templateParameters="")
 
const sofa::core::PlugingetLoadedPlugin (const std::string &pluginName) const
 Get the instance of a loaded Plugin from its name. More...
 
const LoadedPluginMapgetLoadedPlugins () const
 
const LoadedPluginMapgetLoadedLegacyPlugins () const
 
const std::vector< std::string > & getPluginDirectories () const
 
const ComponentDatabasegetComponentDatabase () const
 

Protected Member Functions

LoadedPlugin openPlugin (const std::string &filename)
 
void closePlugin (LoadedPlugin entry)
 
void processDirectory (std::string directory)
 

Attribute details

ComponentDatabase sofa::core::PluginManager::m_componentDatabase
protected

Description of the content of the plugins.

It is a map of the plugin names, indexed by the ComponentID of the components they contain.

std::map<std::string, LoadedPlugin> sofa::core::PluginManager::m_loadedLegacyPlugins
protected
std::map<std::string, LoadedPlugin> sofa::core::PluginManager::m_loadedPlugins
protected

The plugins currently loaded by this PluginManager, indexed by their name.

std::vector<std::string> sofa::core::PluginManager::m_pluginDirectories
protected

The paths to the plugin directories.

std::map<std::string, std::string> sofa::core::PluginManager::m_pluginFiles
protected

The paths of the plugin libraries, indexed by the name of the plugin.

Constructor details

sofa::core::PluginManager::PluginManager ( )
sofa::core::PluginManager::PluginManager ( const std::string &  pluginDirectory)
sofa::core::PluginManager::~PluginManager ( )

Function details

void sofa::core::PluginManager::addComponentsToFactory ( sofa::core::ObjectFactory factory,
const sofa::core::Plugin plugin 
)
void sofa::core::PluginManager::addPluginDirectory ( const std::string &  path)

Add a directory where to look for plugins.

bool sofa::core::PluginManager::canFindComponent ( std::string  componentName,
std::string  templateParameters = "" 
)
void sofa::core::PluginManager::closePlugin ( LoadedPlugin  entry)
protected
const PluginManager::ComponentDatabase & sofa::core::PluginManager::getComponentDatabase ( ) const
const std::map< std::string, PluginManager::LoadedPlugin > & sofa::core::PluginManager::getLoadedLegacyPlugins ( ) const
const sofa::core::Plugin & sofa::core::PluginManager::getLoadedPlugin ( const std::string &  pluginName) const

Get the instance of a loaded Plugin from its name.

const std::map< std::string, PluginManager::LoadedPlugin > & sofa::core::PluginManager::getLoadedPlugins ( ) const
const std::vector< std::string > & sofa::core::PluginManager::getPluginDirectories ( ) const
Plugin & sofa::core::PluginManager::loadPlugin ( const std::string &  plugin)

Try to load the given plugin; throw a runtime_error on error.

Parameters
plugineither the name of the plugin, or the path of the library
Returns
A reference to the Plugin
Plugin & sofa::core::PluginManager::loadPluginContaining ( std::string  componentName,
std::string  templateParameters = "" 
)
PluginManager::LoadedPlugin sofa::core::PluginManager::openPlugin ( const std::string &  filename)
protected
void sofa::core::PluginManager::processDirectory ( std::string  directory)
protected
void sofa::core::PluginManager::refreshPluginInfo ( )
void sofa::core::PluginManager::removeComponentsFromFactory ( sofa::core::ObjectFactory factory,
const sofa::core::Plugin plugin 
)
void sofa::core::PluginManager::unloadAllPlugins ( )

Unload all the loaded plugins.

bool sofa::core::PluginManager::unloadPlugin ( const std::string &  pluginName)

Try to unload a plugin

Returns
true if the plugin was unloaded. (A plugin can prevent unloading by overloading Plugin::canBeUnloaded())