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 |
|
---|
18 | #ifndef ____H_FLOPPYDRIVEIMPL
|
---|
19 | #define ____H_FLOPPYDRIVEIMPL
|
---|
20 |
|
---|
21 | #include "VirtualBoxBase.h"
|
---|
22 |
|
---|
23 | class Machine;
|
---|
24 |
|
---|
25 | class ATL_NO_VTABLE FloppyDrive :
|
---|
26 | public VirtualBoxBaseNEXT,
|
---|
27 | public VirtualBoxSupportErrorInfoImpl <FloppyDrive, IFloppyDrive>,
|
---|
28 | public VirtualBoxSupportTranslation <FloppyDrive>,
|
---|
29 | public IFloppyDrive
|
---|
30 | {
|
---|
31 | public:
|
---|
32 |
|
---|
33 | struct Data
|
---|
34 | {
|
---|
35 | Data()
|
---|
36 | {
|
---|
37 | mEnabled = true;
|
---|
38 | mDriveState = DriveState_NotMounted;
|
---|
39 | }
|
---|
40 |
|
---|
41 | bool operator== (const Data &that) const
|
---|
42 | {
|
---|
43 | return this == &that ||
|
---|
44 | (mDriveState == that.mDriveState &&
|
---|
45 | mFloppyImage.equalsTo (that.mFloppyImage) &&
|
---|
46 | mHostDrive.equalsTo (that.mHostDrive));
|
---|
47 | }
|
---|
48 |
|
---|
49 | BOOL mEnabled;
|
---|
50 | ComPtr <IFloppyImage> mFloppyImage;
|
---|
51 | ComPtr <IHostFloppyDrive> mHostDrive;
|
---|
52 | DriveState_T mDriveState;
|
---|
53 | };
|
---|
54 |
|
---|
55 | VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (FloppyDrive)
|
---|
56 |
|
---|
57 | DECLARE_NOT_AGGREGATABLE(FloppyDrive)
|
---|
58 |
|
---|
59 | DECLARE_PROTECT_FINAL_CONSTRUCT()
|
---|
60 |
|
---|
61 | BEGIN_COM_MAP(FloppyDrive)
|
---|
62 | COM_INTERFACE_ENTRY(ISupportErrorInfo)
|
---|
63 | COM_INTERFACE_ENTRY(IFloppyDrive)
|
---|
64 | END_COM_MAP()
|
---|
65 |
|
---|
66 | NS_DECL_ISUPPORTS
|
---|
67 |
|
---|
68 | DECLARE_EMPTY_CTOR_DTOR (FloppyDrive)
|
---|
69 |
|
---|
70 | HRESULT FinalConstruct();
|
---|
71 | void FinalRelease();
|
---|
72 |
|
---|
73 | // public initializer/uninitializer for internal purposes only
|
---|
74 | HRESULT init (Machine *aParent);
|
---|
75 | HRESULT init (Machine *aParent, FloppyDrive *aThat);
|
---|
76 | HRESULT initCopy (Machine *parent, FloppyDrive *aThat);
|
---|
77 | void uninit();
|
---|
78 |
|
---|
79 | // IFloppyDrive properties
|
---|
80 | STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
|
---|
81 | STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
|
---|
82 | STDMETHOD(COMGETTER(State)) (DriveState_T *aDriveState);
|
---|
83 |
|
---|
84 | // IFloppyDrive methods
|
---|
85 | STDMETHOD(MountImage) (INPTR GUIDPARAM aImageId);
|
---|
86 | STDMETHOD(CaptureHostDrive) (IHostFloppyDrive *aHostFloppyDrive);
|
---|
87 | STDMETHOD(Unmount)();
|
---|
88 | STDMETHOD(GetImage) (IFloppyImage **aFloppyImage);
|
---|
89 | STDMETHOD(GetHostDrive) (IHostFloppyDrive **aHostFloppyDrive);
|
---|
90 |
|
---|
91 | // public methods only for internal purposes
|
---|
92 |
|
---|
93 | bool isModified() { AutoLock alock (this); return mData.isBackedUp(); }
|
---|
94 | bool isReallyModified() { AutoLock alock (this); return mData.hasActualChanges(); }
|
---|
95 | bool rollback();
|
---|
96 | void commit();
|
---|
97 | void copyFrom (FloppyDrive *aThat);
|
---|
98 |
|
---|
99 | // public methods for internal purposes only
|
---|
100 | // (ensure there is a caller and a read lock before calling them!)
|
---|
101 |
|
---|
102 | Backupable <Data> &data() { return mData; }
|
---|
103 |
|
---|
104 | // for VirtualBoxSupportErrorInfoImpl
|
---|
105 | static const wchar_t *getComponentName() { return L"FloppyDrive"; }
|
---|
106 |
|
---|
107 | private:
|
---|
108 |
|
---|
109 | HRESULT unmount();
|
---|
110 |
|
---|
111 | const ComObjPtr <Machine, ComWeakRef> mParent;
|
---|
112 | const ComObjPtr <FloppyDrive> mPeer;
|
---|
113 |
|
---|
114 | Backupable <Data> mData;
|
---|
115 | };
|
---|
116 |
|
---|
117 | #endif // ____H_FLOPPYDRIVEIMPL
|
---|