VirtualBox

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

Last change on this file since 11497 was 11321, checked in by vboxsync, 17 years ago

Main: removied iprt/system.h reference.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.4 KB
Line 
1/* $Id: PerformanceImpl.h 11321 2008-08-11 10:12:28Z 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/* Each second we obtain new CPU load stats. */
41#define VBOX_USAGE_SAMPLER_MIN_INTERVAL 1000
42
43class Machine;
44class HostUSBDevice;
45
46class ATL_NO_VTABLE PerformanceMetric :
47 public VirtualBoxBaseNEXT,
48 public VirtualBoxSupportTranslation <PerformanceMetric>,
49 public IPerformanceMetric
50{
51public:
52
53 DECLARE_NOT_AGGREGATABLE (PerformanceMetric)
54
55 DECLARE_PROTECT_FINAL_CONSTRUCT()
56
57 BEGIN_COM_MAP (PerformanceMetric)
58 COM_INTERFACE_ENTRY (IPerformanceMetric)
59 END_COM_MAP()
60
61 NS_DECL_ISUPPORTS
62
63 DECLARE_EMPTY_CTOR_DTOR (PerformanceMetric)
64
65 HRESULT FinalConstruct();
66 void FinalRelease();
67
68 // public initializer/uninitializer for internal purposes only
69 HRESULT init (pm::Metric *aMetric);
70 void uninit();
71
72 // IPerformanceMetric properties
73 STDMETHOD(COMGETTER(MetricName)) (BSTR *aMetricName);
74 STDMETHOD(COMGETTER(Object)) (IUnknown **anObject);
75 STDMETHOD(COMGETTER(Period)) (ULONG *aPeriod);
76 STDMETHOD(COMGETTER(Count)) (ULONG *aCount);
77 STDMETHOD(COMGETTER(Unit)) (BSTR *aUnit);
78 STDMETHOD(COMGETTER(MinimumValue)) (LONG *aMinValue);
79 STDMETHOD(COMGETTER(MaximumValue)) (LONG *aMaxValue);
80
81 // IPerformanceMetric methods
82
83 // public methods only for internal purposes
84
85 // public methods for internal purposes only
86 // (ensure there is a caller and a read lock before calling them!)
87
88private:
89
90 struct Data
91 {
92 /* Constructor. */
93 Data() : period(0), count(0), min(0), max(0) { }
94
95 Bstr name;
96 ComPtr<IUnknown> object;
97 ULONG period;
98 ULONG count;
99 Bstr unit;
100 LONG min;
101 LONG max;
102 };
103
104 Data m;
105};
106
107
108#if 0
109class ATL_NO_VTABLE PerformanceData :
110 public VirtualBoxBaseNEXT,
111 public VirtualBoxSupportTranslation <PerformanceData>,
112 public IPerformanceData
113{
114private:
115
116 struct Data
117 {
118 /* Constructor. */
119 Data() { }
120
121 bool operator== (const Data &that) const
122 {
123 return this == &that;
124 }
125 };
126
127public:
128
129 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (PerformanceData)
130
131 DECLARE_NOT_AGGREGATABLE (PerformanceData)
132
133 DECLARE_PROTECT_FINAL_CONSTRUCT()
134
135 BEGIN_COM_MAP(PerformanceData)
136 COM_INTERFACE_ENTRY (ISupportErrorInfo)
137 COM_INTERFACE_ENTRY (IPerformanceData)
138 END_COM_MAP()
139
140 NS_DECL_ISUPPORTS
141
142 DECLARE_EMPTY_CTOR_DTOR (PerformanceData)
143
144 HRESULT FinalConstruct();
145 void FinalRelease();
146
147 // public initializer/uninitializer for internal purposes only
148 HRESULT init (cosnt BSTR aMetricName, IUnknown *anObject,
149 ULONG *data, ULONG aLength);
150 void uninit();
151
152 // IPerformanceData properties
153 STDMETHOD(COMGETTER(MetricName)) (BSTR *aMetricName);
154 STDMETHOD(COMGETTER(Object)) (IUnknown **anObject);
155 STDMETHOD(COMGETTER(Values)) (ComSafeArrayOut (LONG, values));
156
157 // IPerformanceData methods
158
159 // public methods only for internal purposes
160
161private:
162
163 Bstr mMetricName;
164 IUnknown *mObject;
165 ULONG *mData;
166 ULONG mLength;
167};
168#endif
169
170class ATL_NO_VTABLE PerformanceCollector :
171 public VirtualBoxBaseNEXT,
172 public VirtualBoxSupportErrorInfoImpl <PerformanceCollector, IPerformanceCollector>,
173 public VirtualBoxSupportTranslation <PerformanceCollector>,
174 public IPerformanceCollector
175{
176public:
177
178 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (PerformanceCollector)
179
180 DECLARE_NOT_AGGREGATABLE (PerformanceCollector)
181
182 DECLARE_PROTECT_FINAL_CONSTRUCT()
183
184 BEGIN_COM_MAP(PerformanceCollector)
185 COM_INTERFACE_ENTRY(ISupportErrorInfo)
186 COM_INTERFACE_ENTRY(IPerformanceCollector)
187 END_COM_MAP()
188
189 NS_DECL_ISUPPORTS
190
191 DECLARE_EMPTY_CTOR_DTOR (PerformanceCollector)
192
193 HRESULT FinalConstruct();
194 void FinalRelease();
195
196 // public initializers/uninitializers only for internal purposes
197 HRESULT init();
198 void uninit();
199
200 // IPerformanceCollector properties
201 STDMETHOD(COMGETTER(MetricNames)) (ComSafeArrayOut (BSTR, metricNames));
202
203 // IPerformanceCollector methods
204 STDMETHOD(GetMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
205 ComSafeArrayIn (IUnknown *, objects),
206 ComSafeArrayOut (IPerformanceMetric *, outMetrics));
207 STDMETHOD(SetupMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
208 ComSafeArrayIn (IUnknown *, objects),
209 ULONG aPeriod, ULONG aCount);
210 STDMETHOD(EnableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
211 ComSafeArrayIn (IUnknown *, objects));
212 STDMETHOD(DisableMetrics) (ComSafeArrayIn (INPTR BSTR, metricNames),
213 ComSafeArrayIn (IUnknown *, objects));
214 STDMETHOD(QueryMetricsData) (ComSafeArrayIn (INPTR BSTR, metricNames),
215 ComSafeArrayIn (IUnknown *, objects),
216 ComSafeArrayOut (BSTR, outMetricNames),
217 ComSafeArrayOut (IUnknown *, outObjects),
218 ComSafeArrayOut (ULONG, outDataIndices),
219 ComSafeArrayOut (ULONG, outDataLengths),
220 ComSafeArrayOut (LONG, outData));
221
222 // public methods only for internal purposes
223
224 void registerBaseMetric (pm::BaseMetric *baseMetric);
225 void registerMetric (pm::Metric *metric);
226 void unregisterBaseMetricsFor (const ComPtr <IUnknown> &object);
227 void unregisterMetricsFor (const ComPtr <IUnknown> &object);
228
229 // public methods for internal purposes only
230 // (ensure there is a caller and a read lock before calling them!)
231
232 pm::MetricFactory *getMetricFactory() { return m.factory; };
233
234 // for VirtualBoxSupportErrorInfoImpl
235 static const wchar_t *getComponentName() { return L"PerformanceCollector"; }
236
237private:
238
239 static void staticSamplerCallback (RTTIMERLR hTimerLR, void *pvUser, uint64_t iTick);
240 void samplerCallback();
241
242 typedef std::list<pm::Metric*> MetricList;
243 typedef std::list<pm::BaseMetric*> BaseMetricList;
244
245 enum
246 {
247 MAGIC = 0xABBA1972u
248 };
249
250 unsigned int mMagic;
251
252 struct Data
253 {
254 Data() : factory(0) {};
255
256 BaseMetricList baseMetrics;
257 MetricList metrics;
258 RTTIMERLR sampler;
259 pm::MetricFactory *factory;
260 };
261
262 Data m;
263};
264
265#endif //!____H_PERFORMANCEIMPL
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette