1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef TOOLS_H |
6 | #define TOOLS_H |
7 | |
8 | #include <QProcess> |
9 | |
10 | #include <json/json.h> |
11 | |
12 | class ToolsPrivate; |
13 | class Tools : public QObject |
14 | { |
15 | Q_OBJECT |
16 | ToolsPrivate *const d; |
17 | public: |
18 | enum PerformanceType |
19 | { |
20 | function, |
21 | global, |
22 | vfs, |
23 | socket, |
24 | deviceIO, |
25 | networkIO, |
26 | checkMemory, |
27 | }; |
28 | Q_ENUM(PerformanceType) |
29 | |
30 | Tools(); |
31 | virtual ~Tools(); |
32 | Q_INVOKABLE Json::Value data() const; |
33 | |
34 | public slots: |
35 | void startAll(); |
36 | void stopAll(); |
37 | void setAttachPID(int pid); |
38 | int attachPID() const; |
39 | |
40 | protected: |
41 | virtual bool initTool(PerformanceType pt); |
42 | virtual QRegularExpression lineRegExpRule(PerformanceType pt); |
43 | |
44 | signals: |
45 | void attachData(const Json::Value &); |
46 | |
47 | private slots: |
48 | void readAllStandardOutput(); |
49 | void readAllStandardError(); |
50 | void errorOccurred(QProcess::ProcessError error); |
51 | }; |
52 | |
53 | |
54 | #endif // TOOLS_H |
55 | |