1 | /* $Id: DVDDriveImpl.h 6076 2007-12-14 19:23:03Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | *
|
---|
5 | * VirtualBox COM class implementation
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
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 |
|
---|
20 | #ifndef ____H_DVDDRIVEIMPL
|
---|
21 | #define ____H_DVDDRIVEIMPL
|
---|
22 |
|
---|
23 | #include "VirtualBoxBase.h"
|
---|
24 |
|
---|
25 | class Machine;
|
---|
26 |
|
---|
27 | class ATL_NO_VTABLE DVDDrive :
|
---|
28 | public VirtualBoxBaseNEXT,
|
---|
29 | public VirtualBoxSupportErrorInfoImpl <DVDDrive, IDVDDrive>,
|
---|
30 | public VirtualBoxSupportTranslation <DVDDrive>,
|
---|
31 | public IDVDDrive
|
---|
32 | {
|
---|
33 | public:
|
---|
34 |
|
---|
35 | struct Data
|
---|
36 | {
|
---|
37 | Data() {
|
---|
38 | mDriveState = DriveState_NotMounted;
|
---|
39 | mPassthrough = false;
|
---|
40 | }
|
---|
41 |
|
---|
42 | bool operator== (const Data &that) const
|
---|
43 | {
|
---|
44 | return this == &that ||
|
---|
45 | (mDriveState == that.mDriveState &&
|
---|
46 | mDVDImage.equalsTo (that.mDVDImage) &&
|
---|
47 | mHostDrive.equalsTo (that.mHostDrive));
|
---|
48 | }
|
---|
49 |
|
---|
50 | ComPtr <IDVDImage> mDVDImage;
|
---|
51 | ComPtr <IHostDVDDrive> mHostDrive;
|
---|
52 | DriveState_T mDriveState;
|
---|
53 | BOOL mPassthrough;
|
---|
54 | };
|
---|
55 |
|
---|
56 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (DVDDrive)
|
---|
57 |
|
---|
58 | DECLARE_NOT_AGGREGATABLE(DVDDrive)
|
---|
59 |
|
---|
60 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
61 |
|
---|
62 | BEGIN_COM_MAP(DVDDrive)
|
---|
63 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
64 | COM_INTERFACE_ENTRY(IDVDDrive)
|
---|
65 | END_COM_MAP()
|
---|
66 |
|
---|
67 | NS_DECL_ISUPPORTS
|
---|
68 |
|
---|
69 | DECLARE_EMPTY_CTOR_DTOR (DVDDrive)
|
---|
70 |
|
---|
71 | HRESULT FinalConstruct();
|
---|
72 | void FinalRelease();
|
---|
73 |
|
---|
74 | // public initializer/uninitializer for internal purposes only
|
---|
75 | HRESULT init (Machine *aParent);
|
---|
76 | HRESULT init (Machine *aParent, DVDDrive *aThat);
|
---|
77 | HRESULT initCopy (Machine *aParent, DVDDrive *aThat);
|
---|
78 | void uninit();
|
---|
79 |
|
---|
80 | // IDVDDrive properties
|
---|
81 | STDMETHOD(COMGETTER(State)) (DriveState_T *aDriveState);
|
---|
82 | STDMETHOD(COMGETTER(Passthrough)) (BOOL *aPassthrough);
|
---|
83 | STDMETHOD(COMSETTER(Passthrough)) (BOOL aPassthrough);
|
---|
84 |
|
---|
85 | // IDVDDrive methods
|
---|
86 | STDMETHOD(MountImage) (INPTR GUIDPARAM aImageId);
|
---|
87 | STDMETHOD(CaptureHostDrive) (IHostDVDDrive *aHostDVDDrive);
|
---|
88 | STDMETHOD(Unmount)();
|
---|
89 | STDMETHOD(GetImage) (IDVDImage **aDVDImage);
|
---|
90 | STDMETHOD(GetHostDrive) (IHostDVDDrive **aHostDVDDrive);
|
---|
91 |
|
---|
92 | // public methods only for internal purposes
|
---|
93 |
|
---|
94 | HRESULT loadSettings (const settings::Key &aMachineNode);
|
---|
95 | HRESULT saveSettings (settings::Key &aMachineNode);
|
---|
96 |
|
---|
97 | bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
|
---|
98 | bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
|
---|
99 | bool rollback();
|
---|
100 | void commit();
|
---|
101 | void copyFrom (DVDDrive *aThat);
|
---|
102 |
|
---|
103 | // public methods for internal purposes only
|
---|
104 | // (ensure there is a caller and a read lock before calling them!)
|
---|
105 |
|
---|
106 | Backupable <Data> &data() { return mData; }
|
---|
107 |
|
---|
108 | // for VirtualBoxSupportErrorInfoImpl
|
---|
109 | static const wchar_t *getComponentName() { return L"DVDDrive"; }
|
---|
110 |
|
---|
111 | private:
|
---|
112 |
|
---|
113 | HRESULT unmount();
|
---|
114 |
|
---|
115 | const ComObjPtr <Machine, ComWeakRef> mParent;
|
---|
116 | const ComObjPtr <DVDDrive> mPeer;
|
---|
117 |
|
---|
118 | Backupable <Data> mData;
|
---|
119 | };
|
---|
120 |
|
---|
121 | #endif // ____H_DVDDRIVEIMPL
|
---|
122 |
|
---|