Fawkes API
Fawkes Development Version
|
Fawkes Plugin Manager. More...
#include <>>
Public Member Functions | |
PluginManager (ThreadCollector *thread_collector, Configuration *config, const char *meta_plugin_prefix, Module::ModuleFlags module_flags=Module::MODULE_FLAGS_DEFAULT, bool init_cache=true) | |
Constructor. | |
~PluginManager () | |
Destructor. | |
void | set_module_flags (Module::ModuleFlags flags) |
Set flags to open modules with. | |
void | init_pinfo_cache () |
Initialize plugin info cache. | |
virtual void | config_tag_changed (const char *new_location) |
Called whenever the tag has changed. | |
virtual void | config_value_changed (const Configuration::ValueIterator *v) |
Called whenever a watched value has changed. | |
virtual void | config_comment_changed (const Configuration::ValueIterator *v) |
Called whenever a comment of a watched value has changed. | |
virtual void | config_value_erased (const char *path) |
Called whenever a value has been erased from the config. | |
virtual void | fam_event (const char *filename, unsigned int mask) |
Event has been raised. | |
void | load (const char *plugin_list) |
Load plugin. | |
void | unload (const char *plugin_name) |
Unload plugin. | |
bool | is_loaded (const char *plugin_name) |
Check if plugin is loaded. | |
std::list< std::string > | get_loaded_plugins () |
Get list of loaded plugins. | |
std::list< std::pair < std::string, std::string > > | get_available_plugins () |
Generate list of all available plugins. | |
void | add_listener (PluginManagerListener *listener) |
Add listener. | |
void | remove_listener (PluginManagerListener *listener) |
Remove listener. | |
void | lock () |
Lock plugin manager. | |
bool | try_lock () |
Try to lock plugin manager. | |
void | unlock () |
Unlock plugin manager. |
Fawkes Plugin Manager.
This class provides a manager for the plugins used in fawkes. It can load and unload modules.
fawkes::PluginManager::PluginManager | ( | ThreadCollector * | thread_collector, |
Configuration * | config, | ||
const char * | meta_plugin_prefix, | ||
Module::ModuleFlags | module_flags = Module::MODULE_FLAGS_DEFAULT , |
||
bool | init_cache = true |
||
) |
Constructor.
thread_collector | thread manager plugin threads will be added to and removed from appropriately. |
config | Fawkes configuration |
meta_plugin_prefix | Path prefix for meta plugins |
module_flags | flags to use to open plugin modules |
init_cache | true to initialize the plugin cache, false to skip this step. Note that some functions like transmitting a list of available plugins is unavailable until the cache has been initialized. You can defer initialization of the cache if required. |
Definition at line 88 of file manager.cpp.
References fawkes::PluginLoader::get_module_manager(), fawkes::ModuleManager::set_open_flags(), init_pinfo_cache(), fawkes::Configuration::add_change_handler(), and fawkes::LibLogger::log_warn().
fawkes::PluginManager::~PluginManager | ( | ) |
Destructor.
Definition at line 124 of file manager.cpp.
References fawkes::Configuration::rem_change_handler(), fawkes::LockList::lock(), fawkes::LockList::unlock(), fawkes::ThreadCollector::force_remove(), and fawkes::PluginLoader::unload().
void fawkes::PluginManager::add_listener | ( | PluginManagerListener * | listener | ) |
Add listener.
Listeners are notified of plugin load and unloda events.
listener | listener to add |
Definition at line 542 of file manager.cpp.
References fawkes::LockList::lock(), and fawkes::LockList::unlock().
Referenced by fawkes::PluginNetworkHandler::PluginNetworkHandler().
void fawkes::PluginManager::config_comment_changed | ( | const Configuration::ValueIterator * | v | ) | [virtual] |
Called whenever a comment of a watched value has changed.
v | value iterator for the specific value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 463 of file manager.cpp.
void fawkes::PluginManager::config_tag_changed | ( | const char * | new_tag | ) | [virtual] |
Called whenever the tag has changed.
This function can be used to detect when data from another tag has been loaded.
new_tag | new tag |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 435 of file manager.cpp.
void fawkes::PluginManager::config_value_changed | ( | const Configuration::ValueIterator * | v | ) | [virtual] |
Called whenever a watched value has changed.
v | value iterator for the specific value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 440 of file manager.cpp.
References fawkes::Configuration::ValueIterator::is_string(), fawkes::LockList::lock(), fawkes::Configuration::ValueIterator::path(), fawkes::Configuration::ValueIterator::get_string(), and fawkes::LockList::unlock().
void fawkes::PluginManager::config_value_erased | ( | const char * | path | ) | [virtual] |
Called whenever a value has been erased from the config.
path | path of value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 468 of file manager.cpp.
References fawkes::LockList::lock(), and fawkes::LockList::unlock().
void fawkes::PluginManager::fam_event | ( | const char * | filename, |
unsigned int | mask | ||
) | [virtual] |
Event has been raised.
filename | name of the file that triggered the event |
mask | mask indicating the event. Currently inotify event flags are used, see inotify.h. |
Implements fawkes::FamListener.
Definition at line 484 of file manager.cpp.
References fawkes::LockList::lock(), fawkes::FamListener::FAM_DELETE, fawkes::FamListener::FAM_MOVED_FROM, fawkes::PluginLoader::get_description(), fawkes::LibLogger::log_warn(), fawkes::FamListener::FAM_ISDIR, fawkes::FamListener::FAM_MODIFY, fawkes::FamListener::FAM_MOVED_TO, fawkes::FamListener::FAM_CREATE, fawkes::PluginLoader::is_loaded(), fawkes::LibLogger::log_info(), and fawkes::LockList::unlock().
std::list< std::pair< std::string, std::string > > fawkes::PluginManager::get_available_plugins | ( | ) |
Generate list of all available plugins.
Definition at line 213 of file manager.cpp.
Referenced by XmlRpcPluginMethods::plugin_list::execute().
std::list< std::string > fawkes::PluginManager::get_loaded_plugins | ( | ) |
Get list of loaded plugins.
Definition at line 229 of file manager.cpp.
References fawkes::LockList::lock(), fawkes::LockList::unlock(), fawkes::LockMap::lock(), and fawkes::LockMap::unlock().
Referenced by XmlRpcPluginMethods::plugin_list::execute().
void fawkes::PluginManager::init_pinfo_cache | ( | ) |
Initialize plugin info cache.
Definition at line 159 of file manager.cpp.
References fawkes::LockList::lock(), fawkes::PluginLoader::get_description(), fawkes::LibLogger::log_warn(), fawkes::Configuration::search(), fawkes::Configuration::ValueIterator::next(), fawkes::Configuration::ValueIterator::is_string(), fawkes::Configuration::ValueIterator::path(), fawkes::Configuration::ValueIterator::get_string(), and fawkes::LockList::unlock().
Referenced by PluginManager().
bool fawkes::PluginManager::is_loaded | ( | const char * | plugin_name | ) |
Check if plugin is loaded.
plugin_name | plugin to check if it is loaded |
Definition at line 253 of file manager.cpp.
References fawkes::PluginLoader::is_loaded().
Referenced by fawkes::PluginNetworkHandler::loop().
void fawkes::PluginManager::load | ( | const char * | plugin_list | ) |
Load plugin.
The loading is interrupted if any of the plugins does not load properly. The already loaded plugins are *not* unloaded, but kept.
plugin_list | string containing a comma-separated list of plugins to load. The plugin list can contain meta plugins. |
Definition at line 297 of file manager.cpp.
References fawkes::Configuration::get_string(), fawkes::LockMap::lock(), fawkes::LockMap::unlock(), fawkes::LibLogger::log_info(), fawkes::Exception::append(), fawkes::LockMap::erase_locked(), fawkes::PluginLoader::load(), fawkes::ThreadCollector::add(), fawkes::Plugin::threads(), fawkes::Exception::prepend(), fawkes::PluginLoader::unload(), lock(), and fawkes::LockMap::mutex().
Referenced by fawkes::FawkesMainThread::once(), and XmlRpcPluginMethods::plugin_load::execute().
void fawkes::PluginManager::lock | ( | ) |
Lock plugin manager.
This is an utility method that you can use for mutual access to the plugin manager. The mutex is not used internally, but meant to be used from callers.
Definition at line 599 of file manager.cpp.
References fawkes::Mutex::lock().
Referenced by load(), unload(), and fawkes::FawkesMainThread::loop().
void fawkes::PluginManager::remove_listener | ( | PluginManagerListener * | listener | ) |
Remove listener.
listener | listener to remove |
Definition at line 555 of file manager.cpp.
References fawkes::LockList::remove_locked().
Referenced by fawkes::PluginNetworkHandler::~PluginNetworkHandler().
void fawkes::PluginManager::set_module_flags | ( | Module::ModuleFlags | flags | ) |
Set flags to open modules with.
flags | flags to pass to modules when opening them |
Definition at line 151 of file manager.cpp.
References fawkes::PluginLoader::get_module_manager(), and fawkes::ModuleManager::set_open_flags().
bool fawkes::PluginManager::try_lock | ( | ) |
Try to lock plugin manager.
This is an utility method that you can use for mutual access to the plugin manager. The mutex is not used internally, but meant to be used from callers.
Definition at line 612 of file manager.cpp.
References fawkes::Mutex::try_lock().
void fawkes::PluginManager::unload | ( | const char * | plugin_name | ) |
Unload plugin.
Note that this method does not allow to pass a list of plugins, but it will only accept a single plugin at a time.
plugin_name | plugin to unload, can be a meta plugin. |
Definition at line 375 of file manager.cpp.
References lock(), fawkes::ThreadCollector::remove(), fawkes::PluginLoader::unload(), fawkes::LockMap::lock(), fawkes::LockMap::unlock(), fawkes::LibLogger::log_error(), fawkes::LockMap::erase_locked(), and fawkes::LibLogger::log_info().
Referenced by XmlRpcPluginMethods::plugin_unload::execute().
void fawkes::PluginManager::unlock | ( | ) |
Unlock plugin manager.
Definition at line 619 of file manager.cpp.
References fawkes::Mutex::unlock().
Referenced by fawkes::FawkesMainThread::loop().