1 | /* $Id: UIMonitorCommon.h 103803 2024-03-12 11:15:18Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox Qt GUI - UIMonitorCommon class declaration.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2016-2023 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef FEQT_INCLUDED_SRC_activity_UIMonitorCommon_h
|
---|
29 | #define FEQT_INCLUDED_SRC_activity_UIMonitorCommon_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <QPainterPath>
|
---|
35 | #include "UIProgressTask.h"
|
---|
36 | #include "CStringArray.h"
|
---|
37 | #include "CCloudMachine.h"
|
---|
38 |
|
---|
39 | class SHARED_LIBRARY_STUFF UIProgressTaskReadCloudMachineMetricList : public UIProgressTask
|
---|
40 | {
|
---|
41 | Q_OBJECT;
|
---|
42 |
|
---|
43 | signals:
|
---|
44 |
|
---|
45 | void sigMetricListReceived(QVector<QString> metricNamesList);
|
---|
46 |
|
---|
47 | public:
|
---|
48 |
|
---|
49 | UIProgressTaskReadCloudMachineMetricList(QObject *pParent, CCloudMachine comCloudMachine);
|
---|
50 |
|
---|
51 | protected:
|
---|
52 |
|
---|
53 | virtual CProgress createProgress() RT_OVERRIDE;
|
---|
54 | virtual void handleProgressFinished(CProgress &comProgress) RT_OVERRIDE;
|
---|
55 |
|
---|
56 | private:
|
---|
57 |
|
---|
58 | CCloudMachine m_comCloudMachine;
|
---|
59 | CStringArray m_metricNamesArray;
|
---|
60 | };
|
---|
61 |
|
---|
62 |
|
---|
63 | class SHARED_LIBRARY_STUFF UIProgressTaskReadCloudMachineMetricData : public UIProgressTask
|
---|
64 | {
|
---|
65 | Q_OBJECT;
|
---|
66 |
|
---|
67 | signals:
|
---|
68 |
|
---|
69 | void sigMetricDataReceived(KMetricType enmMetricType, QVector<QString> data, QVector<QString> timeStamps);
|
---|
70 |
|
---|
71 | public:
|
---|
72 |
|
---|
73 | UIProgressTaskReadCloudMachineMetricData(QObject *pParent, CCloudMachine comCloudMachine,
|
---|
74 | KMetricType enmMetricType, ULONG uDataPointsCount);
|
---|
75 |
|
---|
76 | protected:
|
---|
77 |
|
---|
78 | virtual CProgress createProgress() RT_OVERRIDE;
|
---|
79 | virtual void handleProgressFinished(CProgress &comProgress) RT_OVERRIDE;
|
---|
80 |
|
---|
81 | private:
|
---|
82 |
|
---|
83 | CCloudMachine m_comCloudMachine;
|
---|
84 | CStringArray m_metricData;
|
---|
85 | CStringArray m_timeStamps;
|
---|
86 | KMetricType m_enmMetricType;
|
---|
87 | ULONG m_uDataPointsCount;
|
---|
88 | };
|
---|
89 |
|
---|
90 |
|
---|
91 | /** UIDebuggerMetricData is used as data storage while parsing the xml stream received from IMachineDebugger. */
|
---|
92 | struct UIDebuggerMetricData
|
---|
93 | {
|
---|
94 | UIDebuggerMetricData()
|
---|
95 | : m_counter(0){}
|
---|
96 | UIDebuggerMetricData(const QString &strName, quint64 counter)
|
---|
97 | : m_strName(strName)
|
---|
98 | , m_counter(counter){}
|
---|
99 | QString m_strName;
|
---|
100 | quint64 m_counter;
|
---|
101 | };
|
---|
102 |
|
---|
103 |
|
---|
104 | class SHARED_LIBRARY_STUFF UIMonitorCommon
|
---|
105 | {
|
---|
106 |
|
---|
107 | public:
|
---|
108 |
|
---|
109 | /** @name Static utility methods that query and parse IMachineDebugger outputs for specific metrix types.
|
---|
110 | * @{ */
|
---|
111 | static void getNetworkLoad(CMachineDebugger &debugger, quint64 &uOutNetworkReceived, quint64 &uOutNetworkTransmitted);
|
---|
112 | static void getDiskLoad(CMachineDebugger &debugger, quint64 &uOutDiskWritten, quint64 &uOutDiskRead);
|
---|
113 | static void getVMMExitCount(CMachineDebugger &debugger, quint64 &uOutVMMExitCount);
|
---|
114 | /** @} */
|
---|
115 | static void getRAMLoad(CPerformanceCollector &comPerformanceCollector, QVector<QString> &nameList,
|
---|
116 | QVector<CUnknown>& objectList, quint64 &iOutTotalRAM, quint64 &iOutFreeRAM);
|
---|
117 |
|
---|
118 |
|
---|
119 | static QPainterPath doughnutSlice(const QRectF &outerRectangle, const QRectF &innerRectangle, float fStartAngle, float fSweepAngle);
|
---|
120 | static QPainterPath wholeArc(const QRectF &rectangle);
|
---|
121 | static void drawCombinedDoughnutChart(quint64 data1, const QColor &data1Color,
|
---|
122 | quint64 data2, const QColor &data2Color,
|
---|
123 | QPainter &painter, quint64 iMaximum,
|
---|
124 | const QRectF &chartRect, const QRectF &innerRect, int iOverlayAlpha);
|
---|
125 |
|
---|
126 | /* Returns a rectangle which is co-centric with @p outerFrame and scaled by @p fScaleX and fScaleY. */
|
---|
127 | static QRectF getScaledRect(const QRectF &outerFrame, float fScaleX, float fScaleY);
|
---|
128 |
|
---|
129 | static void drawDoughnutChart(QPainter &painter, quint64 iMaximum, quint64 data,
|
---|
130 | const QRectF &chartRect, const QRectF &innerRect, int iOverlayAlpha, const QColor &color);
|
---|
131 |
|
---|
132 | static quint64 determineTotalRAMAmount(CCloudMachine &comCloudMachine);
|
---|
133 |
|
---|
134 | private:
|
---|
135 |
|
---|
136 | /** Parses the xml string we get from the IMachineDebugger and returns an array of UIDebuggerMetricData. */
|
---|
137 | static QVector<UIDebuggerMetricData> getAndParseStatsFromDebugger(CMachineDebugger &debugger, const QString &strQuery);
|
---|
138 |
|
---|
139 | };
|
---|
140 |
|
---|
141 | #endif /* !FEQT_INCLUDED_SRC_activity_UIMonitorCommon_h */
|
---|