1 | /** @file
|
---|
2 | *
|
---|
3 | * VirtualBox COM class implementation
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006 InnoTek Systemberatung GmbH
|
---|
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 as published by the Free Software Foundation,
|
---|
13 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
14 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
15 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * If you received this file as part of a commercial VirtualBox
|
---|
18 | * distribution, then only the terms of your commercial VirtualBox
|
---|
19 | * license agreement apply instead of the previous paragraph.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef ____H_DVDDRIVEIMPL
|
---|
23 | #define ____H_DVDDRIVEIMPL
|
---|
24 |
|
---|
25 | #include "VirtualBoxBase.h"
|
---|
26 |
|
---|
27 | class Machine;
|
---|
28 |
|
---|
29 | class ATL_NO_VTABLE DVDDrive :
|
---|
30 | public VirtualBoxSupportErrorInfoImpl <DVDDrive, IDVDDrive>,
|
---|
31 | public VirtualBoxSupportTranslation <DVDDrive>,
|
---|
32 | public VirtualBoxBase,
|
---|
33 | public IDVDDrive
|
---|
34 | {
|
---|
35 | public:
|
---|
36 |
|
---|
37 | struct Data
|
---|
38 | {
|
---|
39 | Data() {
|
---|
40 | mDriveState = DriveState_NotMounted;
|
---|
41 | mPassthrough = false;
|
---|
42 | }
|
---|
43 |
|
---|
44 | bool operator== (const Data &that) const
|
---|
45 | {
|
---|
46 | return this == &that ||
|
---|
47 | (mDriveState == that.mDriveState &&
|
---|
48 | mDVDImage.equalsTo (that.mDVDImage) &&
|
---|
49 | mHostDrive.equalsTo (that.mHostDrive));
|
---|
50 | }
|
---|
51 |
|
---|
52 | ComPtr <IDVDImage> mDVDImage;
|
---|
53 | ComPtr <IHostDVDDrive> mHostDrive;
|
---|
54 | DriveState_T mDriveState;
|
---|
55 | BOOL mPassthrough;
|
---|
56 | };
|
---|
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 | HRESULT FinalConstruct();
|
---|
70 | void FinalRelease();
|
---|
71 |
|
---|
72 | // public initializer/uninitializer for internal purposes only
|
---|
73 | HRESULT init (Machine *parent);
|
---|
74 | HRESULT init (Machine *parent, DVDDrive *that);
|
---|
75 | HRESULT initCopy (Machine *parent, DVDDrive *that);
|
---|
76 | void uninit();
|
---|
77 |
|
---|
78 | // IDVDDrive properties
|
---|
79 | STDMETHOD(COMGETTER(State)) (DriveState_T *driveState);
|
---|
80 | STDMETHOD(COMGETTER(Passthrough)) (BOOL *passthrough);
|
---|
81 | STDMETHOD(COMSETTER(Passthrough)) (BOOL passthrough);
|
---|
82 |
|
---|
83 | // IDVDDrive methods
|
---|
84 | STDMETHOD(MountImage)(INPTR GUIDPARAM imageId);
|
---|
85 | STDMETHOD(CaptureHostDrive)(IHostDVDDrive *hostDVDDrive);
|
---|
86 | STDMETHOD(Unmount)();
|
---|
87 | STDMETHOD(GetImage)(IDVDImage **dvdImage);
|
---|
88 | STDMETHOD(GetHostDrive)(IHostDVDDrive **hostDVDDrive);
|
---|
89 |
|
---|
90 | // public methods only for internal purposes
|
---|
91 |
|
---|
92 | bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
|
---|
93 | bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
|
---|
94 | bool rollback();
|
---|
95 | void commit();
|
---|
96 | void copyFrom (DVDDrive *aThat);
|
---|
97 |
|
---|
98 | Backupable <Data> &data() { return mData; }
|
---|
99 |
|
---|
100 | // for VirtualBoxSupportErrorInfoImpl
|
---|
101 | static const wchar_t *getComponentName() { return L"DVDDrive"; }
|
---|
102 |
|
---|
103 | private:
|
---|
104 |
|
---|
105 | HRESULT unmount();
|
---|
106 |
|
---|
107 | ComObjPtr <Machine, ComWeakRef> mParent;
|
---|
108 | ComObjPtr <DVDDrive> mPeer;
|
---|
109 | Backupable <Data> mData;
|
---|
110 | };
|
---|
111 |
|
---|
112 | #endif // ____H_DVDDRIVEIMPL
|
---|
113 |
|
---|