VirtualBox

source: vbox/trunk/src/VBox/Main/include/PerformanceImpl.h@ 16560

Last change on this file since 16560 was 16560, checked in by vboxsync, 15 years ago

Main: do not include include/VBox/settings.h from other header files but only from implementations that need it (save compile time)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 KB
Line 
1/* $Id: PerformanceImpl.h 16560 2009-02-06 18:06:04Z vboxsync $ */
2
3/** @file
4 *
5 * VBox Performance COM Classes declaration.
6 */
7
8/*
9 * Copyright (C) 2008 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_PERFORMANCEIMPL
25#define ____H_PERFORMANCEIMPL
26
27#include "VirtualBoxBase.h"
28
29#include <VBox/com/com.h>
30#include <VBox/com/array.h>
31//#ifdef VBOX_WITH_RESOURCE_USAGE_API
32#include <iprt/timer.h>
33//#endif /* VBOX_WITH_RESOURCE_USAGE_API */
34
35#include <list>
36//#include <set>
37
38#include "Performance.h"
39
40#undef min
41#undef max
42
43/* Each second we obtain new CPU load stats. */
44#define VBOX_USAGE_SAMPLER_MIN_INTERVAL 1000
45
46class Machine;
47class HostUSBDevice;
48
49class ATL_NO_VTABLE PerformanceMetric :
50 public VirtualBoxBaseNEXT,
51 public VirtualBoxSupportTranslation <PerformanceMetric>,
52 public IPerformanceMetric
53{
54public:
55
56 DECLARE_NOT_AGGREGATABLE (PerformanceMetric)
57
58 DECLARE_PROTECT_FINAL_CONSTRUCT()
59
60 BEGIN_COM_MAP (PerformanceMetric)
61 COM_INTERFACE_ENTRY (IPerformanceMetric)
62 END_COM_MAP()
63
64 NS_DECL_ISUPPORTS
65
66 DECLARE_EMPTY_CTOR_DTOR (PerformanceMetric)
67
68 HRESULT FinalConstruct();
69 void FinalRelease();
70
71 // public initializer/uninitializer for internal purposes only
72 HRESULT init (pm::Metric *aMetric);
73 HRESULT init (pm::BaseMetric *aMetric);
74 void uninit();
75
76 // IPerformanceMetric properties
77 STDMETHOD(COMGETTER(MetricName)) (BSTR *aMetricName);
78 STDMETHOD(COMGETTER(Object)) (IUnknown **anObject);
79 STDMETHOD(COMGETTER(Description)) (BSTR *aDescription);
80 STDMETHOD(COMGETTER(Period)) (ULONG *aPeriod);
81 STDMETHOD(COMGETTER(Count)) (ULONG *aCount);
82 STDMETHOD(COMGETTER(Unit)) (BSTR *aUnit);
83 STDMETHOD(COMGETTER(MinimumValue)) (LONG *aMinValue);
84 STDMETHOD(COMGETTER(MaximumValue)) (LONG *aMaxValue);
85
86 // IPerformanceMetric methods
87
88 // public methods only for internal purposes
89
90 // public methods for internal purposes only
91 // (ensure there is a caller and a read lock before calling them!)
92
93private:
94
95 struct Data
96 {
97 /* Constructor. */
98 Data()
99 : period(0), count(0), min(0), max(0)
100 {
101 }
102
103 Bstr name;
104 ComPtr<IUnknown> object;
105 Bstr description;
106 ULONG period;
107 ULONG count;
108 Bstr unit;
109 LONG min;
110 LONG max;
111 };
112
113 Data m;
114};
115
116
117class ATL_NO_VTABLE PerformanceCollector :
118 public VirtualBoxBaseNEXT,
119 public VirtualBoxSupportErrorInfoImpl <PerformanceCollector, IPerformanceCollector>,
120 public VirtualBoxSupportTranslation <PerformanceCollector>,
121 public IPerformanceCollector
122{
123public:
124
125 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (PerformanceCollector)
126
127 DECLARE_NOT_AGGREGATABLE (PerformanceCollector)
128
129 DECLARE_PROTECT_FINAL_CONSTRUCT()
130
131 BEGIN_COM_MAP(PerformanceCollector)
132 COM_INTERFACE_ENTRY(ISupportErrorInfo)
133 COM_INTERFACE_ENTRY(IPerformanceCollector)
134 END_COM_MAP()
135
136 NS_DECL_ISUPPORTS
137
138 DECLARE_EMPTY_CTOR_DTOR (PerformanceCollector)
139
140 HRESULT FinalConstruct();
141 void FinalRelease();
142
143 // public initializers/uninitializers only for internal purposes
144 HRESULT init();
145 void uninit();
146
147 // IPerformanceCollector properties
148 STDMETHOD(COMGETTER(MetricNames)) (ComSafeArrayOut (BSTR, metricNames));
149
150 // IPerformanceCollector methods
151 STDMETHOD(GetMetrics) (ComSafeArrayIn (IN_BSTR, metricNames),
152 ComSafeArrayIn (IUnknown *, objects),
153 ComSafeArrayOut (IPerformanceMetric *, outMetrics));
154 STDMETHOD(SetupMetrics) (ComSafeArrayIn (IN_BSTR, metricNames),
155 ComSafeArrayIn (IUnknown *, objects),
156 ULONG aPeriod, ULONG aCount,
157 ComSafeArrayOut (IPerformanceMetric *,
158 outMetrics));
159 STDMETHOD(EnableMetrics) (ComSafeArrayIn (IN_BSTR, metricNames),
160 ComSafeArrayIn (IUnknown *, objects),
161 ComSafeArrayOut (IPerformanceMetric *,
162 outMetrics));
163 STDMETHOD(DisableMetrics) (ComSafeArrayIn (IN_BSTR, metricNames),
164 ComSafeArrayIn (IUnknown *, objects),
165 ComSafeArrayOut (IPerformanceMetric *,
166 outMetrics));
167 STDMETHOD(QueryMetricsData) (ComSafeArrayIn (IN_BSTR, metricNames),
168 ComSafeArrayIn (IUnknown *, objects),
169 ComSafeArrayOut (BSTR, outMetricNames),
170 ComSafeArrayOut (IUnknown *, outObjects),
171 ComSafeArrayOut (BSTR, outUnits),
172 ComSafeArrayOut (ULONG, outScales),
173 ComSafeArrayOut (ULONG, outSequenceNumbers),
174 ComSafeArrayOut (ULONG, outDataIndices),
175 ComSafeArrayOut (ULONG, outDataLengths),
176 ComSafeArrayOut (LONG, outData));
177
178 // public methods only for internal purposes
179
180 void registerBaseMetric (pm::BaseMetric *baseMetric);
181 void registerMetric (pm::Metric *metric);
182 void unregisterBaseMetricsFor (const ComPtr <IUnknown> &object);
183 void unregisterMetricsFor (const ComPtr <IUnknown> &object);
184
185 // public methods for internal purposes only
186 // (ensure there is a caller and a read lock before calling them!)
187
188 pm::CollectorHAL *getHAL() { return m.hal; };
189
190 // for VirtualBoxSupportErrorInfoImpl
191 static const wchar_t *getComponentName() { return L"PerformanceCollector"; }
192
193private:
194 HRESULT toIPerformanceMetric(pm::Metric *src, IPerformanceMetric **dst);
195 HRESULT toIPerformanceMetric(pm::BaseMetric *src, IPerformanceMetric **dst);
196
197 static void staticSamplerCallback (RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
198 void samplerCallback();
199
200 typedef std::list<pm::Metric*> MetricList;
201 typedef std::list<pm::BaseMetric*> BaseMetricList;
202
203 enum
204 {
205 MAGIC = 0xABBA1972u
206 };
207
208 unsigned int mMagic;
209
210 struct Data
211 {
212 Data() : hal(0) {};
213
214 BaseMetricList baseMetrics;
215 MetricList metrics;
216 RTTIMERLR sampler;
217 pm::CollectorHAL *hal;
218 };
219
220 Data m;
221};
222
223#endif //!____H_PERFORMANCEIMPL
224/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use