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. More... | |
~PluginManager () | |
Destructor. More... | |
void | set_module_flags (Module::ModuleFlags flags) |
Set flags to open modules with. More... | |
void | init_pinfo_cache () |
Initialize plugin info cache. More... | |
virtual void | config_tag_changed (const char *new_location) |
Called whenever the tag has changed. More... | |
virtual void | config_value_changed (const Configuration::ValueIterator *v) |
Called whenever a watched value has changed. More... | |
virtual void | config_comment_changed (const Configuration::ValueIterator *v) |
Called whenever a comment of a watched value has changed. More... | |
virtual void | config_value_erased (const char *path) |
Called whenever a value has been erased from the config. More... | |
virtual void | fam_event (const char *filename, unsigned int mask) |
Event has been raised. More... | |
void | load (const char *plugin_list) |
Load plugin. More... | |
void | unload (const char *plugin_name) |
Unload plugin. More... | |
bool | is_loaded (const char *plugin_name) |
Check if plugin is loaded. More... | |
std::list< std::string > | get_loaded_plugins () |
Get list of loaded plugins. More... | |
std::list< std::pair< std::string, std::string > > | get_available_plugins () |
Generate list of all available plugins. More... | |
void | add_listener (PluginManagerListener *listener) |
Add listener. More... | |
void | remove_listener (PluginManagerListener *listener) |
Remove listener. More... | |
void | lock () |
Lock plugin manager. More... | |
bool | try_lock () |
Try to lock plugin manager. More... | |
void | unlock () |
Unlock plugin manager. More... | |
![]() | |
ConfigurationChangeHandler (const char *path_prefix) | |
Constructor. More... | |
virtual | ~ConfigurationChangeHandler () |
Destructor. More... | |
const char * | config_monitor_prefix () |
Which path prefix shall be monitored. More... | |
![]() | |
virtual | ~FamListener () |
Virtual empty destructor. More... | |
Additional Inherited Members | |
![]() | |
static const unsigned int | FAM_ACCESS = 0x00000001 |
File was accessed. More... | |
static const unsigned int | FAM_MODIFY = 0x00000002 |
File was modified. More... | |
static const unsigned int | FAM_ATTRIB = 0x00000004 |
Metadata changed. More... | |
static const unsigned int | FAM_CLOSE_WRITE = 0x00000008 |
Writtable file was closed. More... | |
static const unsigned int | FAM_CLOSE_NOWRITE = 0x00000010 |
Unwrittable file closed. More... | |
static const unsigned int | FAM_CLOSE = (FAM_CLOSE_WRITE | FAM_CLOSE_NOWRITE) |
Close. More... | |
static const unsigned int | FAM_OPEN = 0x00000020 |
File was opened. More... | |
static const unsigned int | FAM_MOVED_FROM = 0x00000040 |
File was moved from X. More... | |
static const unsigned int | FAM_MOVED_TO = 0x00000080 |
File was moved to Y. More... | |
static const unsigned int | FAM_MOVE = (FAM_MOVED_FROM | FAM_MOVED_TO) |
Moves. More... | |
static const unsigned int | FAM_CREATE = 0x00000100 |
Subfile was created. More... | |
static const unsigned int | FAM_DELETE = 0x00000200 |
Subfile was deleted. More... | |
static const unsigned int | FAM_DELETE_SELF = 0x00000400 |
Self was deleted. More... | |
static const unsigned int | FAM_MOVE_SELF = 0x00000800 |
Self was moved. More... | |
static const unsigned int | FAM_UNMOUNT = 0x00002000 |
Backing fs was unmounted. More... | |
static const unsigned int | FAM_Q_OVERFLOW = 0x00004000 |
Event queued overflowed. More... | |
static const unsigned int | FAM_IGNORED = 0x00008000 |
File was ignored. More... | |
static const unsigned int | FAM_ONLYDIR = 0x01000000 |
Only watch the path if it is a directory. More... | |
static const unsigned int | FAM_DONT_FOLLOW = 0x02000000 |
Do not follow a sym link. More... | |
static const unsigned int | FAM_MASK_ADD = 0x20000000 |
Add to the mask of an already existing watch. More... | |
static const unsigned int | FAM_ISDIR = 0x40000000 |
Event occurred against dir. More... | |
static const unsigned int | FAM_ONESHOT = 0x80000000 |
Only send event once. More... | |
static const unsigned int | FAM_ALL_EVENTS |
All events which a program can wait on. More... | |
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 86 of file manager.cpp.
References fawkes::Configuration::add_change_handler(), fawkes::FamThread::get_fam(), fawkes::PluginLoader::get_module_manager(), init_pinfo_cache(), fawkes::LibLogger::log_warn(), fawkes::ModuleManager::set_open_flags(), and fawkes::Thread::start().
fawkes::PluginManager::~PluginManager | ( | ) |
Destructor.
Definition at line 122 of file manager.cpp.
References fawkes::Thread::cancel(), fawkes::ThreadCollector::force_remove(), fawkes::Thread::join(), fawkes::LockList< Type >::lock(), fawkes::Configuration::rem_change_handler(), fawkes::PluginLoader::unload(), and fawkes::LockList< Type >::unlock().
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 560 of file manager.cpp.
Referenced by fawkes::PluginNetworkHandler::PluginNetworkHandler().
|
virtual |
Called whenever a comment of a watched value has changed.
v | value iterator for the specific value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 474 of file manager.cpp.
|
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 446 of file manager.cpp.
|
virtual |
Called whenever a watched value has changed.
v | value iterator for the specific value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 451 of file manager.cpp.
References fawkes::Configuration::ValueIterator::get_string(), fawkes::Configuration::ValueIterator::is_string(), fawkes::LockList< Type >::lock(), fawkes::Configuration::ValueIterator::path(), and fawkes::LockList< Type >::unlock().
|
virtual |
Called whenever a value has been erased from the config.
path | path of value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 479 of file manager.cpp.
References fawkes::LockList< Type >::lock(), and fawkes::LockList< Type >::unlock().
|
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 495 of file manager.cpp.
References fawkes::FamListener::FAM_CREATE, fawkes::FamListener::FAM_DELETE, fawkes::FamListener::FAM_ISDIR, fawkes::FamListener::FAM_MODIFY, fawkes::FamListener::FAM_MOVED_FROM, fawkes::FamListener::FAM_MOVED_TO, fawkes::PluginLoader::get_description(), fawkes::PluginLoader::is_loaded(), fawkes::LockList< Type >::lock(), fawkes::LibLogger::log_info(), fawkes::LibLogger::log_warn(), and fawkes::LockList< Type >::unlock().
std::list< std::pair< std::string, std::string > > fawkes::PluginManager::get_available_plugins | ( | ) |
Generate list of all available plugins.
Definition at line 218 of file manager.cpp.
Referenced by XmlRpcPluginMethods::plugin_list::execute(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().
std::list< std::string > fawkes::PluginManager::get_loaded_plugins | ( | ) |
Get list of loaded plugins.
Definition at line 234 of file manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_list::execute(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().
void fawkes::PluginManager::init_pinfo_cache | ( | ) |
Initialize plugin info cache.
Definition at line 164 of file manager.cpp.
References fawkes::PluginLoader::get_description(), fawkes::Configuration::ValueIterator::get_string(), fawkes::Configuration::ValueIterator::is_string(), fawkes::LockList< Type >::lock(), fawkes::LibLogger::log_warn(), fawkes::Configuration::ValueIterator::next(), fawkes::Configuration::ValueIterator::path(), fawkes::Configuration::search(), and fawkes::LockList< Type >::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 258 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 302 of file manager.cpp.
References fawkes::ThreadCollector::add(), fawkes::Exception::append(), fawkes::LockMap< KeyType, ValueType, LessKey >::erase_locked(), fawkes::Configuration::get_string(), fawkes::PluginLoader::load(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), lock(), fawkes::LibLogger::log_info(), fawkes::LockMap< KeyType, ValueType, LessKey >::mutex(), fawkes::Exception::prepend(), fawkes::Plugin::threads(), fawkes::PluginLoader::unload(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_load::execute(), fawkes::FawkesMainThread::once(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().
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 617 of file manager.cpp.
References fawkes::Mutex::lock().
Referenced by load(), fawkes::FawkesMainThread::loop(), unload(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().
void fawkes::PluginManager::remove_listener | ( | PluginManagerListener * | listener | ) |
Remove listener.
listener | listener to remove |
Definition at line 573 of file manager.cpp.
References fawkes::LibLogger::log_warn().
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 156 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 630 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 386 of file manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::erase_locked(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), lock(), fawkes::LibLogger::log_error(), fawkes::LibLogger::log_info(), fawkes::ThreadCollector::remove(), fawkes::PluginLoader::unload(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_unload::execute(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().
void fawkes::PluginManager::unlock | ( | ) |
Unlock plugin manager.
Definition at line 637 of file manager.cpp.
References fawkes::Mutex::unlock().
Referenced by fawkes::FawkesMainThread::loop(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().