SOFA API  3ea83cbd
Open source framework for multi-physics simuation
sofa::helper::system::PluginManager Class Reference

#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)
 Unloads a plugin from process memory. More...
 
void init ()
 
void init (const std::string &pluginPath)
 
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)
 
bool checkDuplicatedPlugin (const Plugin &plugin, const std::string &pluginPath)
 
PluginMapgetPluginMap ()
 
PlugingetPlugin (const std::string &plugin, const std::string &=getDefaultSuffix(), bool=true)
 
PlugingetPluginByName (const std::string &pluginName)
 
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 removeOnPluginLoadedCallback (const std::string &key)
 

Static Public Member Functions

static PluginManagergetInstance ()
 
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)
 

Attribute details

◆ s_gui_postfix

std::string sofa::helper::system::PluginManager::s_gui_postfix = "gui"
static

the postfix to gui plugin, default="gui" (e.g. myplugin_gui.so)

Function details

◆ addOnPluginLoadedCallback()

void sofa::helper::system::PluginManager::addOnPluginLoadedCallback ( const std::string &  key,
std::function< void(const std::string &, const Plugin &)>  callback 
)

◆ checkDuplicatedPlugin()

bool sofa::helper::system::PluginManager::checkDuplicatedPlugin ( const Plugin plugin,
const std::string &  pluginPath 
)

◆ findPlugin()

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 
)

◆ getDefaultSuffix()

std::string sofa::helper::system::PluginManager::getDefaultSuffix ( )
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)

◆ getInstance()

PluginManager & sofa::helper::system::PluginManager::getInstance ( )
static

◆ getPlugin()

Plugin * sofa::helper::system::PluginManager::getPlugin ( const std::string &  plugin,
const std::string &  = getDefaultSuffix(),
bool  = true 
)

◆ getPluginByName()

Plugin * sofa::helper::system::PluginManager::getPluginByName ( const std::string &  pluginName)

◆ getPluginMap()

PluginMap& sofa::helper::system::PluginManager::getPluginMap ( )
inline

◆ GetPluginNameFromPath()

std::string sofa::helper::system::PluginManager::GetPluginNameFromPath ( const std::string &  pluginPath)
static

◆ init() [1/2]

void sofa::helper::system::PluginManager::init ( void  )

◆ init() [2/2]

void sofa::helper::system::PluginManager::init ( const std::string &  pluginPath)

◆ loadPlugin()

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.

Parameters
pluginCan be just the filename of the library to load (without extension) or the full path
suffixAn optional suffix to apply to the filename. Defaults to "_d" with debug builds and is empty otherwise.
ignoreCaseSpecify 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
errlogAn optional stream for error logging.

◆ loadPluginByName()

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.

Parameters
pluginNameThe filename without extension of the plugin to load
suffixAn optional suffix to apply to the filename. Defaults to "_d" with debug builds, empty otherwise.
ignoreCaseSpecify 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
errlogAn optional stream for error logging.

◆ loadPluginByPath()

PluginManager::PluginLoadStatus sofa::helper::system::PluginManager::loadPluginByPath ( const std::string &  path,
std::ostream *  errlog = nullptr 
)

Loads a plugin library in process memory.

Parameters
pathThe full path of the plugin to load
errlogAn optional stream for error logging.

◆ pluginIsLoaded()

bool sofa::helper::system::PluginManager::pluginIsLoaded ( const std::string &  plugin)

◆ readFromIniFile() [1/2]

void sofa::helper::system::PluginManager::readFromIniFile ( const std::string &  path)

◆ readFromIniFile() [2/2]

void sofa::helper::system::PluginManager::readFromIniFile ( const std::string &  path,
type::vector< std::string > &  listLoadedPlugins 
)

◆ removeOnPluginLoadedCallback()

void sofa::helper::system::PluginManager::removeOnPluginLoadedCallback ( const std::string &  key)

◆ unloadPlugin()

bool sofa::helper::system::PluginManager::unloadPlugin ( const std::string &  path,
std::ostream *  errlog = nullptr 
)

Unloads a plugin from process memory.

◆ writeToIniFile()

void sofa::helper::system::PluginManager::writeToIniFile ( const std::string &  path)

Enum details

◆ PluginLoadStatus

Enumerator
SUCCESS 
ALREADY_LOADED 
PLUGIN_FILE_NOT_FOUND 
INVALID_LOADING 
MISSING_SYMBOL 
INIT_ERROR 

Related details

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const PluginManager pluginManager 
)
friend

◆ operator>>

std::istream& operator>> ( std::istream &  in,
PluginManager pluginManager 
)
friend