Fawkes API  Fawkes Development Version
fawkes::PluginManager Class Reference

Fawkes Plugin Manager. More...

#include <>>

Inheritance diagram for fawkes::PluginManager:

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...
 
- Public Member Functions inherited from fawkes::ConfigurationChangeHandler
 ConfigurationChangeHandler (const char *path_prefix)
 Constructor. More...
 
virtual ~ConfigurationChangeHandler ()
 Destructor. More...
 
const char * config_monitor_prefix ()
 Which path prefix shall be monitored. More...
 
- Public Member Functions inherited from fawkes::FamListener
virtual ~FamListener ()
 Virtual empty destructor. More...
 

Additional Inherited Members

- Static Public Attributes inherited from fawkes::FamListener
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...
 

Detailed Description

Fawkes Plugin Manager.

This class provides a manager for the plugins used in fawkes. It can load and unload modules.

Author
Tim Niemueller

Definition at line 51 of file manager.h.

Constructor & Destructor Documentation

◆ PluginManager()

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.

Parameters
thread_collectorthread manager plugin threads will be added to and removed from appropriately.
configFawkes configuration
meta_plugin_prefixPath prefix for meta plugins
module_flagsflags to use to open plugin modules
init_cachetrue 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().

◆ ~PluginManager()

Member Function Documentation

◆ add_listener()

void fawkes::PluginManager::add_listener ( PluginManagerListener listener)

Add listener.

Listeners are notified of plugin load and unloda events.

Parameters
listenerlistener to add

Definition at line 560 of file manager.cpp.

Referenced by fawkes::PluginNetworkHandler::PluginNetworkHandler().

◆ config_comment_changed()

void fawkes::PluginManager::config_comment_changed ( const Configuration::ValueIterator v)
virtual

Called whenever a comment of a watched value has changed.

Parameters
vvalue iterator for the specific value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 474 of file manager.cpp.

◆ config_tag_changed()

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.

Parameters
new_tagnew tag

Implements fawkes::ConfigurationChangeHandler.

Definition at line 446 of file manager.cpp.

◆ config_value_changed()

void fawkes::PluginManager::config_value_changed ( const Configuration::ValueIterator v)
virtual

◆ config_value_erased()

void fawkes::PluginManager::config_value_erased ( const char *  path)
virtual

Called whenever a value has been erased from the config.

Parameters
pathpath of value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 479 of file manager.cpp.

References fawkes::LockList< Type >::lock(), and fawkes::LockList< Type >::unlock().

◆ fam_event()

void fawkes::PluginManager::fam_event ( const char *  filename,
unsigned int  mask 
)
virtual

◆ get_available_plugins()

std::list< std::pair< std::string, std::string > > fawkes::PluginManager::get_available_plugins ( )

Generate list of all available plugins.

Returns
list of plugins that are available, each plugin is represented by a pair of strings. The first string is the plugin name, the second is its description.

Definition at line 218 of file manager.cpp.

Referenced by XmlRpcPluginMethods::plugin_list::execute(), and fawkes::PluginNetworkHandler::~PluginNetworkHandler().

◆ get_loaded_plugins()

std::list< std::string > fawkes::PluginManager::get_loaded_plugins ( )

Get list of loaded plugins.

Returns
list of names of real and meta plugins currently loaded

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().

◆ init_pinfo_cache()

◆ is_loaded()

bool fawkes::PluginManager::is_loaded ( const char *  plugin_name)

Check if plugin is loaded.

Parameters
plugin_nameplugin to check if it is loaded
Returns
true if the plugin is currently loaded, false otherwise

Definition at line 258 of file manager.cpp.

References fawkes::PluginLoader::is_loaded().

Referenced by fawkes::PluginNetworkHandler::loop().

◆ load()

void fawkes::PluginManager::load ( const char *  plugin_list)

◆ lock()

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().

◆ remove_listener()

void fawkes::PluginManager::remove_listener ( PluginManagerListener listener)

Remove listener.

Parameters
listenerlistener to remove

Definition at line 573 of file manager.cpp.

References fawkes::LibLogger::log_warn().

Referenced by fawkes::PluginNetworkHandler::~PluginNetworkHandler().

◆ set_module_flags()

void fawkes::PluginManager::set_module_flags ( Module::ModuleFlags  flags)

Set flags to open modules with.

Parameters
flagsflags 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().

◆ try_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.

Returns
true if the lock was acquired, false otherwise

Definition at line 630 of file manager.cpp.

References fawkes::Mutex::try_lock().

◆ unload()

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.

Parameters
plugin_nameplugin 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().

◆ unlock()

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().


The documentation for this class was generated from the following files: