VirtualBox

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

Last change on this file since 22873 was 22173, checked in by vboxsync, 15 years ago

Main: the big XML settings rework. Move XML reading/writing out of interface implementation code into separate layer so it can handle individual settings versions in the future.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 KB
Line 
1/* $Id: StorageControllerImpl.h 22173 2009-08-11 15:38:59Z 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 VBOX_SCRIPTABLE_IMPL(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
55 || ( (mStorageControllerType == that.mStorageControllerType)
56 && (strName == that.strName)
57 && (mPortCount == that.mPortCount)
58 && (mPortIde0Master == that.mPortIde0Master)
59 && (mPortIde0Slave == that.mPortIde0Slave)
60 && (mPortIde1Master == that.mPortIde1Master)
61 && (mPortIde1Slave == that.mPortIde1Slave));
62 }
63
64 /** Unique name of the storage controller. */
65 Utf8Str strName;
66 /** The connection type of thestorage controller. */
67 StorageBus_T mStorageBus;
68 /** Type of the Storage controller. */
69 StorageControllerType_T mStorageControllerType;
70 /** Number of usable ports. */
71 ULONG mPortCount;
72
73 /** The following is only for the SATA controller atm. */
74 /** Port which acts as primary master for ide emulation. */
75 ULONG mPortIde0Master;
76 /** Port which acts as primary slave for ide emulation. */
77 ULONG mPortIde0Slave;
78 /** Port which acts as secondary master for ide emulation. */
79 ULONG mPortIde1Master;
80 /** Port which acts as secondary slave for ide emulation. */
81 ULONG mPortIde1Slave;
82 };
83
84public:
85
86 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (StorageController)
87
88 DECLARE_NOT_AGGREGATABLE (StorageController)
89
90 DECLARE_PROTECT_FINAL_CONSTRUCT()
91
92 BEGIN_COM_MAP(StorageController)
93 COM_INTERFACE_ENTRY (ISupportErrorInfo)
94 COM_INTERFACE_ENTRY (IStorageController)
95 COM_INTERFACE_ENTRY2 (IDispatch, IStorageController)
96 END_COM_MAP()
97
98 NS_DECL_ISUPPORTS
99
100 DECLARE_EMPTY_CTOR_DTOR (StorageController)
101
102 HRESULT FinalConstruct();
103 void FinalRelease();
104
105 // public initializer/uninitializer for internal purposes only
106 HRESULT init(Machine *aParent,
107 const Utf8Str &aName,
108 StorageBus_T aBus);
109 HRESULT init(Machine *aParent,
110 StorageController *aThat,
111 bool aReshare = false);
112 HRESULT initCopy(Machine *aParent,
113 StorageController *aThat);
114 void uninit();
115
116 // IStorageController properties
117 STDMETHOD(COMGETTER(Name)) (BSTR *aName);
118 STDMETHOD(COMGETTER(Bus)) (StorageBus_T *aBus);
119 STDMETHOD(COMGETTER(ControllerType)) (StorageControllerType_T *aControllerType);
120 STDMETHOD(COMSETTER(ControllerType)) (StorageControllerType_T aControllerType);
121 STDMETHOD(COMGETTER(MaxDevicesPerPortCount)) (ULONG *aMaxDevices);
122 STDMETHOD(COMGETTER(MinPortCount)) (ULONG *aMinPortCount);
123 STDMETHOD(COMGETTER(MaxPortCount)) (ULONG *aMaxPortCount);
124 STDMETHOD(COMGETTER(PortCount)) (ULONG *aPortCount);
125 STDMETHOD(COMSETTER(PortCount)) (ULONG aPortCount);
126 STDMETHOD(COMGETTER(Instance)) (ULONG *aInstance);
127 STDMETHOD(COMSETTER(Instance)) (ULONG aInstance);
128
129 // StorageController methods
130 STDMETHOD(GetIDEEmulationPort) (LONG DevicePosition, LONG *aPortNumber);
131 STDMETHOD(SetIDEEmulationPort) (LONG DevicePosition, LONG aPortNumber);
132
133 // public methods only for internal purposes
134
135 const Utf8Str &name() const { return mData->strName; }
136 StorageControllerType_T controllerType() const { return mData->mStorageControllerType; }
137 StorageBus_T storageBus() const { return mData->mStorageBus; }
138
139 bool isModified() { AutoWriteLock alock (this); return mData.isBackedUp(); }
140 bool isReallyModified() { AutoWriteLock alock (this); return mData.hasActualChanges(); }
141 bool rollback();
142 void commit();
143
144 // public methods for internal purposes only
145 // (ensure there is a caller and a read lock before calling them!)
146
147 void unshare();
148
149 /** @note this doesn't require a read lock since mParent is constant. */
150 const ComObjPtr<Machine, ComWeakRef> &parent() { return mParent; };
151
152 const Backupable<Data> &data() { return mData; }
153 ComObjPtr<StorageController> peer() { return mPeer; }
154
155 // for VirtualBoxSupportErrorInfoImpl
156 static const wchar_t *getComponentName() { return L"StorageController"; }
157
158private:
159
160 void printList();
161
162 /** Parent object. */
163 const ComObjPtr<Machine, ComWeakRef> mParent;
164 /** Peer object. */
165 const ComObjPtr<StorageController> mPeer;
166 /** Data. */
167 Backupable<Data> mData;
168
169 /* Instance number of the device in the running VM. */
170 ULONG mInstance;
171};
172
173#endif //!____H_STORAGECONTROLLERIMPL
174/* 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