1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef PLUGIN_H
6#define PLUGIN_H
7
8#include "framework/framework_global.h"
9#include "framework/service/pluginservice.h"
10
11#include <QObject>
12#include <QSharedData>
13
14DPF_BEGIN_NAMESPACE
15
16
17class PluginContext;
18
19/**
20 * @brief The Plugin class
21 * 插件接口类,用于实现插件,使用方式如下
22 * @code
23 * class Core : public Plugin
24 * {
25 * Q_OBJECT
26 * Q_PLUGIN_METADATA(IID PLUGIN_INTERFACE FILE "core.json")
27 * public:
28 * virtual void initialized() override;
29 * virtual bool start() override;
30 * virtual PluginMetaObject::ShutDownFlag stop() override;
31 * };
32 * @endcode
33 * Q_PLUGIN_METADATA 可参阅Qt宏定义
34 * PLUGIN_INTERFACE
35 */
36class Plugin : public QObject
37{
38 Q_OBJECT
39public:
40 enum ShutdownFlag {
41 Sync, /// 同步释放标识
42 Async, /// 异步释放标识
43 };
44
45 explicit Plugin();
46 virtual ~Plugin() override;
47 virtual void initialize();
48
49 /**
50 * @brief start
51 * @return bool 如果返回true则表示当前插件start函数执行正常
52 * false则代表当前内部执行存在问题
53 */
54 virtual bool start() = 0;
55 virtual ShutdownFlag stop();
56
57signals:
58
59 /**
60 * @brief asyncStopFinished 异步释放完成的信号
61 */
62 void asyncStopFinished();
63};
64
65DPF_END_NAMESPACE
66
67#endif // PLUGIN_H
68