RTT::plugin::PluginLoader Class Reference
#include <PluginLoader.hpp>
List of all members.
Classes |
class | LoadedLib |
Public Types |
typedef boost::shared_ptr
< PluginLoader > | shared_ptr |
Public Member Functions |
std::string | getPluginPath () const |
bool | isLoaded (std::string name) |
std::vector< std::string > | listPlugins () const |
std::vector< std::string > | listServices () const |
std::vector< std::string > | listTypekits () const |
bool | loadLibrary (std::string const &path) |
bool | loadPlugin (std::string const &name, std::string const &path_list) |
bool | loadPlugins (std::string const &path_list) |
bool | loadService (std::string const &servicename, TaskContext *tc) |
bool | loadTypekit (std::string const &name, std::string const &path_list) |
bool | loadTypekits (std::string const &path_list) |
| PluginLoader () |
void | setPluginPath (std::string const &newpath) |
| ~PluginLoader () |
Static Public Member Functions |
static boost::shared_ptr
< PluginLoader > | Instance () |
static void | Release () |
Private Member Functions |
bool | isCompatiblePlugin (std::string const &filepath) |
bool | isLoadedInternal (std::string name) |
bool | loadInProcess (std::string filename, std::string shortname, std::string kind, bool log_error) |
bool | loadPluginInternal (std::string const &name, std::string const &path_list, std::string const &subdir, std::string const &kind) |
bool | loadPluginsInternal (std::string const &path_list, std::string const &subdir, std::string const &kind) |
Private Attributes |
os::Mutex | listlock |
std::vector< LoadedLib > | loadedLibs |
std::string | plugin_path |
Detailed Description
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 (".").
- See also:
- Plugin.hpp
Definition at line 68 of file PluginLoader.hpp.
Member Typedef Documentation
Constructor & Destructor Documentation
RTT::plugin::PluginLoader::PluginLoader |
( |
|
) |
|
RTT::plugin::PluginLoader::~PluginLoader |
( |
|
) |
|
Member Function Documentation
std::string RTT::plugin::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.
- Returns:
- A colon separated list of paths or the empty string if not set.
static boost::shared_ptr<PluginLoader> RTT::plugin::PluginLoader::Instance |
( |
|
) |
[static] |
Create the instance of the PluginLoader. It will keep track of the loaded libraries for this process.
- Returns:
- A singleton.
bool RTT::plugin::PluginLoader::isCompatiblePlugin |
( |
std::string const & |
filepath |
) |
[private] |
Internal helper function that validate if a plugin is compatible with the current target. Currently, there's a validation only on the win32 platform to avoid mixing debug/release runtime libraries.
- Parameters:
-
| filepath | Full path of plugin to validate (with extension) |
- Returns:
- true if the plugin is compatible
bool RTT::plugin::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').
- Parameters:
-
| name | name of a file or the plugin name. |
- Returns:
- true if so.
bool RTT::plugin::PluginLoader::isLoadedInternal |
( |
std::string |
name |
) |
[private] |
This function does not hold the listlock.
- See also:
- isLoaded()
std::vector<std::string> RTT::plugin::PluginLoader::listPlugins |
( |
|
) |
const |
Lists all plugins (= services + typekits) discovered by the PluginLoader.
- Returns:
- A list of plugin names
std::vector<std::string> RTT::plugin::PluginLoader::listServices |
( |
|
) |
const |
Lists all services discovered by the PluginLoader.
- Returns:
- A list of service names
std::vector<std::string> RTT::plugin::PluginLoader::listTypekits |
( |
|
) |
const |
Lists all typekits discovered by the PluginLoader.
- Returns:
- A list of typekit names
bool RTT::plugin::PluginLoader::loadInProcess |
( |
std::string |
filename, |
|
|
std::string |
shortname, |
|
|
std::string |
kind, |
|
|
bool |
log_error | |
|
) |
| | [private] |
Internal function that does all library loading.
- Parameters:
-
| filename | The path+filename to open |
| shortname | The short name of this file |
| kind | The kind of plugin to load: 'plugin' or 'typekit'. |
| log_error | Log errors to users. Set to false in case you are poking files to see if they can be loaded. |
- Returns:
- true if a new library was loaded or if this library was already loaded.
bool RTT::plugin::PluginLoader::loadLibrary |
( |
std::string const & |
path |
) |
|
Loads a library as plugin or typekit.
- Parameters:
-
| path | an absolute or relative path to a library. Relative paths are interpreted with regard to the plugin path. |
bool RTT::plugin::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.
- Parameters:
-
| 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. |
- Exceptions:
-
| std::runtime_exception | if the found plugin refused to load. |
bool RTT::plugin::PluginLoader::loadPluginInternal |
( |
std::string const & |
name, |
|
|
std::string const & |
path_list, |
|
|
std::string const & |
subdir, |
|
|
std::string const & |
kind | |
|
) |
| | [private] |
Helper function for loadTypekit and loadPlugin.
- Parameters:
-
| name | |
| path_list | |
| subdir | |
| kind | |
- Returns:
- false if no plugins were found
- Exceptions:
-
| std::runtime_exception | if one of the found plugins refused to load. |
bool RTT::plugin::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.
- Returns:
- false if some typekit caused an error, or some path was not found.
- Parameters:
-
| path_list | A colon or semi-colon seperated list of paths to look for plugins. May be the empty string. |
- Exceptions:
-
| std::runtime_exception | if one of the found plugin refused to load. |
bool RTT::plugin::PluginLoader::loadPluginsInternal |
( |
std::string const & |
path_list, |
|
|
std::string const & |
subdir, |
|
|
std::string const & |
kind | |
|
) |
| | [private] |
Helper function for loadTypekits and loadPlugins.
- Parameters:
-
- Returns:
- false if no plugins were found
- Exceptions:
-
| std::runtime_exception | if one of the found plugins refused to load. |
bool RTT::plugin::PluginLoader::loadService |
( |
std::string const & |
servicename, |
|
|
TaskContext * |
tc | |
|
) |
| | |
Loads an earlier discovered service into a TaskContext.
- Parameters:
-
| servicename | The name of the service or plugin containing the service |
| tc | The TaskContext to load into. |
- Returns:
- false if the service or plugin refused to load into the TaskContext.
bool RTT::plugin::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.
- Parameters:
-
| path_list | A colon or semi-colon seperated list of paths to look for typekits. May be empty the empty string. |
- Exceptions:
-
| std::runtime_exception | if the found typekit refused to load. |
bool RTT::plugin::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.
- Returns:
- false if some typekit caused an error, or some path was not found.
- Parameters:
-
| path_list | A colon or semi-colon seperated list of paths to look for typekits. No other paths will be searched. |
- Exceptions:
-
| std::runtime_exception | if one of the found typekits refused to load. |
static void RTT::plugin::PluginLoader::Release |
( |
|
) |
[static] |
Release the PluginLoader, erasing all knowledge of loaded libraries. No libraries will be unloaded from the process.
void RTT::plugin::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.
- Parameters:
-
| newpath | The new paths to look for plugins. |
Member Data Documentation
Protects for concurrent access of this shared object.
Definition at line 108 of file PluginLoader.hpp.
The documentation for this class was generated from the following file: