-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpluginspec.h
126 lines (97 loc) · 4.03 KB
/
pluginspec.h
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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include "extensionsystem_global.h"
#include <QHash>
#include <QStaticPlugin>
#include <QString>
#include <QVector>
QT_BEGIN_NAMESPACE
class QRegularExpression;
QT_END_NAMESPACE
namespace ExtensionSystem {
namespace Internal {
class OptionsParser;
class PluginSpecPrivate;
class PluginManagerPrivate;
} // namespace Internal
class IPlugin;
class PluginView;
struct EXTENSIONSYSTEM_EXPORT PluginDependency
{
enum Type { Required, Optional, Test };
PluginDependency()
: type(Required)
{}
friend auto qHash(const PluginDependency &value) -> size_t;
QString name;
QString version;
Type type;
auto operator==(const PluginDependency &other) const -> bool;
[[nodiscard]] auto toString() const -> QString;
};
struct EXTENSIONSYSTEM_EXPORT PluginArgumentDescription
{
QString name;
QString parameter;
QString description;
};
class EXTENSIONSYSTEM_EXPORT PluginSpec
{
public:
enum State { Invalid, Read, Resolved, Loaded, Initialized, Running, Stopped, Deleted };
~PluginSpec();
// information from the xml file, valid after 'Read' state is reached
[[nodiscard]] auto name() const -> QString;
[[nodiscard]] auto version() const -> QString;
[[nodiscard]] auto compatVersion() const -> QString;
[[nodiscard]] auto vendor() const -> QString;
[[nodiscard]] auto copyright() const -> QString;
[[nodiscard]] auto license() const -> QString;
[[nodiscard]] auto description() const -> QString;
[[nodiscard]] auto longDescription() const -> QString;
[[nodiscard]] auto url() const -> QString;
[[nodiscard]] auto category() const -> QString;
[[nodiscard]] auto revision() const -> QString;
[[nodiscard]] auto platformSpecification() const -> QRegularExpression;
[[nodiscard]] auto isAvailableForHostPlatform() const -> bool;
[[nodiscard]] auto isRequired() const -> bool;
[[nodiscard]] auto isExperimental() const -> bool;
[[nodiscard]] auto isEnabledByDefault() const -> bool;
[[nodiscard]] auto isEnabledBySettings() const -> bool;
[[nodiscard]] auto isEffectivelyEnabled() const -> bool;
[[nodiscard]] auto isEnabledIndirectly() const -> bool;
[[nodiscard]] auto isForceEnabled() const -> bool;
[[nodiscard]] auto isForceDisabled() const -> bool;
[[nodiscard]] auto dependencies() const -> QVector<PluginDependency>;
[[nodiscard]] auto metaData() const -> QJsonObject;
using PluginArgumentDescriptions = QVector<PluginArgumentDescription>;
[[nodiscard]] auto argumentDescriptions() const -> PluginArgumentDescriptions;
// other information, valid after 'Read' state is reached
[[nodiscard]] auto location() const -> QString;
[[nodiscard]] auto filePath() const -> QString;
[[nodiscard]] auto arguments() const -> QStringList;
void setArguments(const QStringList &arguments);
void addArgument(const QString &argument);
[[nodiscard]] auto provides(const QString &pluginName, const QString &version) const -> bool;
// dependency specs, valid after 'Resolved' state is reached
[[nodiscard]] auto dependencySpecs() const -> QHash<PluginDependency, PluginSpec *>;
[[nodiscard]] auto requiresAny(const QSet<PluginSpec *> &plugins) const -> bool;
// linked plugin instance, valid after 'Loaded' state is reached
[[nodiscard]] auto plugin() const -> IPlugin *;
// state
[[nodiscard]] auto state() const -> State;
[[nodiscard]] auto hasError() const -> bool;
[[nodiscard]] auto errorString() const -> QString;
void setEnabledBySettings(bool value);
static auto read(const QString &filePath) -> PluginSpec *;
static auto read(const QStaticPlugin &plugin) -> PluginSpec *;
private:
PluginSpec();
Internal::PluginSpecPrivate *d;
friend class PluginView;
friend class Internal::OptionsParser;
friend class Internal::PluginManagerPrivate;
friend class Internal::PluginSpecPrivate;
};
} // namespace ExtensionSystem