VirtualBox

source: vbox/trunk/src/VBox/Main/include/StorageControllerImpl.h@ 18622

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

export

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
1/* $Id: StorageControllerImpl.h 17768 2009-03-12 17:49:08Z vboxsync $ */
2
3/** @file
4 *
5 * VBox StorageController COM Class declaration.
6 */
7
8/*
9 * Copyright (C) 2008 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_STORAGECONTROLLERIMPL
25#define ____H_STORAGECONTROLLERIMPL
26
27#include "VirtualBoxBase.h"
28
29#include <list>
30
31class Machine;
32
33class ATL_NO_VTABLE StorageController :
34 public VirtualBoxBaseWithChildrenNEXT,
35 public VirtualBoxSupportErrorInfoImpl <StorageController, IStorageController>,
36 public VirtualBoxSupportTranslation <StorageController>,
37 public IStorageController
38{
39private:
40
41 struct Data
42 {
43 /* Constructor. */
44 Data() : mStorageBus (StorageBus_IDE),
45 mStorageControllerType (StorageControllerType_PIIX4),
46 mPortCount (2),
47 mPortIde0Master (0),
48 mPortIde0Slave (1),
49 mPortIde1Master (2),
50 mPortIde1Slave (3) { }
51
52 bool operator== (const Data &that) const
53 {
54 return this == &that || ((mStorageControllerType == that.mStorageControllerType) &&
55 (mName == that.mName) &&
56 (mPortCount == that.mPortCount) &&
57 (mPortIde0Master == that.mPortIde0Master) &&
58 (mPortIde0Slave == that.mPortIde0Slave) &&
59 (mPortIde1Master == that.mPortIde1Master) &&
60 (mPortIde1Slave == that.mPortIde1Slave));
61 }
62
63 /** Uniuqe name of the storage controller. */
64 Bstr mName;
65 /** The connection type of thestorage controller. */
66 StorageBus_T mStorageBus;
67 /** Type of the Storage controller. */
68 StorageControllerType_T mStorageControllerType;
69 /** Number of usable ports. */
70 ULONG mPortCount;
71
72 /** The following is only for the SATA controller atm. */
73 /** Port which acts as primary master for ide emulation. */
74 ULONG mPortIde0Master;
75 /** Port which acts as primary slave for ide emulation. */
76 ULONG mPortIde0Slave;
77 /** Port which acts as secondary master for ide emulation. */
78 ULONG mPortIde1Master;
79 /** Port which acts as secondary slave for ide emulation. */
80 ULONG mPortIde1Slave;
81 };
82
83public:
84
85 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (StorageController)
86
87 DECLARE_NOT_AGGREGATABLE (StorageController)
88
89 DECLARE_PROTECT_FINAL_CONSTRUCT()
90
91 BEGIN_COM_MAP(StorageController)
92 COM_INTERFACE_ENTRY (ISupportErrorInfo)
93 COM_INTERFACE_ENTRY (IStorageController)
94 END_COM_MAP()
95
96 NS_DECL_ISUPPORTS
97
98 DECLARE_EMPTY_CTOR_DTOR (StorageController)
99
100 HRESULT FinalConstruct();
101 void FinalRelease();
102
103 // public initializer/uninitializer for internal purposes only
104 HRESULT init (Machine *aParent, IN_BSTR aName,
105 StorageBus_T aBus);
106 HRESULT init (Machine *aParent, StorageController *aThat, bool aReshare = false);
107 HRESULT initCopy (Machine *aParent, StorageController *aThat);
108 void uninit();
109
110 // IStorageController properties
111 STDMETHOD(COMGETTER(Name)) (BSTR *aName);
112 STDMETHOD(COMGETTER(Bus)) (StorageBus_T *aBus);
113 STDMETHOD(COMGETTER(ControllerType)) (StorageControllerType_T *aControllerType);
114 STDMETHOD(COMSETTER(ControllerType)) (StorageControllerType_T aControllerType);
115 STDMETHOD(COMGETTER(MaxDevicesPerPortCount)) (ULONG *aMaxDevices);
116 STDMETHOD(COMGETTER(MinPortCount)) (ULONG *aMinPortCount);
117 STDMETHOD(COMGETTER(MaxPortCount)) (ULONG *aMaxPortCount);
118 STDMETHOD(COMGETTER(PortCount)) (ULONG *aPortCount);
119 STDMETHOD(COMSETTER(PortCount)) (ULONG aPortCount);
120 STDMETHOD(COMGETTER(Instance)) (ULONG *aInstance);
121 STDMETHOD(COMSETTER(Instance)) (ULONG aInstance);
122
123 // StorageController methods
124 STDMETHOD(GetIDEEmulationPort) (LONG DevicePosition, LONG *aPortNumber);
125 STDMETHOD(SetIDEEmulationPort) (LONG DevicePosition, LONG aPortNumber);
126
127 // public methods only for internal purposes
128
129 const Bstr &name() const { return mData->mName; }
130 StorageControllerType_T controllerType() const { return mData->mStorageControllerType; }
131
132 bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
133 bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
134 bool rollback();
135 void commit();
136
137 // public methods for internal purposes only
138 // (ensure there is a caller and a read lock before calling them!)
139
140 void unshare();
141
142 /** @note this doesn't require a read lock since mParent is constant. */
143 const ComObjPtr <Machine, ComWeakRef> &parent() { return mParent; };
144
145 const Backupable<Data> &data() { return mData; }
146 ComObjPtr <StorageController> peer() { return mPeer; }
147
148 // for VirtualBoxSupportErrorInfoImpl
149 static const wchar_t *getComponentName() { return L"StorageController"; }
150
151private:
152
153 void printList();
154
155 /** Parent object. */
156 const ComObjPtr<Machine, ComWeakRef> mParent;
157 /** Peer object. */
158 const ComObjPtr <StorageController> mPeer;
159 /** Data. */
160 Backupable <Data> mData;
161
162 /* Instance number of the device in the running VM. */
163 ULONG mInstance;
164};
165
166#endif //!____H_STORAGECONTROLLERIMPL
167/* vi: set tabstop=4 shiftwidth=4 expandtab: */
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