Orocos Real-Time Toolkit
2.5.0
|
Loads plugins found on the filesystem and keeps track of found plugins, typekits and services. More...
#include <rtt/plugin/PluginLoader.hpp>
Public Types | |
typedef boost::shared_ptr < PluginLoader > | shared_ptr |
Public Member Functions | |
bool | loadLibrary (std::string const &path) |
Loads a library as plugin or typekit. | |
bool | loadTypekits (std::string const &path_list) |
Load any typekit found in the 'types/' subdirectory of each path in path_list in the process. | |
bool | loadTypekit (std::string const &name, std::string const &path_list) |
Load a typekit found in the 'types/' subdirectory of each path in path_list in the process. | |
bool | loadPlugins (std::string const &path_list) |
Loads any plugin found in the 'plugins/' subdirectory of each path in path_list in the current process. | |
bool | isLoaded (std::string name) |
Checks if a given plugin or filename has been loaded. | |
bool | loadPlugin (std::string const &name, std::string const &path_list) |
Loads a plugin found in the 'plugins/' subdirectory of each path in path_list in the current process. | |
bool | loadService (std::string const &servicename, TaskContext *tc) |
Loads an earlier discovered service into a TaskContext. | |
std::vector< std::string > | listServices () const |
Lists all services discovered by the PluginLoader. | |
std::vector< std::string > | listPlugins () const |
Lists all plugins (= services + typekits) discovered by the PluginLoader. | |
std::vector< std::string > | listTypekits () const |
Lists all typekits discovered by the PluginLoader. | |
std::string | getPluginPath () const |
Returns the current plugin path list. | |
void | setPluginPath (std::string const &newpath) |
Sets the plugin path list. | |
Static Public Member Functions | |
static boost::shared_ptr < PluginLoader > | Instance () |
Create the instance of the PluginLoader. | |
static void | Release () |
Release the PluginLoader, erasing all knowledge of loaded libraries. |
Loads plugins found on the filesystem and keeps track of found plugins, typekits and services.
It has no facilities of unloading plugins. Plugins remain in memory until the process terminates.
The PluginLoader reads the RTT_COMPONENT_PATH variable when the application starts and stores it using setPluginPath(). Paths are scanned in this order:
** First the paths specified by the function argument path_list if the function takes such argument ** Second the paths specified using the setPluginPath() function.
If neither is specified, it looks for plugins in the current directory (".").
Definition at line 68 of file PluginLoader.hpp.
std::string PluginLoader::getPluginPath | ( | ) | const |
Returns the current plugin path list.
Defaults to the value of RTT_COMPONENT_PATH, when the RTT was started for the current process.
Definition at line 736 of file PluginLoader.cpp.
boost::shared_ptr< PluginLoader > PluginLoader::Instance | ( | ) | [static] |
Create the instance of the PluginLoader.
It will keep track of the loaded libraries for this process.
Definition at line 285 of file PluginLoader.cpp.
Referenced by RTT::internal::GlobalService::require().
bool PluginLoader::isLoaded | ( | std::string | name | ) |
Checks if a given plugin or filename has been loaded.
This function accepts full filenames ('libthe_plugin.so.1.99.0'), short names ('the_plugin') or the name provided by the plugin ('The Plugin').
name | name of a file or the plugin name. |
Definition at line 581 of file PluginLoader.cpp.
std::vector< std::string > PluginLoader::listPlugins | ( | ) | const |
Lists all plugins (= services + typekits) discovered by the PluginLoader.
Definition at line 717 of file PluginLoader.cpp.
std::vector< std::string > PluginLoader::listServices | ( | ) | const |
Lists all services discovered by the PluginLoader.
Definition at line 707 of file PluginLoader.cpp.
std::vector< std::string > PluginLoader::listTypekits | ( | ) | const |
Lists all typekits discovered by the PluginLoader.
Definition at line 726 of file PluginLoader.cpp.
bool PluginLoader::loadLibrary | ( | std::string const & | path | ) |
Loads a library as plugin or typekit.
path | an absolute or relative path to a library. Relative paths are interpreted with regard to the plugin path. |
Definition at line 422 of file PluginLoader.cpp.
bool PluginLoader::loadPlugin | ( | std::string const & | name, |
std::string const & | path_list | ||
) |
Loads a plugin found in the 'plugins/' subdirectory of each path in path_list in the current process.
name | The name of the plugin to load, must match the library name (without lib/dll/so pre-/suffixes). |
path_list | A colon or semi-colon seperated list of paths to look for plugins. May be the empty string. |
std::runtime_exception | if the found plugin refused to load. |
Definition at line 306 of file PluginLoader.cpp.
bool PluginLoader::loadPlugins | ( | std::string const & | path_list | ) |
Loads any plugin found in the 'plugins/' subdirectory of each path in path_list in the current process.
path_list | A colon or semi-colon seperated list of paths to look for plugins. May be the empty string. |
std::runtime_exception | if one of the found plugin refused to load. |
Definition at line 311 of file PluginLoader.cpp.
bool PluginLoader::loadService | ( | std::string const & | servicename, |
TaskContext * | tc | ||
) |
Loads an earlier discovered service into a TaskContext.
servicename | The name of the service or plugin containing the service |
tc | The TaskContext to load into. |
Definition at line 316 of file PluginLoader.cpp.
References RTT::TaskContext::getName().
bool PluginLoader::loadTypekit | ( | std::string const & | name, |
std::string const & | path_list | ||
) |
Load a typekit found in the 'types/' subdirectory of each path in path_list in the process.
path_list | A colon or semi-colon seperated list of paths to look for typekits. May be empty the empty string. |
std::runtime_exception | if the found typekit refused to load. |
Definition at line 301 of file PluginLoader.cpp.
bool PluginLoader::loadTypekits | ( | std::string const & | path_list | ) |
Load any typekit found in the 'types/' subdirectory of each path in path_list in the process.
This is not a 'smart' function. It will only look into that directory and will not try to guess a target specific subdir or any other means for locating typekits.
path_list | A colon or semi-colon seperated list of paths to look for typekits. No other paths will be searched. |
std::runtime_exception | if one of the found typekits refused to load. |
Definition at line 296 of file PluginLoader.cpp.
void PluginLoader::Release | ( | ) | [static] |
Release the PluginLoader, erasing all knowledge of loaded libraries.
No libraries will be unloaded from the process.
Definition at line 292 of file PluginLoader.cpp.
void PluginLoader::setPluginPath | ( | std::string const & | newpath | ) |
Sets the plugin path list.
This is typically done by RTT startup code with the contents of the RTT_COMPONENT_PATH variable.
newpath | The new paths to look for plugins. |
Definition at line 741 of file PluginLoader.cpp.