VirtualBox

source: vbox/trunk/src/VBox/Main/include/DVDDriveImpl.h@ 4041

Last change on this file since 4041 was 3330, checked in by vboxsync, 17 years ago

Main: Converted DVDDrive and FloppyDrive to the new locking scheme.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 innotek 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
27class Machine;
28
29class ATL_NO_VTABLE DVDDrive :
30 public VirtualBoxBaseNEXT,
31 public VirtualBoxSupportErrorInfoImpl <DVDDrive, IDVDDrive>,
32 public VirtualBoxSupportTranslation <DVDDrive>,
33 public IDVDDrive
34{
35public:
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 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (DVDDrive)
59
60 DECLARE_NOT_AGGREGATABLE(DVDDrive)
61
62 DECLARE_PROTECT_FINAL_CONSTRUCT()
63
64 BEGIN_COM_MAP(DVDDrive)
65 COM_INTERFACE_ENTRY(ISupportErrorInfo)
66 COM_INTERFACE_ENTRY(IDVDDrive)
67 END_COM_MAP()
68
69 NS_DECL_ISUPPORTS
70
71 DECLARE_EMPTY_CTOR_DTOR (DVDDrive)
72
73 HRESULT FinalConstruct();
74 void FinalRelease();
75
76 // public initializer/uninitializer for internal purposes only
77 HRESULT init (Machine *aParent);
78 HRESULT init (Machine *aParent, DVDDrive *aThat);
79 HRESULT initCopy (Machine *aParent, DVDDrive *aThat);
80 void uninit();
81
82 // IDVDDrive properties
83 STDMETHOD(COMGETTER(State)) (DriveState_T *aDriveState);
84 STDMETHOD(COMGETTER(Passthrough)) (BOOL *aPassthrough);
85 STDMETHOD(COMSETTER(Passthrough)) (BOOL aPassthrough);
86
87 // IDVDDrive methods
88 STDMETHOD(MountImage) (INPTR GUIDPARAM aImageId);
89 STDMETHOD(CaptureHostDrive) (IHostDVDDrive *aHostDVDDrive);
90 STDMETHOD(Unmount)();
91 STDMETHOD(GetImage) (IDVDImage **aDVDImage);
92 STDMETHOD(GetHostDrive) (IHostDVDDrive **aHostDVDDrive);
93
94 // public methods only for internal purposes
95
96 bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
97 bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
98 bool rollback();
99 void commit();
100 void copyFrom (DVDDrive *aThat);
101
102 // public methods for internal purposes only
103 // (ensure there is a caller and a read lock before calling them!)
104
105 Backupable <Data> &data() { return mData; }
106
107 // for VirtualBoxSupportErrorInfoImpl
108 static const wchar_t *getComponentName() { return L"DVDDrive"; }
109
110private:
111
112 HRESULT unmount();
113
114 const ComObjPtr <Machine, ComWeakRef> mParent;
115 const ComObjPtr <DVDDrive> mPeer;
116
117 Backupable <Data> mData;
118};
119
120#endif // ____H_DVDDRIVEIMPL
121
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