Loading...
Searching...
No Matches
pluginManager.h
Go to the documentation of this file.
#ifndef BALL_PLUGIN_PLUGINMANAGER_H
#define BALL_PLUGIN_PLUGINMANAGER_H
#ifndef BALL_COMMON_GLOBAL_H
# include <BALL/COMMON/global.h>
#endif
#ifndef BALL_DATATYPE_STRING_H
# include <BALL/DATATYPE/string.h>
#endif
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QtCore/QHash>
#include <QtCore/QMutex>
#include <QtCore/QReadWriteLock>
#include <boost/shared_ptr.hpp>
#include <list>
#include <map>
class QPluginLoader;
class QObject;
namespace BALL
{
class BALLPlugin;
class PluginHandler;
class BALL_EXPORT PluginManager
{
public:
virtual ~PluginManager();
static PluginManager& instance();
bool addPluginDirectory(const QString& dir);
bool removePluginDirectory(const QString& dir);
std::vector<QString> getPluginDirectories() const;
BALLPlugin* loadPlugin(const QString& plugin_name);
bool unloadPlugin(const QString& plugin);
QObject* getPluginInstance(const QString& plugin);
QObject* getPluginInstance(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);
void registerHandler(const boost::shared_ptr<PluginHandler>& h);
bool unregisterHandler(PluginHandler* h);
// needed for storing this classes' preferences
virtual bool getPluginDirectories(String& value) const;
virtual bool setPluginDirectories(const String&);
virtual QString getAutoActivatePlugins() const;
virtual bool setAutoActivatePlugins(const QString&);
void autoActivatePlugin(const QString& str);
void doNotAutoActivatePlugin(const QString& str);
protected:
static const char* BETWEEN_PLUGINDIR_SEPERATOR;
typedef std::map<QString, vector<BALLPlugin*> > PluginDirMap;
PluginManager();
PluginManager(const PluginManager&);
PluginManager& operator=(const PluginManager&);
bool unloadDirectoryPlugins_(PluginDirMap::iterator it);
PluginDirMap loaded_plugin_dirs_;
QHash<QString, QPluginLoader*> loaders_;
std::list<PluginHandler*> handlers_;
std::list<boost::shared_ptr<PluginHandler> > shared_handlers_;
QStringList autoactivate_plugins_;
static boost::shared_ptr<PluginManager> manager_;
//This mutex is used in the creation of the singleton
static QMutex mutex_;
//This mutex guards the handlers_ list
mutable QReadWriteLock handler_mutex_;
//This mutex guards the loaders_ list
mutable QReadWriteLock loader_mutex_;
};
}
#endif //BALL_PLUGIN_PLUGINMANAGER_H
global.h
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::BALLPlugin
Definition BALLPlugin.h:21
BALL::PluginHandler
Definition pluginHandler.h:28
BALL::PluginManager::unregisterHandler
bool unregisterHandler(PluginHandler *h)
BALL::PluginManager::shared_handlers_
std::list< boost::shared_ptr< PluginHandler > > shared_handlers_
Definition pluginManager.h:224
BALL::PluginManager::PluginDirMap
std::map< QString, vector< BALLPlugin * > > PluginDirMap
Definition pluginManager.h:213
BALL::PluginManager::autoActivatePlugin
void autoActivatePlugin(const QString &str)
BALL::PluginManager::BETWEEN_PLUGINDIR_SEPERATOR
static const char * BETWEEN_PLUGINDIR_SEPERATOR
Definition pluginManager.h:211
BALL::PluginManager::autoactivate_plugins_
QStringList autoactivate_plugins_
Definition pluginManager.h:226
BALL::PluginManager::getAutoActivatePlugins
virtual QString getAutoActivatePlugins() const
BALL::PluginManager::loader_mutex_
QReadWriteLock loader_mutex_
Definition pluginManager.h:235
BALL::PluginManager::instance
static PluginManager & instance()
BALL::PluginManager::loaded_plugin_dirs_
PluginDirMap loaded_plugin_dirs_
Definition pluginManager.h:220
BALL::PluginManager::getPluginDirectories
std::vector< QString > getPluginDirectories() const
BALL::PluginManager::registerHandler
void registerHandler(PluginHandler *h)
BALL::PluginManager::getPluginDirectories
virtual bool getPluginDirectories(String &value) const
BALL::PluginManager::~PluginManager
virtual ~PluginManager()
BALL::PluginManager::unloadDirectoryPlugins_
bool unloadDirectoryPlugins_(PluginDirMap::iterator it)
BALL::PluginManager::getPluginCount
int getPluginCount() const
BALL::PluginManager::handler_mutex_
QReadWriteLock handler_mutex_
Definition pluginManager.h:233
BALL::PluginManager::getPluginInstance
QObject * getPluginInstance(const QString &plugin)
BALL::PluginManager::stopPlugin
bool stopPlugin(const QString &plugin)
BALL::PluginManager::removePluginDirectory
bool removePluginDirectory(const QString &dir)
BALL::PluginManager::unloadPlugin
bool unloadPlugin(const QString &plugin)
BALL::PluginManager::manager_
static boost::shared_ptr< PluginManager > manager_
Definition pluginManager.h:228
BALL::PluginManager::startPlugin
bool startPlugin(int plugin)
BALL::PluginManager::startPlugin
bool startPlugin(const QString &plugin)
BALL::PluginManager::registerHandler
void registerHandler(const boost::shared_ptr< PluginHandler > &h)
BALL::PluginManager::loadPlugin
BALLPlugin * loadPlugin(const QString &plugin_name)
BALL::PluginManager::PluginManager
PluginManager()
BALL::PluginManager::addPluginDirectory
bool addPluginDirectory(const QString &dir)
BALL::PluginManager::loaders_
QHash< QString, QPluginLoader * > loaders_
Definition pluginManager.h:222
BALL::PluginManager::stopPlugin
bool stopPlugin(int plugin)
BALL::PluginManager::unloadAllPlugins
void unloadAllPlugins()
BALL::PluginManager::operator=
PluginManager & operator=(const PluginManager &)
BALL::PluginManager::getPluginInstance
QObject * getPluginInstance(int pos)
BALL::PluginManager::mutex_
static QMutex mutex_
Definition pluginManager.h:231
BALL::PluginManager::stopPlugin
bool stopPlugin(BALLPlugin *plugin)
BALL::PluginManager::setPluginDirectories
virtual bool setPluginDirectories(const String &)
BALL::PluginManager::doNotAutoActivatePlugin
void doNotAutoActivatePlugin(const QString &str)
BALL::PluginManager::setAutoActivatePlugins
virtual bool setAutoActivatePlugins(const QString &)
BALL::PluginManager::handlers_
std::list< PluginHandler * > handlers_
Definition pluginManager.h:223
BALL::PluginManager::PluginManager
PluginManager(const PluginManager &)
BALL::PluginManager::startPlugin
bool startPlugin(BALLPlugin *plugin)
BALL::String
Definition string.h:57
QObject
BALL
Definition constants.h:13
string.h