VirtualBox

source: vbox/trunk/src/VBox/Main/BIOSSettingsImpl.cpp@ 4044

Last change on this file since 4044 was 3302, checked in by vboxsync, 17 years ago

Main: More Machine children use the AutoStateDependency template.

  • Property svn:eol-style set to native
File size: 10.0 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek GmbH
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22#include "BIOSSettingsImpl.h"
23#include "MachineImpl.h"
24#include "Logging.h"
25#include <iprt/cpputils.h>
26
27// constructor / destructor
28/////////////////////////////////////////////////////////////////////////////
29
30HRESULT BIOSSettings::FinalConstruct()
31{
32 return S_OK;
33}
34
35void BIOSSettings::FinalRelease()
36{
37 uninit ();
38}
39
40// public initializer/uninitializer for internal purposes only
41/////////////////////////////////////////////////////////////////////////////
42
43/**
44 * Initializes the audio adapter object.
45 *
46 * @returns COM result indicator
47 */
48HRESULT BIOSSettings::init (Machine *aParent)
49{
50 LogFlowThisFuncEnter();
51 LogFlowThisFunc (("aParent: %p\n", aParent));
52
53 ComAssertRet (aParent, E_INVALIDARG);
54
55 /* Enclose the state transition NotReady->InInit->Ready */
56 AutoInitSpan autoInitSpan (this);
57 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
58
59 /* share the parent weakly */
60 unconst (mParent) = aParent;
61
62 mData.allocate();
63
64 autoInitSpan.setSucceeded();
65
66 LogFlowThisFuncLeave();
67 return S_OK;
68}
69
70/**
71 * Initializes the audio adapter object given another audio adapter object
72 * (a kind of copy constructor). This object shares data with
73 * the object passed as an argument.
74 *
75 * @note This object must be destroyed before the original object
76 * it shares data with is destroyed.
77 */
78HRESULT BIOSSettings::init (Machine *aParent, BIOSSettings *that)
79{
80 LogFlowThisFuncEnter();
81 LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
82
83 ComAssertRet (aParent && that, E_INVALIDARG);
84
85 /* Enclose the state transition NotReady->InInit->Ready */
86 AutoInitSpan autoInitSpan (this);
87 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
88
89 mParent = aParent;
90 mPeer = that;
91
92 AutoLock thatlock (that);
93 mData.share (that->mData);
94
95 autoInitSpan.setSucceeded();
96
97 LogFlowThisFuncLeave();
98 return S_OK;
99}
100
101/**
102 * Initializes the guest object given another guest object
103 * (a kind of copy constructor). This object makes a private copy of data
104 * of the original object passed as an argument.
105 */
106HRESULT BIOSSettings::initCopy (Machine *aParent, BIOSSettings *that)
107{
108 LogFlowThisFuncEnter();
109 LogFlowThisFunc (("aParent: %p, that: %p\n", aParent, that));
110
111 ComAssertRet (aParent && that, E_INVALIDARG);
112
113 /* Enclose the state transition NotReady->InInit->Ready */
114 AutoInitSpan autoInitSpan (this);
115 AssertReturn (autoInitSpan.isOk(), E_UNEXPECTED);
116
117 mParent = aParent;
118 // mPeer is left null
119
120 AutoLock thatlock (that);
121 mData.attachCopy (that->mData);
122
123 autoInitSpan.setSucceeded();
124
125 LogFlowThisFuncLeave();
126 return S_OK;
127}
128
129/**
130 * Uninitializes the instance and sets the ready flag to FALSE.
131 * Called either from FinalRelease() or by the parent when it gets destroyed.
132 */
133void BIOSSettings::uninit()
134{
135 LogFlowThisFuncEnter();
136
137 /* Enclose the state transition Ready->InUninit->NotReady */
138 AutoUninitSpan autoUninitSpan (this);
139 if (autoUninitSpan.uninitDone())
140 return;
141
142 mData.free();
143
144 mPeer.setNull();
145 mParent.setNull();
146
147 LogFlowThisFuncLeave();
148}
149
150// IBIOSSettings properties
151/////////////////////////////////////////////////////////////////////////////
152
153STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeIn)(BOOL *enabled)
154{
155 if (!enabled)
156 return E_POINTER;
157
158 AutoCaller autoCaller (this);
159 CheckComRCReturnRC (autoCaller.rc());
160
161 AutoReaderLock alock (this);
162
163 *enabled = mData->mLogoFadeIn;
164
165 return S_OK;
166}
167
168STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeIn)(BOOL enable)
169{
170 AutoCaller autoCaller (this);
171 CheckComRCReturnRC (autoCaller.rc());
172
173 /* the machine needs to be mutable */
174 Machine::AutoMutableStateDependency adep (mParent);
175 CheckComRCReturnRC (adep.rc());
176
177 AutoLock alock (this);
178
179 mData.backup();
180 mData->mLogoFadeIn = enable;
181
182 return S_OK;
183}
184
185STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
186{
187 if (!enabled)
188 return E_POINTER;
189
190 AutoCaller autoCaller (this);
191 CheckComRCReturnRC (autoCaller.rc());
192
193 AutoReaderLock alock (this);
194
195 *enabled = mData->mLogoFadeOut;
196
197 return S_OK;
198}
199
200STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
201{
202 AutoCaller autoCaller (this);
203 CheckComRCReturnRC (autoCaller.rc());
204
205 /* the machine needs to be mutable */
206 Machine::AutoMutableStateDependency adep (mParent);
207 CheckComRCReturnRC (adep.rc());
208
209 AutoLock alock (this);
210
211 mData.backup();
212 mData->mLogoFadeOut = enable;
213
214 return S_OK;
215}
216
217STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
218{
219 if (!displayTime)
220 return E_POINTER;
221
222 AutoCaller autoCaller (this);
223 CheckComRCReturnRC (autoCaller.rc());
224
225 AutoReaderLock alock (this);
226
227 *displayTime = mData->mLogoDisplayTime;
228
229 return S_OK;
230}
231
232STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
233{
234 AutoCaller autoCaller (this);
235 CheckComRCReturnRC (autoCaller.rc());
236
237 /* the machine needs to be mutable */
238 Machine::AutoMutableStateDependency adep (mParent);
239 CheckComRCReturnRC (adep.rc());
240
241 AutoLock alock (this);
242
243 mData.backup();
244 mData->mLogoDisplayTime = displayTime;
245
246 return S_OK;
247}
248
249STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
250{
251 if (!imagePath)
252 return E_POINTER;
253
254 AutoCaller autoCaller (this);
255 CheckComRCReturnRC (autoCaller.rc());
256
257 AutoReaderLock alock (this);
258
259 mData->mLogoImagePath.cloneTo(imagePath);
260 return S_OK;
261}
262
263STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(INPTR BSTR imagePath)
264{
265 /* empty strings are not allowed as path names */
266 if (imagePath && !(*imagePath))
267 return E_INVALIDARG;
268
269 AutoCaller autoCaller (this);
270 CheckComRCReturnRC (autoCaller.rc());
271
272 /* the machine needs to be mutable */
273 Machine::AutoMutableStateDependency adep (mParent);
274 CheckComRCReturnRC (adep.rc());
275
276 AutoLock alock (this);
277
278 mData.backup();
279 mData->mLogoImagePath = imagePath;
280
281 return S_OK;
282}
283
284STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
285{
286 if (!bootMenuMode)
287 return E_POINTER;
288
289 AutoCaller autoCaller (this);
290 CheckComRCReturnRC (autoCaller.rc());
291
292 AutoReaderLock alock (this);
293
294 *bootMenuMode = mData->mBootMenuMode;
295 return S_OK;
296}
297
298STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
299{
300 AutoCaller autoCaller (this);
301 CheckComRCReturnRC (autoCaller.rc());
302
303 /* the machine needs to be mutable */
304 Machine::AutoMutableStateDependency adep (mParent);
305 CheckComRCReturnRC (adep.rc());
306
307 AutoLock alock (this);
308
309 mData.backup();
310 mData->mBootMenuMode = bootMenuMode;
311
312 return S_OK;
313}
314
315STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
316{
317 if (!enabled)
318 return E_POINTER;
319
320 AutoCaller autoCaller (this);
321 CheckComRCReturnRC (autoCaller.rc());
322
323 AutoReaderLock alock (this);
324
325 *enabled = mData->mACPIEnabled;
326
327 return S_OK;
328}
329
330STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
331{
332 AutoCaller autoCaller (this);
333 CheckComRCReturnRC (autoCaller.rc());
334
335 /* the machine needs to be mutable */
336 Machine::AutoMutableStateDependency adep (mParent);
337 CheckComRCReturnRC (adep.rc());
338
339 AutoLock alock (this);
340
341 mData.backup();
342 mData->mACPIEnabled = enable;
343
344 return S_OK;
345}
346
347STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
348{
349 if (!enabled)
350 return E_POINTER;
351
352 AutoCaller autoCaller (this);
353 CheckComRCReturnRC (autoCaller.rc());
354
355 AutoReaderLock alock (this);
356
357 *enabled = mData->mIOAPICEnabled;
358
359 return S_OK;
360}
361
362STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
363{
364 AutoCaller autoCaller (this);
365 CheckComRCReturnRC (autoCaller.rc());
366
367 /* the machine needs to be mutable */
368 Machine::AutoMutableStateDependency adep (mParent);
369 CheckComRCReturnRC (adep.rc());
370
371 AutoLock alock (this);
372
373 mData.backup();
374 mData->mIOAPICEnabled = enable;
375
376 return S_OK;
377}
378
379STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
380{
381 if (!offset)
382 return E_POINTER;
383
384 AutoCaller autoCaller (this);
385 CheckComRCReturnRC (autoCaller.rc());
386
387 AutoReaderLock alock (this);
388
389 *offset = mData->mTimeOffset;
390
391 return S_OK;
392}
393
394STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
395{
396 AutoCaller autoCaller (this);
397 CheckComRCReturnRC (autoCaller.rc());
398
399 /* the machine needs to be mutable */
400 Machine::AutoMutableStateDependency adep (mParent);
401 CheckComRCReturnRC (adep.rc());
402
403 AutoLock alock (this);
404
405 mData.backup();
406 mData->mTimeOffset = offset;
407
408 return S_OK;
409}
410
411
412// IBIOSSettings methods
413/////////////////////////////////////////////////////////////////////////////
414
415// public methods only for internal purposes
416/////////////////////////////////////////////////////////////////////////////
417
418void BIOSSettings::commit()
419{
420 AutoLock alock (this);
421 if (mData.isBackedUp())
422 {
423 mData.commit();
424 if (mPeer)
425 {
426 // attach new data to the peer and reshare it
427 AutoLock peerlock (mPeer);
428 mPeer->mData.attach (mData);
429 }
430 }
431}
432
433void BIOSSettings::copyFrom (BIOSSettings *aThat)
434{
435 AutoLock alock (this);
436
437 // this will back up current data
438 mData.assignCopy (aThat->mData);
439}
440
Note: See TracBrowser for help on using the repository browser.

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