BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
BALL::PluginManager Class Reference

#include <BALL/PLUGIN/pluginManager.h>

Inheritance diagram for BALL::PluginManager:
BALL::PreferencesObject QObject

Public Member Functions

virtual ~PluginManager ()
 
void addPluginDirectory (const QString &dir, bool autoactivate=false)
 
bool removePluginDirectory (const QString &dir)
 
vector< QString > getPluginDirectories () const
 
BALLPluginloadPlugin (const QString &plugin_name)
 
bool unloadPlugin (const QString &plugin)
 
QObjectgetPluginInstance (const QString &plugin)
 
QObjectgetPluginInstance (int pos)
 
bool startPlugin (int plugin)
 
bool startPlugin (const QString &plugin)
 
bool startPlugin (BALLPlugin *plugin)
 
bool stopPlugin (int plugin)
 
bool stopPlugin (const QString &plugin)
 
bool stopPlugin (BALLPlugin *plugin)
 
void unloadAllPlugins ()
 
int getPluginCount () const
 
void registerHandler (PluginHandler *h)
 
virtual bool getValue (String &) const
 Overload this in derived classes! More...
 
virtual bool setValue (const String &)
 Overload this in derived classes! More...
 
- Public Member Functions inherited from BALL::PreferencesObject
 PreferencesObject ()
 
virtual ~PreferencesObject ()
 

Static Public Member Functions

static PluginManagerinstance ()
 

Protected Member Functions

 PluginManager ()
 
 PluginManager (const PluginManager &)
 
PluginManageroperator= (const PluginManager &)
 

Protected Attributes

std::map< QString, vector
< BALLPlugin * > > 
loaded_plugin_dirs_
 
QHash< QString, QPluginLoader * > loaders_
 
std::list< PluginHandler * > handlers_
 
QReadWriteLock handler_mutex_
 
QReadWriteLock loader_mutex_
 

Static Protected Attributes

static const char * BETWEEN_PLUGINDIR_SEPERATOR
 
static boost::shared_ptr
< PluginManager
manager_
 
static QMutex mutex_
 

Detailed Description

A singleton that takes care of handling all plugins. It is responsible for loading, starting and stopping plugins. For the task of properly initializing the plugins it utilizes the PluginHandler helper classes, that need to be supplemented for each new plugin type.

Definition at line 33 of file pluginManager.h.

Constructor & Destructor Documentation

virtual BALL::PluginManager::~PluginManager ( )
virtual
BALL::PluginManager::PluginManager ( )
protected
BALL::PluginManager::PluginManager ( const PluginManager )
protected

Member Function Documentation

void BALL::PluginManager::addPluginDirectory ( const QString &  dir,
bool  autoactivate = false 
)

Tries to load all plugins (files named like: pluginMyPlugin.$LIBRARY_SUFFIX) located in the specified directoy dir.

Parameters
dirthe directory to search for plugins.
int BALL::PluginManager::getPluginCount ( ) const

Returns the number of loaded plugins.

vector<QString> BALL::PluginManager::getPluginDirectories ( ) const

Return a list of directories currently searched for plugins.

QObject* BALL::PluginManager::getPluginInstance ( const QString &  plugin)

Searches for the plugin and returns a pointer to it if it has been loaded.

Parameters
pluginThe name of the plugin to search
Returns
NULL if the plugin could not be found, a pointer to it otherwise
QObject* BALL::PluginManager::getPluginInstance ( int  pos)

Searches for the plugin and returns a pointer to it if it has been loaded.

Parameters
posThe position of the plugin in the plugin list
Returns
NULL if the plugin could not be found, a pointer to it otherwise
virtual bool BALL::PluginManager::getValue ( String ) const
virtual

Overload this in derived classes!

Implements BALL::PreferencesObject.

static PluginManager& BALL::PluginManager::instance ( )
static

Use this method to obtain the PluginManager instance.

This method is thread safe.

BALLPlugin* BALL::PluginManager::loadPlugin ( const QString &  plugin_name)

Loads the plugin specified by plugin_name.

Parameters
plugin_nameThe path to the plugin to load
Returns
NULL if the plugin could not be loaded. A valid pointer to the loaded plugin otherwise.
PluginManager& BALL::PluginManager::operator= ( const PluginManager )
protected
void BALL::PluginManager::registerHandler ( PluginHandler h)

Register a new PluginHandler. This handler will then be available for starting new plugins.

bool BALL::PluginManager::removePluginDirectory ( const QString &  dir)

Tries to unload all plugins (files named like: pluginMyPlugin.$LIBRARY_SUFFIX) located in the specified directoy dir.

Parameters
dirthe directory to search for plugins to remove.
virtual bool BALL::PluginManager::setValue ( const String )
virtual

Overload this in derived classes!

Implements BALL::PreferencesObject.

bool BALL::PluginManager::startPlugin ( int  plugin)
bool BALL::PluginManager::startPlugin ( const QString &  plugin)
bool BALL::PluginManager::startPlugin ( BALLPlugin plugin)

Starts the specified plugin through a applicable PluginHandler

Parameters
pluginA pointer to the plugin to be started
Returns
false if no suitable handler could be found, true otherwise.
bool BALL::PluginManager::stopPlugin ( int  plugin)
bool BALL::PluginManager::stopPlugin ( const QString &  plugin)
bool BALL::PluginManager::stopPlugin ( BALLPlugin plugin)

Stops the specified plugin by letting all PluginHandlers stop it.

Parameters
pluginA pointer to the plugin to be stopped
Returns
false if one handler could not stop the plugin, true otherwise.
void BALL::PluginManager::unloadAllPlugins ( )

Unload all registered plugins.

bool BALL::PluginManager::unloadPlugin ( const QString &  plugin)

Unloads the plugin specified by plugin_name.

Parameters
plugin_nameThe name of the plugin to unload

Member Data Documentation

const char* BALL::PluginManager::BETWEEN_PLUGINDIR_SEPERATOR
staticprotected

Definition at line 168 of file pluginManager.h.

QReadWriteLock BALL::PluginManager::handler_mutex_
mutableprotected

Definition at line 184 of file pluginManager.h.

std::list<PluginHandler*> BALL::PluginManager::handlers_
protected

Definition at line 177 of file pluginManager.h.

std::map<QString, vector<BALLPlugin*> > BALL::PluginManager::loaded_plugin_dirs_
protected

Definition at line 174 of file pluginManager.h.

QReadWriteLock BALL::PluginManager::loader_mutex_
mutableprotected

Definition at line 186 of file pluginManager.h.

QHash<QString, QPluginLoader*> BALL::PluginManager::loaders_
protected

Definition at line 176 of file pluginManager.h.

boost::shared_ptr<PluginManager> BALL::PluginManager::manager_
staticprotected

Definition at line 179 of file pluginManager.h.

QMutex BALL::PluginManager::mutex_
staticprotected

Definition at line 182 of file pluginManager.h.