Fawkes API
Fawkes Development Version
|
#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) |
virtual void | config_value_changed (const Configuration::ValueIterator *v) |
virtual void | config_comment_changed (const Configuration::ValueIterator *v) |
virtual void | config_value_erased (const char *path) |
virtual void | fam_event (const char *filename, unsigned int mask) |
void | load (const std::string &plugin_list) |
Load plugin. More... | |
void | load (const std::list< std::string > &plugin_list) |
Load plugin. More... | |
void | unload (const std::string &plugin_name) |
Unload plugin. More... | |
bool | is_loaded (const std::string &plugin_name) |
Check if plugin is loaded. More... | |
bool | is_meta_plugin (const std::string &plugin_name) |
Check if plugin is a meta plugin. More... | |
std::list< std::string > | get_meta_plugin_children (const std::string &plugin_name) |
Get meta plugin children. 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 89 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 125 of file manager.cpp.
References 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 607 of file manager.cpp.
|
virtual |
Called whenever a comment of a watched value has changed.
v | value iterator for the specific value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 523 of file manager.cpp.
References fawkes::LockList< Type >::lock().
|
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 495 of file manager.cpp.
References fawkes::Configuration::ValueIterator::is_string(), and fawkes::LockList< Type >::lock().
|
virtual |
Called whenever a watched value has changed.
v | value iterator for the specific value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 500 of file manager.cpp.
|
virtual |
Called whenever a value has been erased from the config.
path | path of value |
Implements fawkes::ConfigurationChangeHandler.
Definition at line 528 of file manager.cpp.
|
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 543 of file manager.cpp.
std::list< std::pair< std::string, std::string > > fawkes::PluginManager::get_available_plugins | ( | ) |
Generate list of all available plugins.
Definition at line 222 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 238 of file manager.cpp.
Referenced by XmlRpcPluginMethods::plugin_list::execute().
std::list< std::string > fawkes::PluginManager::get_meta_plugin_children | ( | const std::string & | plugin_name | ) |
Get meta plugin children.
plugin_name | plugin to check |
Definition at line 291 of file manager.cpp.
void fawkes::PluginManager::init_pinfo_cache | ( | ) |
Initialize plugin info cache.
Definition at line 165 of file manager.cpp.
Referenced by PluginManager().
bool fawkes::PluginManager::is_loaded | ( | const std::string & | plugin_name | ) |
Check if plugin is loaded.
plugin_name | plugin to check if it is loaded |
Definition at line 261 of file manager.cpp.
Referenced by fawkes::PluginNetworkHandler::loop().
bool fawkes::PluginManager::is_meta_plugin | ( | const std::string & | plugin_name | ) |
Check if plugin is a meta plugin.
plugin_name | plugin to check |
Definition at line 276 of file manager.cpp.
void fawkes::PluginManager::load | ( | const std::list< std::string > & | 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 341 of file manager.cpp.
References fawkes::Exception::append(), fawkes::LockMap< KeyType, ValueType, LessKey >::erase_locked(), fawkes::Configuration::get_string(), fawkes::Configuration::get_strings(), fawkes::Configuration::is_list(), load(), fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::LibLogger::log_debug(), fawkes::LibLogger::log_info(), fawkes::str_join(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
void fawkes::PluginManager::load | ( | const std::string & | 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 | list of plugin names to load. The plugin list can contain meta plugins. |
Definition at line 329 of file manager.cpp.
Referenced by XmlRpcPluginMethods::plugin_load::execute(), and load().
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 665 of file manager.cpp.
References fawkes::Mutex::try_lock().
void fawkes::PluginManager::remove_listener | ( | PluginManagerListener * | listener | ) |
Remove listener.
listener | listener to remove |
Definition at line 620 of file manager.cpp.
References fawkes::LibLogger::log_warn().
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 158 of file manager.cpp.
References fawkes::LockList< Type >::lock().
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 677 of file manager.cpp.
References fawkes::Mutex::unlock().
void fawkes::PluginManager::unload | ( | const std::string & | 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 431 of file manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::ThreadCollector::remove(), fawkes::PluginLoader::unload(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by XmlRpcPluginMethods::plugin_unload::execute().
void fawkes::PluginManager::unlock | ( | ) |
Unlock plugin manager.
Definition at line 684 of file manager.cpp.