Tesseract
Motion Planning Environment
|
This is a utility class for loading plugins within Tesseract. More...
#include <plugin_loader.h>
Public Member Functions | |
template<class PluginBase > | |
std::shared_ptr< PluginBase > | instantiate (const std::string &plugin_name) const |
Instantiate a plugin with the provided name. More... | |
bool | isPluginAvailable (const std::string &plugin_name) const |
Check if plugin is available. More... | |
template<class PluginBase > | |
std::vector< std::string > | getAvailablePlugins () const |
Get the available plugins for the provided PluginBase type. More... | |
std::vector< std::string > | getAvailablePlugins (const std::string §ion) const |
Get the available plugins under the provided section. More... | |
std::vector< std::string > | getAvailableSections (bool include_hidden=false) const |
Get the available sections within the provided search libraries. More... | |
int | count () const |
The number of plugins stored. The size of plugins variable. More... | |
Static Public Member Functions | |
static void | addSymbolLibraryToSearchLibrariesEnv (const void *symbol_ptr, const std::string &search_libraries_env) |
Utility function to add library containing symbol to the search env variable. More... | |
Public Attributes | |
bool | search_system_folders { true } |
Indicate is system folders may be search if plugin is not found in any of the paths. More... | |
std::set< std::string > | search_paths |
A list of paths to search for plugins. More... | |
std::set< std::string > | search_libraries |
A list of library names without the prefix or suffix that contain plugins. More... | |
std::string | search_paths_env |
The environment variable containing plugin search paths. More... | |
std::string | search_libraries_env |
The environment variable containing plugins. More... | |
This is a utility class for loading plugins within Tesseract.
The library_name should not include the prefix 'lib' or suffix '.so'. It will add the correct prefix and suffix based on the OS.
It supports providing additional search paths and set environment variable which should be used when searching for plugins.
The plugin must be exported using the macro TESSERACT_ADD_PLUGIN. In the example below, the first parameter is the derived object and the second is the assigned symbol name which is used for loading Example: TESSERACT_ADD_PLUGIN(my_namespace::MyPlugin, plugin)
PluginLoader loader; loader.search_libraries.insert("my_plugin"); // libmy_plugin.so std::shared_ptr<PluginBase> p = loader.instantiate<PluginBase>("plugin");
|
inlinestatic |
Utility function to add library containing symbol to the search env variable.
In some cases the name and location of a library is unknown at runtime, but a symbol can be linked at compile time. This is true for Python auditwheel distributions. This utility function will determine the location of the library, and add it to the library search environment variable so it can be found.
symbol_ptr | Pointer to the symbol to find |
search_libraries_env | The environmental variable to modify |
|
inline |
The number of plugins stored. The size of plugins variable.
std::vector< std::string > tesseract_common::PluginLoader::getAvailablePlugins |
Get the available plugins for the provided PluginBase type.
This expects the Plugin base to have a static std::string SECTION_NAME which is used for looking up plugins
|
inline |
Get the available plugins under the provided section.
section | The section name to get all available plugins |
|
inline |
Get the available sections within the provided search libraries.
std::shared_ptr< PluginBase > tesseract_common::PluginLoader::instantiate | ( | const std::string & | plugin_name | ) | const |
Instantiate a plugin with the provided name.
plugin_name | The plugin name to find |
|
inline |
Check if plugin is available.
plugin_name | The plugin name to find |
std::set<std::string> tesseract_common::PluginLoader::search_libraries |
A list of library names without the prefix or suffix that contain plugins.
std::string tesseract_common::PluginLoader::search_libraries_env |
The environment variable containing plugins.
The plugins are store ins the following format. The library name does not contain prefix or suffix Format: library_name:library_name1:library_name2
std::set<std::string> tesseract_common::PluginLoader::search_paths |
A list of paths to search for plugins.
std::string tesseract_common::PluginLoader::search_paths_env |
The environment variable containing plugin search paths.
bool tesseract_common::PluginLoader::search_system_folders { true } |
Indicate is system folders may be search if plugin is not found in any of the paths.