VirtualBox

source: vbox/trunk/src/VBox/Main/include/MediumAttachmentImpl.h@ 38873

Last change on this file since 38873 was 38873, checked in by vboxsync, 13 years ago

Main: Add API to set the discard flag for harddisks

  • Property svn:eol-style set to native
File size: 4.2 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2011 Oracle Corporation
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 (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_MEDIUMATTACHMENTIMPL
19#define ____H_MEDIUMATTACHMENTIMPL
20
21#include "VirtualBoxBase.h"
22#include "BandwidthGroupImpl.h"
23
24class ATL_NO_VTABLE MediumAttachment :
25 public VirtualBoxBase,
26 VBOX_SCRIPTABLE_IMPL(IMediumAttachment)
27{
28public:
29 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT(MediumAttachment, IMediumAttachment)
30
31 DECLARE_NOT_AGGREGATABLE(MediumAttachment)
32
33 DECLARE_PROTECT_FINAL_CONSTRUCT()
34
35 BEGIN_COM_MAP(MediumAttachment)
36 VBOX_DEFAULT_INTERFACE_ENTRIES(IMediumAttachment)
37 END_COM_MAP()
38
39 MediumAttachment() { };
40 ~MediumAttachment() { };
41
42 // public initializer/uninitializer for internal purposes only
43 HRESULT init(Machine *aParent,
44 Medium *aMedium,
45 const Bstr &aControllerName,
46 LONG aPort,
47 LONG aDevice,
48 DeviceType_T aType,
49 bool fImplicit,
50 bool fPassthrough,
51 bool fTempEject,
52 bool fNonRotational,
53 bool fDiscard,
54 const Utf8Str &strBandwidthGroup);
55 HRESULT initCopy(Machine *aParent, MediumAttachment *aThat);
56 void uninit();
57
58 HRESULT FinalConstruct();
59 void FinalRelease();
60
61 // IMediumAttachment properties
62 STDMETHOD(COMGETTER(Medium))(IMedium **aMedium);
63 STDMETHOD(COMGETTER(Controller))(BSTR *aController);
64 STDMETHOD(COMGETTER(Port))(LONG *aPort);
65 STDMETHOD(COMGETTER(Device))(LONG *aDevice);
66 STDMETHOD(COMGETTER(Type))(DeviceType_T *aType);
67 STDMETHOD(COMGETTER(Passthrough))(BOOL *aPassthrough);
68 STDMETHOD(COMGETTER(TemporaryEject))(BOOL *aTemporaryEject);
69 STDMETHOD(COMGETTER(IsEjected))(BOOL *aIsEjected);
70 STDMETHOD(COMGETTER(NonRotational))(BOOL *aNonRotational);
71 STDMETHOD(COMGETTER(Discard))(BOOL *aDiscard);
72 STDMETHOD(COMGETTER(BandwidthGroup))(IBandwidthGroup **aBwGroup);
73
74 // public internal methods
75 void rollback();
76 void commit();
77
78 // unsafe public methods for internal purposes only (ensure there is
79 // a caller and a read lock before calling them!)
80 bool isImplicit() const;
81 void setImplicit(bool aImplicit);
82
83 const ComObjPtr<Medium>& getMedium() const;
84 Bstr getControllerName() const;
85 LONG getPort() const;
86 LONG getDevice() const;
87 DeviceType_T getType() const;
88 bool getPassthrough() const;
89 bool getTempEject() const;
90 bool getNonRotational() const;
91 bool getDiscard() const;
92 const Utf8Str& getBandwidthGroup() const;
93
94 bool matches(CBSTR aControllerName, LONG aPort, LONG aDevice);
95
96 /** Must be called from under this object's write lock. */
97 void updateMedium(const ComObjPtr<Medium> &aMedium);
98
99 /** Must be called from under this object's write lock. */
100 void updatePassthrough(bool aPassthrough);
101
102 /** Must be called from under this object's write lock. */
103 void updateTempEject(bool aTempEject);
104
105 /** Must be called from under this object's write lock. */
106 void updateNonRotational(bool aNonRotational);
107
108 /** Must be called from under this object's write lock. */
109 void updateDiscard(bool aDiscard);
110
111 /** Must be called from under this object's write lock. */
112 void updateEjected();
113
114 /** Must be called from under this object's write lock. */
115 void updateBandwidthGroup(const Utf8Str &aBandwidthGroup);
116
117 void updateParentMachine(Machine * const pMachine);
118
119 /** Get a unique and somewhat descriptive name for logging. */
120 const char* getLogName(void) const { return mLogName.c_str(); }
121
122private:
123 struct Data;
124 Data *m;
125
126 Utf8Str mLogName; /**< For logging purposes */
127};
128
129#endif // ____H_MEDIUMATTACHMENTIMPL
130/* 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