VirtualBox

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

Last change on this file since 3340 was 2981, checked in by vboxsync, 18 years ago

InnoTek -> innotek: all the headers and comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/** @file
2 *
3 * VBox USBController COM Class declaration.
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_USBCONTROLLERIMPL
23#define ____H_USBCONTROLLERIMPL
24
25#include "VirtualBoxBase.h"
26#include "USBDeviceFilterImpl.h"
27
28#include <VBox/cfgldr.h>
29
30#include <list>
31
32class Machine;
33class HostUSBDevice;
34
35/**
36 * @note we cannot use VirtualBoxBaseWithTypedChildren <USBDeviceFilter> as a
37 * base class, because we want a quick (map-based) way of validating
38 * IUSBDeviceFilter pointers passed from outside as method parameters that
39 * VirtualBoxBaseWithChildren::getDependentChild() gives us.
40 */
41
42class ATL_NO_VTABLE USBController :
43 public VirtualBoxBaseWithChildrenNEXT,
44 public VirtualBoxSupportErrorInfoImpl <USBController, IUSBController>,
45 public VirtualBoxSupportTranslation <USBController>,
46 public IUSBController
47{
48private:
49
50 struct Data
51 {
52 /* Constructor. */
53 Data() : mEnabled (FALSE) { }
54
55 bool operator== (const Data &that) const
56 {
57 return this == &that || mEnabled == that.mEnabled;
58 }
59
60 /** Enabled indicator. */
61 BOOL mEnabled;
62 };
63
64public:
65
66 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
67
68 DECLARE_NOT_AGGREGATABLE (USBController)
69
70 DECLARE_PROTECT_FINAL_CONSTRUCT()
71
72 BEGIN_COM_MAP(USBController)
73 COM_INTERFACE_ENTRY (ISupportErrorInfo)
74 COM_INTERFACE_ENTRY (IUSBController)
75 END_COM_MAP()
76
77 NS_DECL_ISUPPORTS
78
79 DECLARE_EMPTY_CTOR_DTOR (USBController)
80
81 HRESULT FinalConstruct();
82 void FinalRelease();
83
84 // public initializer/uninitializer for internal purposes only
85 HRESULT init (Machine *aParent);
86 HRESULT init (Machine *aParent, USBController *aThat);
87 HRESULT initCopy (Machine *aParent, USBController *aThat);
88 void uninit();
89
90 // IUSBController properties
91 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
92 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
93 STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
94 STDMETHOD(COMGETTER(DeviceFilters)) (IUSBDeviceFilterCollection **aDevicesFilters);
95
96 // IUSBController methods
97 STDMETHOD(CreateDeviceFilter) (INPTR BSTR aName, IUSBDeviceFilter **aFilter);
98 STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
99 STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
100
101 // public methods only for internal purposes
102
103 const ComObjPtr <Machine, ComWeakRef> &parent() { return mParent; };
104
105 HRESULT loadSettings (CFGNODE aMachine);
106 HRESULT saveSettings (CFGNODE aMachine);
107
108 bool isModified();
109 bool isReallyModified();
110 bool rollback();
111 void commit();
112 void copyFrom (USBController *aThat);
113
114 const Backupable<Data> &data() { return mData; }
115
116 HRESULT onMachineRegistered (BOOL aRegistered);
117
118 HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
119 BOOL aActiveChanged = FALSE);
120
121 bool hasMatchingFilter (ComObjPtr <HostUSBDevice> &aDevice);
122 bool hasMatchingFilter (IUSBDevice *aUSBDevice);
123
124 HRESULT notifyProxy (bool aInsertFilters);
125
126 // for VirtualBoxSupportErrorInfoImpl
127 static const wchar_t *getComponentName() { return L"USBController"; }
128
129private:
130
131 /** specialization for IUSBDeviceFilter */
132 ComObjPtr <USBDeviceFilter> getDependentChild (IUSBDeviceFilter *aFilter)
133 {
134 VirtualBoxBase *child = VirtualBoxBaseWithChildren::
135 getDependentChild (ComPtr <IUnknown> (aFilter));
136 return child ? static_cast <USBDeviceFilter *> (child)
137 : NULL;
138 }
139
140 void printList();
141
142 /** Parent object. */
143 const ComObjPtr<Machine, ComWeakRef> mParent;
144 /** Peer object. */
145 const ComObjPtr <USBController> mPeer;
146 /** Data. */
147 Backupable <Data> mData;
148
149 // the following fields need special backup/rollback/commit handling,
150 // so they cannot be a part of Data
151
152 typedef std::list <ComObjPtr <USBDeviceFilter> > DeviceFilterList;
153 Backupable <DeviceFilterList> mDeviceFilters;
154};
155
156#endif //!____H_USBCONTROLLERIMPL
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