#include <PluginManager.h>
Static Public Attributes | |
static std::string | s_gui_postfix = "gui" |
the postfix to gui plugin, default="gui" (e.g. myplugin_gui.so) More... | |
Public Member Functions | |
PluginLoadStatus | loadPlugin (const std::string &plugin, const std::string &suffix=getDefaultSuffix(), bool ignoreCase=true, bool recursive=true, std::ostream *errlog=nullptr) |
PluginLoadStatus | loadPluginByPath (const std::string &path, std::ostream *errlog=nullptr) |
PluginLoadStatus | loadPluginByName (const std::string &pluginName, const std::string &suffix=getDefaultSuffix(), bool ignoreCase=true, bool recursive=true, std::ostream *errlog=nullptr) |
bool | unloadPlugin (const std::string &path, std::ostream *errlog=nullptr) |
PluginLoadStatus | registerPlugin (const std::string &plugin, const std::string &suffix=getDefaultSuffix(), bool ignoreCase=true, bool recursive=true, std::ostream *errlog=nullptr) |
Register a plugin. Merely an alias for loadPlugin() More... | |
const std::unordered_set< std::string > & | unloadedPlugins () const |
bool | isPluginUnloaded (const std::string &pluginName) const |
void | init () |
void | init (const std::string &pluginPath) |
void | cleanup () |
std::string | findPlugin (const std::string &pluginName, const std::string &suffix=getDefaultSuffix(), bool ignoreCase=true, bool recursive=true, int maxRecursiveDepth=3) |
bool | pluginIsLoaded (const std::string &plugin) |
std::pair< std::string, bool > | isPluginLoaded (const std::string &plugin) |
bool | checkDuplicatedPlugin (const Plugin &plugin, const std::string &pluginPath) |
PluginMap & | getPluginMap () |
Plugin * | getPlugin (const std::string &plugin, const std::string &=getDefaultSuffix(), bool=true) |
Plugin * | getPluginByName (const std::string &pluginName) |
template<typename Entry > | |
bool | getEntryFromPlugin (const Plugin *plugin, Entry &entry) |
void | readFromIniFile (const std::string &path) |
void | readFromIniFile (const std::string &path, type::vector< std::string > &listLoadedPlugins) |
void | writeToIniFile (const std::string &path) |
void | addOnPluginLoadedCallback (const std::string &key, std::function< void(const std::string &, const Plugin &)> callback) |
void | addOnPluginCleanupCallbacks (const std::string &key, std::function< void()> callback) |
void | removeOnPluginLoadedCallback (const std::string &key) |
void | removeOnPluginCleanupCallbacks (const std::string &key) |
Static Public Member Functions | |
static PluginManager & | getInstance () |
static std::string | getDefaultSuffix () |
static std::string | GetPluginNameFromPath (const std::string &pluginPath) |
Friends | |
std::ostream & | operator<< (std::ostream &os, const PluginManager &pluginManager) |
std::istream & | operator>> (std::istream &in, PluginManager &pluginManager) |
|
static |
the postfix to gui plugin, default="gui" (e.g. myplugin_gui.so)
void sofa::helper::system::PluginManager::addOnPluginCleanupCallbacks | ( | const std::string & | key, |
std::function< void()> | callback | ||
) |
void sofa::helper::system::PluginManager::addOnPluginLoadedCallback | ( | const std::string & | key, |
std::function< void(const std::string &, const Plugin &)> | callback | ||
) |
bool sofa::helper::system::PluginManager::checkDuplicatedPlugin | ( | const Plugin & | plugin, |
const std::string & | pluginPath | ||
) |
void sofa::helper::system::PluginManager::cleanup | ( | ) |
std::string sofa::helper::system::PluginManager::findPlugin | ( | const std::string & | pluginName, |
const std::string & | suffix = getDefaultSuffix() , |
||
bool | ignoreCase = true , |
||
bool | recursive = true , |
||
int | maxRecursiveDepth = 3 |
||
) |
|
static |
Get the default suffix applied to plugin names to find the actual lib to load Returns "_d" in debug configuration and an empty string otherwise
Get the default suffix applied to plugin names to find the actual lib to load (depends on platform, version, debug/release build)
|
inline |
|
static |
Plugin * sofa::helper::system::PluginManager::getPlugin | ( | const std::string & | plugin, |
const std::string & | = getDefaultSuffix() , |
||
bool | = true |
||
) |
Plugin * sofa::helper::system::PluginManager::getPluginByName | ( | const std::string & | pluginName | ) |
|
inline |
|
static |
void sofa::helper::system::PluginManager::init | ( | void | ) |
void sofa::helper::system::PluginManager::init | ( | const std::string & | pluginPath | ) |
std::pair< std::string, bool > sofa::helper::system::PluginManager::isPluginLoaded | ( | const std::string & | plugin | ) |
Determine if a plugin name or plugin path is known from the plugin manager (i.e. has been loaded by the plugin manager) with the found path.
plugin | A path to a plugin or a plugin name |
bool sofa::helper::system::PluginManager::isPluginUnloaded | ( | const std::string & | pluginName | ) | const |
auto sofa::helper::system::PluginManager::loadPlugin | ( | const std::string & | plugin, |
const std::string & | suffix = getDefaultSuffix() , |
||
bool | ignoreCase = true , |
||
bool | recursive = true , |
||
std::ostream * | errlog = nullptr |
||
) |
Loads a plugin library in process memory and register into the map
plugin | Can be just the filename of the library to load (without extension) or the full path |
suffix | An optional suffix to apply to the filename. Defaults to "_d" with debug builds and is empty otherwise. |
ignoreCase | Specify if the plugin search should be case-insensitive (activated by default). Not used if the plugin string passed as a parameter is a full path |
errlog | An optional stream for error logging. |
auto sofa::helper::system::PluginManager::loadPluginByName | ( | const std::string & | pluginName, |
const std::string & | suffix = getDefaultSuffix() , |
||
bool | ignoreCase = true , |
||
bool | recursive = true , |
||
std::ostream * | errlog = nullptr |
||
) |
Loads a plugin library in process memory.
pluginName | The filename without extension of the plugin to load |
suffix | An optional suffix to apply to the filename. Defaults to "_d" with debug builds, empty otherwise. |
ignoreCase | Specify if the plugin search should be case-insensitive (activated by default). Not used if the plugin string passed as a parameter is a full path |
errlog | An optional stream for error logging. |
PluginManager::PluginLoadStatus sofa::helper::system::PluginManager::loadPluginByPath | ( | const std::string & | path, |
std::ostream * | errlog = nullptr |
||
) |
Loads a plugin library in process memory.
path | The full path of the plugin to load |
errlog | An optional stream for error logging. |
bool sofa::helper::system::PluginManager::pluginIsLoaded | ( | const std::string & | plugin | ) |
void sofa::helper::system::PluginManager::readFromIniFile | ( | const std::string & | path | ) |
void sofa::helper::system::PluginManager::readFromIniFile | ( | const std::string & | path, |
type::vector< std::string > & | listLoadedPlugins | ||
) |
auto sofa::helper::system::PluginManager::registerPlugin | ( | const std::string & | plugin, |
const std::string & | suffix = getDefaultSuffix() , |
||
bool | ignoreCase = true , |
||
bool | recursive = true , |
||
std::ostream * | errlog = nullptr |
||
) |
Register a plugin. Merely an alias for loadPlugin()
void sofa::helper::system::PluginManager::removeOnPluginCleanupCallbacks | ( | const std::string & | key | ) |
void sofa::helper::system::PluginManager::removeOnPluginLoadedCallback | ( | const std::string & | key | ) |
const std::unordered_set< std::string > & sofa::helper::system::PluginManager::unloadedPlugins | ( | ) | const |
bool sofa::helper::system::PluginManager::unloadPlugin | ( | const std::string & | path, |
std::ostream * | errlog = nullptr |
||
) |
Unloads a plugin from the map Warning: a previously loaded plugin will always be in process memory.
void sofa::helper::system::PluginManager::writeToIniFile | ( | const std::string & | path | ) |
|
friend |
|
friend |