VirtualBox

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

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

The Big Sun Rebranding Header Change

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 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#include "HardDiskImpl.h"
24
25#include "Logging.h"
26
27// constructor / destructor
28/////////////////////////////////////////////////////////////////////////////
29
30DEFINE_EMPTY_CTOR_DTOR (HardDiskAttachment)
31
32HRESULT HardDiskAttachment::FinalConstruct()
33{
34 mBus = StorageBus_Null;
35 mChannel = 0;
36 mDevice = 0;
37
38 return S_OK;
39}
40
41void HardDiskAttachment::FinalRelease()
42{
43}
44
45// public initializer/uninitializer for internal purposes only
46/////////////////////////////////////////////////////////////////////////////
47
48/**
49 * Initializes the hard disk attachment object.
50 * The initialized object becomes immediately dirty
51 *
52 * @param aHD hard disk object
53 * @param aBus bus type
54 * @param aChannel channel number
55 * @param aDevice device number on the channel
56 * @param aDirty whether the attachment is initially dirty or not
57 */
58HRESULT HardDiskAttachment::init (HardDisk *aHD, StorageBus_T aBus, LONG aChannel, LONG aDevice,
59 BOOL aDirty)
60{
61 ComAssertRet (aHD, E_INVALIDARG);
62
63 if (aBus == StorageBus_IDE)
64 {
65 if (aChannel < 0 || aChannel > 1)
66 return setError (E_FAIL,
67 tr ("Invalid IDE channel for hard disk '%ls': %d. "
68 "IDE channel number must be in range [0,1]"),
69 aHD->toString().raw(), aChannel);
70 if (aDevice < 0 || aDevice > 1 || (aChannel == 1 && aDevice == 0))
71 return setError (E_FAIL,
72 tr ("Invalid IDE device slot for hard disk '%ls': %d. "
73 "IDE device slot number must be in range [0,1] for "
74 "channel 0 and always 1 for channel 1"),
75 aHD->toString().raw(), aDevice);
76 }
77
78 AutoWriteLock alock (this);
79
80 mDirty = aDirty;
81
82 mHardDisk = aHD;
83 mBus = aBus;
84 mChannel = aChannel;
85 mDevice = aDevice;
86
87 setReady (true);
88 return S_OK;
89}
90
91// IHardDiskAttachment properties
92/////////////////////////////////////////////////////////////////////////////
93
94STDMETHODIMP HardDiskAttachment::COMGETTER(HardDisk) (IHardDisk **aHardDisk)
95{
96 if (!aHardDisk)
97 return E_POINTER;
98
99 AutoWriteLock alock (this);
100 CHECK_READY();
101
102 ComAssertRet (!!mHardDisk, E_FAIL);
103
104 mHardDisk.queryInterfaceTo (aHardDisk);
105 return S_OK;
106}
107
108STDMETHODIMP HardDiskAttachment::COMGETTER(Bus) (StorageBus_T *aBus)
109{
110 if (!aBus)
111 return E_POINTER;
112
113 AutoWriteLock alock (this);
114 CHECK_READY();
115
116 *aBus = mBus;
117 return S_OK;
118}
119
120STDMETHODIMP HardDiskAttachment::COMGETTER(Channel) (LONG *aChannel)
121{
122 if (!aChannel)
123 return E_INVALIDARG;
124
125 AutoWriteLock alock (this);
126 CHECK_READY();
127
128 *aChannel = mChannel;
129 return S_OK;
130}
131
132STDMETHODIMP HardDiskAttachment::COMGETTER(Device) (LONG *aDevice)
133{
134 if (!aDevice)
135 return E_INVALIDARG;
136
137 AutoWriteLock alock (this);
138 CHECK_READY();
139
140 *aDevice = mDevice;
141 return S_OK;
142}
143
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use