/usr/include/avogadro/pluginmanager.h is in libavogadro-dev 1.2.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | /**********************************************************************
PluginManager - Class to handle dynamic loading/unloading of plugins
Copyright (C) 2008 Donald Ephraim Curtis
Copyright (C) 2008,2009 Tim Vandermeersch
Copyright (C) 2008 Marcus D. Hanwell
This file is part of the Avogadro molecular editor project.
For more information, see <http://avogadro.cc/>
Avogadro is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Avogadro is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
**********************************************************************/
#ifndef PLUGINMANAGER_H
#define PLUGINMANAGER_H
#include <avogadro/global.h>
#include <avogadro/plugin.h>
#include <QStringList>
class QDir;
class QSettings;
class QFileInfo;
namespace Avogadro {
class PluginFactory;
class Tool;
class Engine;
class Extension;
class Color;
class PluginItemPrivate;
class A_EXPORT PluginItem
{
public:
PluginItem();
// PluginItem(int type, const QString &fileName,
// const QString &filePath, PluginFactory *factory);
PluginItem(const QString &name, const QString &identifier,
const QString &description,
Plugin::Type type, const QString &fileName,
const QString &filePath, PluginFactory *factory = 0,
bool enabled = true);
~PluginItem();
/**
* The plugin type (engine = 0, tool = 1, extension = 2)
*/
int type() const;
/**
* The plugin name (Draw, Stick, ...)
*/
QString name() const;
/**
* The plugin description (Draw, Stick, ...)
*/
QString description() const;
/**
* The plugin unique, untranslated identifier
*/
QString identifier() const;
/**
* The plugin filename (libdrawtool.so, libaligntool.dll, ...)
*/
QString fileName() const;
/**
* The absolute file path
*/
QString absoluteFilePath() const;
/**
* Should the plugin be loaded
*/
bool isEnabled() const;
PluginFactory *factory() const;
/**
* Set the plugin type (engine = 0, tool = 1, extension = 2)
*/
void setType( Plugin::Type type );
/**
* Set the plugin name (Draw, Stick, ...)
*/
void setName( const QString &name );
/**
* Set the plugin unique, untranslated identifier
*/
void setIdentifier( const QString &id );
/**
* Set the plugin description
*/
void setDescription( const QString &description );
/**
* The plugin filename (libdrawtool.so, libaligntool.dll, ...)
*/
void setFileName( const QString &fileName );
/**
* The absolute file path
*/
void setAbsoluteFilePath( const QString &filePath );
/**
* Should the plugin be loaded
*/
void setEnabled( bool enable );
void setFactory( PluginFactory *factory );
private:
PluginItemPrivate * const d;
};
class PluginManagerPrivate;
class A_EXPORT PluginManager: public QObject
{
Q_OBJECT
public:
PluginManager(QObject *parent = 0);
~PluginManager();
/**
* Get the singleton instance of the PluginManager. Always use this function
* when using the PluginManager class. This pointer never has to be deleted.
*/
static PluginManager* instance();
/**
* Set the search path for plugins as list of directories.
*/
void setPluginPath(const QStringList& path);
/**
* @overload
* Set the search path for plugins.
*/
void setPluginPath(const QString& path);
/**
* Add list of directories to the search path.
*/
void addToPluginPath(const QStringList& path);
/**
* @overload
* Add the supplied path to the search path.
*/
void addToPluginPath(const QString& path);
/**
* Get the search path for plugins.
*/
QStringList pluginPath() const;
/**
* Find all plugins by looking through the plugin search path. If it was
* not set, the next directories are used
* <bin_location>/../<lib_dir>/avogadro/engines
* <bin_location>/../<lib_dir>/avogadro/tools
* <bin_location>/../<lib_dir>/avogadro/extensions
* <bin_location>/../<lib_dir>/avogadro/colors
* <bin_location>/../<lib_dir>/avogadro/contrib (external plugins)
*
* You can set AVOGADRO_PLUGINS to designate a path at runtime to search.
*
* @param dir Path of directory to search for plugins instead of the default
* paths
* @sa setPluginPath, pluginPath
*/
void loadFactories(const QString& dir = "");
/**
* Load plugins with file names listed in @a plugins from directory @a dir
* and enable/disable them using @a settings
*/
static void loadPluginList(const QDir &dir, const QStringList &plugins,
QSettings &settings);
/**
* Get all the PluginFactory obacjects for a given type.
*/
QList<PluginFactory *> factories( Plugin::Type type );
/**
* Get the PluginFactory of type @p type with plugin identifier @p id.
*/
PluginFactory *factory(const QString &id, Plugin::Type type);
/**
* Get a new instance of the extension with identifier @p id.
* @return 0 if there is no extension plugin with identifier @p id
*/
Extension *extension(const QString &id, QObject *parent = 0);
/**
* Get a new instance of the tool with identifier @p id.
* @return 0 if there is no tool plugin with identifier @p id
*/
Tool *tool(const QString &id, QObject *parent = 0);
/**
* Get a new instance of the color with identifier @p id.
* @return 0 if there is no color plugin with identifier @p id
*/
Color *color(const QString &id, QObject *parent = 0);
/**
* Get a new instance of the color with identifier @p id.
* @return 0 if there is no engine plugin with identifier @p id
*/
Engine *engine(const QString &id, QObject *parent = 0);
/**
* Get a list with the plugin names of type @p type.
*/
QList<QString> names(Plugin::Type type);
/**
* Get a list with the plugin identifiers of type @p type.
*/
QList<QString> identifiers(Plugin::Type type);
/**
* Get a list with the plugin descriptions of type @p type.
*/
QList<QString> descriptions(Plugin::Type type);
/**
* Get a list of all extension (new instances).
*/
QList<Extension *> extensions(QObject *parent=0);
/**
* Get a list of all tools (new instances).
*/
QList<Tool *> tools(QObject *parent=0);
/**
* Get a list of all colors (new instances).
*/
QList<Color *> colors(QObject *parent=0);
/**
* Write the settings of the PluginManager in order to save them to disk.
*/
void writeSettings(QSettings &settings);
/*static void readSettings(QSettings &settings);*/
/**
* Get a list of all python tool script filenames.
*/
QList<QString> toolScripts();
/**
* Get a list of all python engine script filenames.
*/
QList<QString> engineScripts();
/**
* Get a list of all python extension script filenames.
*/
QList<QString> extensionScripts();
/**
* Use by the plugin manager settings dialog
*/
QList<PluginItem *> pluginItems(Plugin::Type);
public Q_SLOTS:
void reload();
Q_SIGNALS:
void reloadPlugins();
private:
PluginManagerPrivate * const d;
/**
* Private function that traverses a directory loading plugins if they are
* valid.
*/
static void loadPluginDir(const QString &directory, QSettings &settings);
static void loadFactory(PluginFactory *factory, QFileInfo &fileInfo,
QSettings &settings);
static QList<QString> scripts(const QString &type);
static void initializeSearchDirs(QStringList &searchDirs);
};
}
#endif
|