VirtualBox

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

Last change on this file since 14579 was 14579, checked in by vboxsync, 16 years ago

Main: VirtualBoxBase::addCaller() now returns E_ACCESSDENIED. Also replaced E_UNEXPECTED with E_FAIL in all Assert* statements (for consistency).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include "HardDiskAttachmentImpl.h"
23
24#include "Logging.h"
25
26// constructor / destructor
27/////////////////////////////////////////////////////////////////////////////
28
29HRESULT HardDisk2Attachment::FinalConstruct()
30{
31 return S_OK;
32}
33
34void HardDisk2Attachment::FinalRelease()
35{
36 uninit();
37}
38
39// public initializer/uninitializer for internal purposes only
40/////////////////////////////////////////////////////////////////////////////
41
42/**
43 * Initializes the hard disk attachment object.
44 *
45 * @param aHD Hard disk object.
46 * @param aBus Bus type.
47 * @param aChannel Channel number.
48 * @param aDevice Device number on the channel.
49 * @param aImplicit Wether the attachment contains an implicitly created diff.
50 */
51HRESULT HardDisk2Attachment::init (HardDisk2 *aHD, StorageBus_T aBus, LONG aChannel,
52 LONG aDevice, bool aImplicit /*= false*/)
53{
54 AssertReturn (aHD, E_INVALIDARG);
55
56 /* Enclose the state transition NotReady->InInit->Ready */
57 AutoInitSpan autoInitSpan (this);
58 AssertReturn (autoInitSpan.isOk(), E_FAIL);
59
60 m.hardDisk = aHD;
61 unconst (m.bus) = aBus;
62 unconst (m.channel) = aChannel;
63 unconst (m.device) = aDevice;
64
65 m.implicit = aImplicit;
66
67 /* Confirm a successful initialization when it's the case */
68 autoInitSpan.setSucceeded();
69
70 return S_OK;
71}
72
73/**
74 * Uninitializes the instance.
75 * Called from FinalRelease().
76 */
77void HardDisk2Attachment::uninit()
78{
79 /* Enclose the state transition Ready->InUninit->NotReady */
80 AutoUninitSpan autoUninitSpan (this);
81 if (autoUninitSpan.uninitDone())
82 return;
83}
84
85// IHardDisk2Attachment properties
86/////////////////////////////////////////////////////////////////////////////
87
88STDMETHODIMP HardDisk2Attachment::COMGETTER(HardDisk) (IHardDisk2 **aHardDisk)
89{
90 if (!aHardDisk)
91 return E_POINTER;
92
93 AutoCaller autoCaller (this);
94 CheckComRCReturnRC (autoCaller.rc());
95
96 AutoReadLock alock (this);
97
98 m.hardDisk.queryInterfaceTo (aHardDisk);
99
100 return S_OK;
101}
102
103STDMETHODIMP HardDisk2Attachment::COMGETTER(Bus) (StorageBus_T *aBus)
104{
105 if (!aBus)
106 return E_POINTER;
107
108 AutoCaller autoCaller (this);
109 CheckComRCReturnRC (autoCaller.rc());
110
111 /* m.bus is constant during life time, no need to lock */
112 *aBus = m.bus;
113
114 return S_OK;
115}
116
117STDMETHODIMP HardDisk2Attachment::COMGETTER(Channel) (LONG *aChannel)
118{
119 if (!aChannel)
120 return E_INVALIDARG;
121
122 AutoCaller autoCaller (this);
123 CheckComRCReturnRC (autoCaller.rc());
124
125 /* m.channel is constant during life time, no need to lock */
126 *aChannel = m.channel;
127
128 return S_OK;
129}
130
131STDMETHODIMP HardDisk2Attachment::COMGETTER(Device) (LONG *aDevice)
132{
133 if (!aDevice)
134 return E_INVALIDARG;
135
136 AutoCaller autoCaller (this);
137 CheckComRCReturnRC (autoCaller.rc());
138
139 /* m.device is constant during life time, no need to lock */
140 *aDevice = m.device;
141
142 return S_OK;
143}
144
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