pluginmanager_p.h 4.21 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
hjk's avatar
hjk committed
3 4
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23
**
hjk's avatar
hjk committed
24 25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32 33 34
#ifndef PLUGINMANAGER_P_H
#define PLUGINMANAGER_P_H

#include "pluginspec.h"

35 36 37 38
#include <QSet>
#include <QStringList>
#include <QObject>
#include <QScopedPointer>
39 40 41

QT_BEGIN_NAMESPACE
class QTime;
42
class QTimer;
43
class QSettings;
Friedemann Kleint's avatar
Friedemann Kleint committed
44
class QEventLoop;
45
QT_END_NAMESPACE
con's avatar
con committed
46 47 48 49

namespace ExtensionSystem {

class PluginManager;
50
class PluginCollection;
con's avatar
con committed
51 52 53 54 55

namespace Internal {

class PluginSpecPrivate;

56
class EXTENSIONSYSTEM_EXPORT PluginManagerPrivate : QObject
con's avatar
con committed
57
{
58
    Q_OBJECT
con's avatar
con committed
59 60 61 62 63 64 65 66 67 68
public:
    PluginManagerPrivate(PluginManager *pluginManager);
    virtual ~PluginManagerPrivate();

    // Object pool operations
    void addObject(QObject *obj);
    void removeObject(QObject *obj);

    // Plugin operations
    void loadPlugins();
69
    void shutdown();
con's avatar
con committed
70 71 72 73
    void setPluginPaths(const QStringList &paths);
    QList<PluginSpec *> loadQueue();
    void loadPlugin(PluginSpec *spec, PluginSpec::State destState);
    void resolveDependencies();
74 75
    void initProfiling();
    void profilingReport(const char *what, const PluginSpec *spec = 0);
76
    void setSettings(QSettings *settings);
77
    void setGlobalSettings(QSettings *settings);
78
    void readSettings();
79
    void writeSettings();
80
    void disablePluginIndirectly(PluginSpec *spec);
con's avatar
con committed
81

82
    QHash<QString, PluginCollection *> pluginCategories;
83
    QList<PluginSpec *> pluginSpecs;
con's avatar
con committed
84 85 86 87
    QList<PluginSpec *> testSpecs;
    QStringList pluginPaths;
    QString extension;
    QList<QObject *> allObjects; // ### make this a QList<QPointer<QObject> > > ?
88
    QStringList defaultDisabledPlugins;
con's avatar
con committed
89
    QStringList disabledPlugins;
90
    QStringList forceEnabledPlugins;
91 92 93 94
    // delayed initialization
    QTimer *delayedInitializeTimer;
    QList<PluginSpec *> delayedInitializeQueue;
    // ansynchronous shutdown
95 96
    QList<PluginSpec *> asynchronousPlugins; // plugins that have requested async shutdown
    QEventLoop *shutdownEventLoop; // used for async shutdown
con's avatar
con committed
97 98

    QStringList arguments;
99 100
    QScopedPointer<QTime> m_profileTimer;
    int m_profileElapsedMS;
101
    unsigned m_profilingVerbosity;
102
    QSettings *settings;
103
    QSettings *globalSettings;
con's avatar
con committed
104 105 106 107 108 109 110 111

    // Look in argument descriptions of the specs for the option.
    PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
    PluginSpec *pluginByName(const QString &name) const;

    // used by tests
    static PluginSpec *createSpec();
    static PluginSpecPrivate *privateSpec(PluginSpec *spec);
112 113

private slots:
114
    void nextDelayedInitialize();
115 116
    void asyncShutdownFinished();

con's avatar
con committed
117
private:
118
    PluginCollection *defaultCollection;
con's avatar
con committed
119 120 121 122 123 124 125
    PluginManager *q;

    void readPluginPaths();
    bool loadQueue(PluginSpec *spec,
            QList<PluginSpec *> &queue,
            QList<PluginSpec *> &circularityCheckQueue);
    void stopAll();
126
    void deleteAll();
con's avatar
con committed
127 128 129 130 131 132
};

} // namespace Internal
} // namespace ExtensionSystem

#endif // PLUGINMANAGER_P_H