VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBControllerImpl.h@ 14959

Last change on this file since 14959 was 14949, checked in by vboxsync, 16 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: 5.4 KB
Line 
1/* $Id: USBControllerImpl.h 14949 2008-12-03 15:17:16Z vboxsync $ */
2
3/** @file
4 *
5 * VBox USBController COM Class declaration.
6 */
7
8/*
9 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
10 *
11 * This file is part of VirtualBox Open Source Edition (OSE), as
12 * available from http://www.virtualbox.org. This file is free software;
13 * you can redistribute it and/or modify it under the terms of the GNU
14 * General Public License (GPL) as published by the Free Software
15 * Foundation, in version 2 as it comes in the "COPYING" file of the
16 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
20 * Clara, CA 95054 USA or visit http://www.sun.com if you need
21 * additional information or have any questions.
22 */
23
24#ifndef ____H_USBCONTROLLERIMPL
25#define ____H_USBCONTROLLERIMPL
26
27#include "VirtualBoxBase.h"
28#ifdef VBOX_WITH_USB
29# include "USBDeviceFilterImpl.h"
30#endif
31
32#include <list>
33
34class Machine;
35class HostUSBDevice;
36
37/**
38 * @note we cannot use VirtualBoxBaseWithTypedChildren <USBDeviceFilter> as a
39 * base class, because we want a quick (map-based) way of validating
40 * IUSBDeviceFilter pointers passed from outside as method parameters that
41 * VirtualBoxBaseWithChildren::getDependentChild() gives us.
42 */
43
44class ATL_NO_VTABLE USBController :
45 public VirtualBoxBaseWithChildrenNEXT,
46 public VirtualBoxSupportErrorInfoImpl <USBController, IUSBController>,
47 public VirtualBoxSupportTranslation <USBController>,
48 public IUSBController
49{
50private:
51
52 struct Data
53 {
54 /* Constructor. */
55 Data() : mEnabled (FALSE), mEnabledEhci (FALSE) { }
56
57 bool operator== (const Data &that) const
58 {
59 return this == &that || (mEnabled == that.mEnabled && mEnabledEhci == that.mEnabledEhci);
60 }
61
62 /** Enabled indicator. */
63 BOOL mEnabled;
64
65 /** Enabled indicator for EHCI. */
66 BOOL mEnabledEhci;
67 };
68
69public:
70
71 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
72
73 DECLARE_NOT_AGGREGATABLE (USBController)
74
75 DECLARE_PROTECT_FINAL_CONSTRUCT()
76
77 BEGIN_COM_MAP(USBController)
78 COM_INTERFACE_ENTRY (ISupportErrorInfo)
79 COM_INTERFACE_ENTRY (IUSBController)
80 END_COM_MAP()
81
82 NS_DECL_ISUPPORTS
83
84 DECLARE_EMPTY_CTOR_DTOR (USBController)
85
86 HRESULT FinalConstruct();
87 void FinalRelease();
88
89 // public initializer/uninitializer for internal purposes only
90 HRESULT init (Machine *aParent);
91 HRESULT init (Machine *aParent, USBController *aThat);
92 HRESULT initCopy (Machine *aParent, USBController *aThat);
93 void uninit();
94
95 // IUSBController properties
96 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
97 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
98 STDMETHOD(COMGETTER(EnabledEhci)) (BOOL *aEnabled);
99 STDMETHOD(COMSETTER(EnabledEhci)) (BOOL aEnabled);
100 STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
101 STDMETHOD(COMGETTER(DeviceFilters)) (IUSBDeviceFilterCollection **aDevicesFilters);
102
103 // IUSBController methods
104 STDMETHOD(CreateDeviceFilter) (INPTR BSTR aName, IUSBDeviceFilter **aFilter);
105 STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
106 STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
107
108 // public methods only for internal purposes
109
110 HRESULT loadSettings (const settings::Key &aMachineNode);
111 HRESULT saveSettings (settings::Key &aMachineNode);
112
113 bool isModified();
114 bool isReallyModified();
115 bool rollback();
116 void commit();
117 void copyFrom (USBController *aThat);
118
119 HRESULT onMachineRegistered (BOOL aRegistered);
120
121#ifdef VBOX_WITH_USB
122 HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
123 BOOL aActiveChanged = FALSE);
124
125 bool hasMatchingFilter (const ComObjPtr <HostUSBDevice> &aDevice, ULONG *aMaskedIfs);
126 bool hasMatchingFilter (IUSBDevice *aUSBDevice, ULONG *aMaskedIfs);
127
128 HRESULT notifyProxy (bool aInsertFilters);
129#endif /* VBOX_WITH_USB */
130
131 // public methods for internal purposes only
132 // (ensure there is a caller and a read lock before calling them!)
133
134 /** @note this doesn't require a read lock since mParent is constant. */
135 const ComObjPtr <Machine, ComWeakRef> &parent() { return mParent; };
136
137 const Backupable<Data> &data() { return mData; }
138
139 // for VirtualBoxSupportErrorInfoImpl
140 static const wchar_t *getComponentName() { return L"USBController"; }
141
142private:
143
144#ifdef VBOX_WITH_USB
145 /** specialization for IUSBDeviceFilter */
146 ComObjPtr <USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
147 {
148 VirtualBoxBase *child = VirtualBoxBaseWithChildrenNEXT::
149 getDependentChild (ComPtr <IUnknown> (aFilter));
150 return child ? static_cast <USBDeviceFilter *> (child)
151 : NULL;
152 }
153#endif /* VBOX_WITH_USB */
154
155 void printList();
156
157 /** Parent object. */
158 const ComObjPtr<Machine, ComWeakRef> mParent;
159 /** Peer object. */
160 const ComObjPtr <USBController> mPeer;
161 /** Data. */
162 Backupable <Data> mData;
163
164#ifdef VBOX_WITH_USB
165 // the following fields need special backup/rollback/commit handling,
166 // so they cannot be a part of Data
167
168 typedef std::list <ComObjPtr <USBDeviceFilter> > DeviceFilterList;
169 Backupable <DeviceFilterList> mDeviceFilters;
170#endif /* VBOX_WITH_USB */
171};
172
173#endif //!____H_USBCONTROLLERIMPL
174/* 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