Fawkes API  Fawkes Development Version
fawkes::PluginManager Class Reference

Fawkes Plugin Manager. More...

#include <>>

Inheritance diagram for fawkes::PluginManager:

List of all members.

Public Member Functions

 PluginManager (ThreadCollector *thread_collector, Configuration *config, const char *meta_plugin_prefix)
 Constructor.
 ~PluginManager ()
 Destructor.
virtual void config_tag_changed (const char *new_tag)
 Called whenever the tag has changed.
virtual void config_value_changed (const char *path, bool is_default, int value)
 Called whenever an int value has changed.
virtual void config_value_changed (const char *path, bool is_default, unsigned int value)
 Called whenever an unsigned int value has changed.
virtual void config_value_changed (const char *path, bool is_default, float value)
 Called whenever an float value has changed.
virtual void config_value_changed (const char *path, bool is_default, bool value)
 Called whenever an boolean value has changed.
virtual void config_value_changed (const char *path, bool is_default, const char *value)
 Called whenever a string value has changed.
virtual void config_comment_changed (const char *path, bool is_default, const char *comment)
 Called whenever a comment has changed.
virtual void config_value_erased (const char *path, bool is_default)
 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::stringget_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.

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

Constructor & Destructor Documentation

fawkes::PluginManager::PluginManager ( ThreadCollector thread_collector,
Configuration config,
const char *  meta_plugin_prefix 
)

Constructor.

Parameters:
thread_collectorthread manager plugin threads will be added to and removed from appropriately.
configFawkes configuration
meta_plugin_prefixPath prefix for meta plugins

Definition at line 66 of file manager.cpp.

References fawkes::Configuration::add_change_handler(), and fawkes::LibLogger::log_warn().


Member Function Documentation

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 531 of file manager.cpp.

References fawkes::LockList::lock(), and fawkes::LockList::unlock().

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

void fawkes::PluginManager::config_comment_changed ( const char *  path,
bool  is_default,
const char *  comment 
) [virtual]

Called whenever a comment has changed.

Parameters:
pathpath of value
is_defaulttrue if modified comment is of a default value, false otherwise
commentnew comment

Implements fawkes::ConfigurationChangeHandler.

Definition at line 429 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.

Parameters:
new_tagnew tag

Implements fawkes::ConfigurationChangeHandler.

Definition at line 396 of file manager.cpp.

void fawkes::PluginManager::config_value_changed ( const char *  path,
bool  is_default,
int  value 
) [virtual]

Called whenever an int value has changed.

Parameters:
pathpath of value
is_defaulttrue if modified value is a default value, false otherwise
valuenew value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 401 of file manager.cpp.

References fawkes::LibLogger::log_warn().

void fawkes::PluginManager::config_value_changed ( const char *  path,
bool  is_default,
unsigned int  value 
) [virtual]

Called whenever an unsigned int value has changed.

Parameters:
pathpath of value
is_defaulttrue if modified value is a default value, false otherwise
valuenew value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 408 of file manager.cpp.

References fawkes::LibLogger::log_warn().

void fawkes::PluginManager::config_value_changed ( const char *  path,
bool  is_default,
float  value 
) [virtual]

Called whenever an float value has changed.

Parameters:
pathpath of value
is_defaulttrue if modified value is a default value, false otherwise
valuenew value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 415 of file manager.cpp.

References fawkes::LibLogger::log_warn().

void fawkes::PluginManager::config_value_changed ( const char *  path,
bool  is_default,
bool  value 
) [virtual]

Called whenever an boolean value has changed.

Parameters:
pathpath of value
is_defaulttrue if modified value is a default value, false otherwise
valuenew value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 422 of file manager.cpp.

References fawkes::LibLogger::log_warn().

void fawkes::PluginManager::config_value_changed ( const char *  path,
bool  is_default,
const char *  value 
) [virtual]

Called whenever a string value has changed.

Parameters:
pathpath of value
is_defaulttrue if modified value is a default value, false otherwise
valuenew value

Implements fawkes::ConfigurationChangeHandler.

Definition at line 435 of file manager.cpp.

References fawkes::LockList::lock(), and fawkes::LockList::unlock().

void fawkes::PluginManager::config_value_erased ( const char *  path,
bool  is_default 
) [virtual]

Called whenever a value has been erased from the config.

Parameters:
pathpath of value
is_defaulttrue if erased value was a default value, false otherwise

Implements fawkes::ConfigurationChangeHandler.

Definition at line 456 of file manager.cpp.

References fawkes::LockList::lock(), and fawkes::LockList::unlock().

void fawkes::PluginManager::fam_event ( const char *  filename,
unsigned int  mask 
) [virtual]
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 175 of file manager.cpp.

Referenced by XmlRpcPluginMethods::plugin_list::execute().

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 191 of file manager.cpp.

References fawkes::LockMap::lock(), and fawkes::LockMap::unlock().

Referenced by XmlRpcPluginMethods::plugin_list::execute().

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 215 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.

Parameters:
plugin_liststring containing a comma-separated list of plugins to load. The plugin list can contain meta plugins.

Definition at line 259 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(), and fawkes::LockMap::mutex().

Referenced by XmlRpcPluginMethods::plugin_load::execute(), and FawkesMainThread::once().

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

Remove listener.

Parameters:
listenerlistener to remove

Definition at line 544 of file manager.cpp.

References fawkes::LockList::remove_locked().

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

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 335 of file manager.cpp.

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


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