VirtualBox

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

Last change on this file since 3007 was 3007, checked in by vboxsync, 18 years ago

Moved the template code out of cdefs.h, partly because it didn't belong there but mostly because it was at the end of the file and would screw up any attempts made by the object cache at avoid recompiling on cdefs.h changes.

  • Property svn:eol-style set to native
File size: 9.3 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 AutoLock alock (this);
174
175 CHECK_MACHINE_MUTABILITY (mParent);
176
177 mData.backup();
178 mData->mLogoFadeIn = enable;
179
180 return S_OK;
181}
182
183STDMETHODIMP BIOSSettings::COMGETTER(LogoFadeOut)(BOOL *enabled)
184{
185 if (!enabled)
186 return E_POINTER;
187
188 AutoCaller autoCaller (this);
189 CheckComRCReturnRC (autoCaller.rc());
190
191 AutoReaderLock alock (this);
192
193 *enabled = mData->mLogoFadeOut;
194
195 return S_OK;
196}
197
198STDMETHODIMP BIOSSettings::COMSETTER(LogoFadeOut)(BOOL enable)
199{
200 AutoCaller autoCaller (this);
201 CheckComRCReturnRC (autoCaller.rc());
202
203 AutoLock alock (this);
204
205 CHECK_MACHINE_MUTABILITY (mParent);
206
207 mData.backup();
208 mData->mLogoFadeOut = enable;
209
210 return S_OK;
211}
212
213STDMETHODIMP BIOSSettings::COMGETTER(LogoDisplayTime)(ULONG *displayTime)
214{
215 if (!displayTime)
216 return E_POINTER;
217
218 AutoCaller autoCaller (this);
219 CheckComRCReturnRC (autoCaller.rc());
220
221 AutoReaderLock alock (this);
222
223 *displayTime = mData->mLogoDisplayTime;
224
225 return S_OK;
226}
227
228STDMETHODIMP BIOSSettings::COMSETTER(LogoDisplayTime)(ULONG displayTime)
229{
230 AutoCaller autoCaller (this);
231 CheckComRCReturnRC (autoCaller.rc());
232
233 AutoLock alock (this);
234
235 CHECK_MACHINE_MUTABILITY (mParent);
236
237 mData.backup();
238 mData->mLogoDisplayTime = displayTime;
239
240 return S_OK;
241}
242
243STDMETHODIMP BIOSSettings::COMGETTER(LogoImagePath)(BSTR *imagePath)
244{
245 if (!imagePath)
246 return E_POINTER;
247
248 AutoCaller autoCaller (this);
249 CheckComRCReturnRC (autoCaller.rc());
250
251 AutoReaderLock alock (this);
252
253 mData->mLogoImagePath.cloneTo(imagePath);
254 return S_OK;
255}
256
257STDMETHODIMP BIOSSettings::COMSETTER(LogoImagePath)(INPTR BSTR imagePath)
258{
259 /* empty strings are not allowed as path names */
260 if (imagePath && !(*imagePath))
261 return E_INVALIDARG;
262
263 AutoCaller autoCaller (this);
264 CheckComRCReturnRC (autoCaller.rc());
265
266 AutoLock alock (this);
267
268 CHECK_MACHINE_MUTABILITY (mParent);
269
270 mData.backup();
271 mData->mLogoImagePath = imagePath;
272
273 return S_OK;
274}
275
276STDMETHODIMP BIOSSettings::COMGETTER(BootMenuMode)(BIOSBootMenuMode_T *bootMenuMode)
277{
278 if (!bootMenuMode)
279 return E_POINTER;
280
281 AutoCaller autoCaller (this);
282 CheckComRCReturnRC (autoCaller.rc());
283
284 AutoReaderLock alock (this);
285
286 *bootMenuMode = mData->mBootMenuMode;
287 return S_OK;
288}
289
290STDMETHODIMP BIOSSettings::COMSETTER(BootMenuMode)(BIOSBootMenuMode_T bootMenuMode)
291{
292 AutoCaller autoCaller (this);
293 CheckComRCReturnRC (autoCaller.rc());
294
295 AutoLock alock (this);
296
297 CHECK_MACHINE_MUTABILITY (mParent);
298
299 mData.backup();
300 mData->mBootMenuMode = bootMenuMode;
301
302 return S_OK;
303}
304
305STDMETHODIMP BIOSSettings::COMGETTER(ACPIEnabled)(BOOL *enabled)
306{
307 if (!enabled)
308 return E_POINTER;
309
310 AutoCaller autoCaller (this);
311 CheckComRCReturnRC (autoCaller.rc());
312
313 AutoReaderLock alock (this);
314
315 *enabled = mData->mACPIEnabled;
316
317 return S_OK;
318}
319
320STDMETHODIMP BIOSSettings::COMSETTER(ACPIEnabled)(BOOL enable)
321{
322 AutoCaller autoCaller (this);
323 CheckComRCReturnRC (autoCaller.rc());
324
325 AutoLock alock (this);
326
327 CHECK_MACHINE_MUTABILITY (mParent);
328
329 mData.backup();
330 mData->mACPIEnabled = enable;
331
332 return S_OK;
333}
334
335STDMETHODIMP BIOSSettings::COMGETTER(IOAPICEnabled)(BOOL *enabled)
336{
337 if (!enabled)
338 return E_POINTER;
339
340 AutoCaller autoCaller (this);
341 CheckComRCReturnRC (autoCaller.rc());
342
343 AutoReaderLock alock (this);
344
345 *enabled = mData->mIOAPICEnabled;
346
347 return S_OK;
348}
349
350STDMETHODIMP BIOSSettings::COMSETTER(IOAPICEnabled)(BOOL enable)
351{
352 AutoCaller autoCaller (this);
353 CheckComRCReturnRC (autoCaller.rc());
354
355 AutoLock alock (this);
356
357 CHECK_MACHINE_MUTABILITY (mParent);
358
359 mData.backup();
360 mData->mIOAPICEnabled = enable;
361
362 return S_OK;
363}
364
365STDMETHODIMP BIOSSettings::COMGETTER(TimeOffset)(LONG64 *offset)
366{
367 if (!offset)
368 return E_POINTER;
369
370 AutoCaller autoCaller (this);
371 CheckComRCReturnRC (autoCaller.rc());
372
373 AutoReaderLock alock (this);
374
375 *offset = mData->mTimeOffset;
376
377 return S_OK;
378}
379
380STDMETHODIMP BIOSSettings::COMSETTER(TimeOffset)(LONG64 offset)
381{
382 AutoCaller autoCaller (this);
383 CheckComRCReturnRC (autoCaller.rc());
384
385 AutoLock alock (this);
386
387 CHECK_MACHINE_MUTABILITY (mParent);
388
389 mData.backup();
390 mData->mTimeOffset = offset;
391
392 return S_OK;
393}
394
395
396// IBIOSSettings methods
397/////////////////////////////////////////////////////////////////////////////
398
399// public methods only for internal purposes
400/////////////////////////////////////////////////////////////////////////////
401
402void BIOSSettings::commit()
403{
404 AutoLock alock (this);
405 if (mData.isBackedUp())
406 {
407 mData.commit();
408 if (mPeer)
409 {
410 // attach new data to the peer and reshare it
411 AutoLock peerlock (mPeer);
412 mPeer->mData.attach (mData);
413 }
414 }
415}
416
417void BIOSSettings::copyFrom (BIOSSettings *aThat)
418{
419 AutoLock alock (this);
420
421 // this will back up current data
422 mData.assignCopy (aThat->mData);
423}
424
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