fawkes::PluginLoader Class Reference
This class manages plugins. More...
#include <plugin/loader.h>
Public Member Functions | |
| PluginLoader (const char *plugin_base_dir, Configuration *config) | |
| Constructor. | |
| ~PluginLoader () | |
| Destructor. | |
| Plugin * | load (const char *plugin_name) |
| Load a specific plugin The plugin loader is clever and guarantees that every plugin is only loaded once (as long as you use only one instance of the PluginLoader, using multiple instances is discouraged. | |
| void | unload (Plugin *plugin) |
| Unload the given plugin This will unload the given plugin. | |
| std::string | get_description (const char *plugin_name) |
| Get plugin description. | |
| bool | is_loaded (const char *plugin_name) |
| Check if a plugin is loaded. | |
Detailed Description
This class manages plugins.With this class plugins can be loaded and unloaded. Information is kept about active plugins.
Definition at line 55 of file loader.h.
Constructor & Destructor Documentation
| fawkes::PluginLoader::PluginLoader | ( | const char * | plugin_base_dir, | |
| Configuration * | config | |||
| ) |
Constructor.
- Parameters:
-
plugin_base_dir The base directory where to search for the shared libraries which contain the plugins config Fawkes configuration
Definition at line 107 of file loader.cpp.
References fawkes::ModuleManagerFactory::getInstance(), and fawkes::ModuleManagerFactory::MMT_DL.
| fawkes::PluginLoader::~PluginLoader | ( | ) |
Member Function Documentation
| std::string fawkes::PluginLoader::get_description | ( | const char * | plugin_name | ) |
Get plugin description.
- Parameters:
-
plugin_name name of the plugin
- Returns:
- plugin description tring
- Exceptions:
-
PluginLoadException thrown if opening the plugin fails
Definition at line 205 of file loader.cpp.
References fawkes::Module::get_symbol(), and fawkes::Module::has_symbol().
Referenced by fawkes::PluginManager::fam_event().
| bool fawkes::PluginLoader::is_loaded | ( | const char * | plugin_name | ) |
Check if a plugin is loaded.
- Parameters:
-
plugin_name name of the plugin to chekc
- Returns:
- true if the plugin is loaded, false otherwise
Definition at line 226 of file loader.cpp.
Referenced by fawkes::PluginManager::fam_event(), and fawkes::PluginManager::is_loaded().
| Plugin * fawkes::PluginLoader::load | ( | const char * | plugin_name | ) |
Load a specific plugin The plugin loader is clever and guarantees that every plugin is only loaded once (as long as you use only one instance of the PluginLoader, using multiple instances is discouraged.
If you try to open a plugin a second time it will return the very same instance that it returned on previous load()s.
- Parameters:
-
plugin_name The name of the plugin to be loaded, the plugin name has to correspond to a plugin name and the name of the shared object that will be opened for this plugin (for instance on Linux systems opening the plugin test_plugin will look for plugin_base_dir/test_plugin.so)
- Returns:
- Returns a pointer to the opened plugin. Do not under any circumstances delete this object, use unload() instead! Since the delete operator could be overloaded this would result in memory chaos.
- Exceptions:
-
PluginLoadException thrown if plugin could not be loaded ModuleOpenException passed along from module manager
Definition at line 176 of file loader.cpp.
Referenced by fawkes::PluginManager::load().
| void fawkes::PluginLoader::unload | ( | Plugin * | plugin | ) |
Unload the given plugin This will unload the given plugin.
The plugin is destroyed with the proper destroy method from the shared object. The shared object is unloaded after the destruction of the plugin. Note that even though you may call load() multiple times per plugin you may only unload() it once! Every further access will lead to a segmentation fault. Make sure that you have closed any resources claimed by the plugin like threads, memory access etc.
- Parameters:
-
plugin The plugin that has to be unloaded
Definition at line 244 of file loader.cpp.
Referenced by fawkes::PluginManager::load(), fawkes::PluginManager::unload(), and fawkes::PluginManager::~PluginManager().
The documentation for this class was generated from the following files:
- src/libs/plugin/loader.h
- src/libs/plugin/loader.cpp

