1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef EVENTHANDLER_H |
6 | #define EVENTHANDLER_H |
7 | |
8 | #include "framework/event/event.h" |
9 | #include "framework/log/frameworklog.h" |
10 | #include "framework/log/codetimecheck.h" |
11 | #include "framework/framework_global.h" |
12 | |
13 | #include <QObject> |
14 | #include <QtConcurrent> |
15 | |
16 | DPF_BEGIN_NAMESPACE |
17 | |
18 | class Event; |
19 | class EventHandler : public QObject |
20 | { |
21 | Q_OBJECT |
22 | Q_DISABLE_COPY(EventHandler) |
23 | |
24 | public: |
25 | /*! |
26 | * \brief You should derived the class, and |
27 | * write a static function named type that returns `Type` and `topics` |
28 | * |
29 | * // for example: |
30 | * static Type type() |
31 | * { |
32 | * return EventHandler::Sync; |
33 | * } |
34 | * |
35 | * static QStringList topics() |
36 | * { |
37 | * return QStringList() << "TEST_TOPIC"; |
38 | * } |
39 | * |
40 | */ |
41 | enum class Type : uint8_t |
42 | { |
43 | Sync, |
44 | Async |
45 | }; |
46 | |
47 | explicit EventHandler(QObject *parent = nullptr); |
48 | virtual ~EventHandler() {} |
49 | |
50 | /*! |
51 | * \brief eventProcess 事件处理入口 |
52 | */ |
53 | virtual void eventProcess(const Event&) = 0; |
54 | |
55 | // TODO: |
56 | Q_SIGNALS: |
57 | void handError(const QString &error); |
58 | void handInfo(const QString &info); |
59 | }; |
60 | |
61 | DPF_END_NAMESPACE |
62 | |
63 | #endif // EVENTHANDLER_H |
64 |