VirtualBox

source: vbox/trunk/src/VBox/Main/HardDiskAttachmentImpl.cpp@ 7392

Last change on this file since 7392 was 7207, checked in by vboxsync, 17 years ago

Main: Reworked enums to avoid 1) weird duplication of enum name when referring to enum values in cross-platform code; 2) possible clashes on Win32 due to putting identifiers like Paused or Disabled to the global namespace (via C enums). In the new style, enums are used like this: a) USBDeviceState_T v = USBDeviceState_Busy from cross-platform non-Qt code; b) KUSBDeviceState v = KUSBDeviceState_Busy from Qt code; c) USBDeviceState v = USBDeviceState_Busy from plain Win32 and d) PRUInt32 USBDeviceState v = USBDeviceState::Busy from plain XPCOM.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "HardDiskAttachmentImpl.h"
19#include "HardDiskImpl.h"
20
21#include "Logging.h"
22
23// constructor / destructor
24/////////////////////////////////////////////////////////////////////////////
25
26DEFINE_EMPTY_CTOR_DTOR (HardDiskAttachment)
27
28HRESULT HardDiskAttachment::FinalConstruct()
29{
30 mController = DiskControllerType_Null;
31 mDeviceNumber = 0;
32
33 return S_OK;
34}
35
36void HardDiskAttachment::FinalRelease()
37{
38}
39
40// public initializer/uninitializer for internal purposes only
41/////////////////////////////////////////////////////////////////////////////
42
43/**
44 * Initializes the hard disk attachment object.
45 * The initialized object becomes immediately dirty
46 *
47 * @param aHD hard disk object
48 * @param aCtl controller type
49 * @param aDev device number on the controller
50 * @param aDirty whether the attachment is initially dirty or not
51 */
52HRESULT HardDiskAttachment::init (HardDisk *aHD, DiskControllerType_T aCtl, LONG aDev,
53 BOOL aDirty)
54{
55 ComAssertRet (aHD, E_INVALIDARG);
56
57 AutoLock alock (this);
58
59 mDirty = aDirty;
60
61 mHardDisk = aHD;
62 mController = aCtl;
63 mDeviceNumber = aDev;
64
65 setReady (true);
66 return S_OK;
67}
68
69// IHardDiskAttachment properties
70/////////////////////////////////////////////////////////////////////////////
71
72STDMETHODIMP HardDiskAttachment::COMGETTER(HardDisk) (IHardDisk **aHardDisk)
73{
74 if (!aHardDisk)
75 return E_POINTER;
76
77 AutoLock alock (this);
78 CHECK_READY();
79
80 ComAssertRet (!!mHardDisk, E_FAIL);
81
82 mHardDisk.queryInterfaceTo (aHardDisk);
83 return S_OK;
84}
85
86STDMETHODIMP HardDiskAttachment::COMGETTER(Controller) (DiskControllerType_T *aController)
87{
88 if (!aController)
89 return E_POINTER;
90
91 AutoLock alock (this);
92 CHECK_READY();
93
94 *aController = mController;
95 return S_OK;
96}
97
98STDMETHODIMP HardDiskAttachment::COMGETTER(DeviceNumber) (LONG *aDeviceNumber)
99{
100 if (!aDeviceNumber)
101 return E_INVALIDARG;
102
103 AutoLock alock (this);
104 CHECK_READY();
105
106 *aDeviceNumber = mDeviceNumber;
107 return S_OK;
108}
109
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