QtCanpool 3.3.0
载入中...
搜索中...
未找到
qxplugin.h
浏览该文件的文档.
1
5#ifndef QXPLUGIN_H
6#define QXPLUGIN_H
7
8#include "qxplugin_global.h"
9
10#include <QtCore/QObject>
11
13
14class QxPluginContext;
15
55class QX_PLUGIN_EXPORT QxPlugin : public QObject
56{
57 Q_OBJECT
59 friend class QxPluginManager;
60public:
61 explicit QxPlugin(QObject *parent = Q_NULLPTR);
62 ~QxPlugin() override;
63
70 virtual bool initialize(QxPluginContext *context, QString *errorString) = 0;
71
83 virtual void extensionsInitialized();
84
86 virtual void shutdown();
87
93 virtual int interfaceVersion() const;
94
96 QxPluginContext *context() const;
97protected:
100};
101
103
104// No Q_DECLARE_INTERFACE here, deliberately: QxPlugin is a QObject subclass, not
105// a pure interface, so qobject_cast falls back to the meta-object chain and works
106// at any inheritance depth. Declaring it as a Qt interface would instead route
107// qobject_cast through qt_metacast(IID), which only succeeds for a class that
108// lists Q_INTERFACES(QxPlugin) itself - and moc does not inherit that list, so
109// every plugin written the documented way would load but never cast. What ties
110// a plugin to this library is the IID in its Q_PLUGIN_METADATA, which is what
111// QPluginLoader and the manager check.
112
113#endif // QXPLUGIN_H
The thin surface a plugin programs against.
Discovers, orders, loads and isolates QtCanpool plugins.
virtual bool initialize(QxPluginContext *context, QString *errorString)=0
Called after every required dependency has been initialized.
Copyright (C) 2026 maminjie canpool@163.com SPDX-License-Identifier: MulanPSL-2.0
#define Q_NULLPTR
Copyleft (C) 2025 maminjie canpool@163.com SPDX-License-Identifier: MulanPSL-2.0
#define QX_PLUGIN_BEGIN_NAMESPACE
#define QX_PLUGIN_END_NAMESPACE
#define QX_PLUGIN_EXPORT