VirtualBox

source: vbox/trunk/src/VBox/Main/include/HardDiskAttachmentImpl.h@ 16560

Last change on this file since 16560 was 14949, checked in by vboxsync, 15 years ago

Appended vim modeline to set tabstop and expand tabs (in the way
suggested by our coding guidelines).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.3 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ____H_HARDDISKATTACHMENTIMPL
23#define ____H_HARDDISKATTACHMENTIMPL
24
25#include "VirtualBoxBase.h"
26
27#include "HardDisk2Impl.h"
28
29class ATL_NO_VTABLE HardDisk2Attachment :
30 public VirtualBoxBaseNEXT,
31 public com::SupportErrorInfoImpl <HardDisk2Attachment, IHardDisk2Attachment>,
32 public VirtualBoxSupportTranslation <HardDisk2Attachment>,
33 public IHardDisk2Attachment
34{
35public:
36
37 /** Equality predicate for stdc++. */
38 struct EqualsTo
39 : public std::unary_function <ComObjPtr <HardDisk2Attachment>, bool>
40 {
41 explicit EqualsTo (StorageBus_T aBus, LONG aChannel, LONG aDevice)
42 : bus (aBus), channel (aChannel), device (aDevice) {}
43
44 bool operator() (const argument_type &aThat) const
45 {
46 return aThat->bus() == bus && aThat->channel() == channel &&
47 aThat->device() == device;
48 }
49
50 const StorageBus_T bus;
51 const LONG channel;
52 const LONG device;
53 };
54
55 /** Hard disk reference predicate for stdc++. */
56 struct RefersTo
57 : public std::unary_function <ComObjPtr <HardDisk2Attachment>, bool>
58 {
59 explicit RefersTo (HardDisk2 *aHardDisk) : hardDisk (aHardDisk) {}
60
61 bool operator() (const argument_type &aThat) const
62 {
63 return aThat->hardDisk().equalsTo (hardDisk);
64 }
65
66 const ComObjPtr <HardDisk2> hardDisk;
67 };
68
69 DECLARE_NOT_AGGREGATABLE(HardDisk2Attachment)
70
71 DECLARE_PROTECT_FINAL_CONSTRUCT()
72
73 BEGIN_COM_MAP (HardDisk2Attachment)
74 COM_INTERFACE_ENTRY(ISupportErrorInfo)
75 COM_INTERFACE_ENTRY(IHardDisk2Attachment)
76 END_COM_MAP()
77
78 NS_DECL_ISUPPORTS
79
80 HRESULT FinalConstruct();
81 void FinalRelease();
82
83 // public initializer/uninitializer for internal purposes only
84 HRESULT init (HardDisk2 *aHD, StorageBus_T aBus, LONG aChannel,
85 LONG aDevice, bool aImplicit = false);
86 void uninit();
87
88 // IHardDisk2Attachment properties
89 STDMETHOD(COMGETTER(HardDisk)) (IHardDisk2 **aHardDisk);
90 STDMETHOD(COMGETTER(Bus)) (StorageBus_T *aBus);
91 STDMETHOD(COMGETTER(Channel)) (LONG *aChannel);
92 STDMETHOD(COMGETTER(Device)) (LONG *aDevice);
93
94 // unsafe inline public methods for internal purposes only (ensure there is
95 // a caller and a read lock before calling them!)
96
97 bool isImplicit() const { return m.implicit; }
98 void setImplicit (bool aImplicit) { m.implicit = aImplicit; }
99
100 const ComObjPtr <HardDisk2> &hardDisk() const { return m.hardDisk; }
101 StorageBus_T bus() const { return m.bus; }
102 LONG channel() const { return m.channel; }
103 LONG device() const { return m.device; }
104
105 /** Must be called from under this object's write lock. */
106 void updateHardDisk (const ComObjPtr <HardDisk2> &aHardDisk, bool aImplicit)
107 {
108 m.hardDisk = aHardDisk;
109 m.implicit = aImplicit;
110 }
111
112 /** For com::SupportErrorInfoImpl. */
113 static const char *ComponentName() { return "HardDisk2Attachment"; }
114
115private:
116
117 struct Data
118 {
119 Data() : bus (StorageBus_Null), channel (0), device (0)
120 , implicit (false) {}
121
122 /// @todo NEWMEDIA shouldn't it be constant too? It'd be nice to get
123 /// rid of locks at all in this simple readonly structure-like interface
124 ComObjPtr <HardDisk2> hardDisk;
125 const StorageBus_T bus;
126 const LONG channel;
127 const LONG device;
128
129 bool implicit : 1;
130 };
131
132 Data m;
133};
134
135#endif // ____H_HARDDISKATTACHMENTIMPL
136/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use