VirtualBox

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

Last change on this file since 5546 was 4071, checked in by vboxsync, 17 years ago

Biggest check-in ever. New source code headers for all (C) innotek files.

  • 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
18#ifndef ____H_USBCONTROLLERIMPL
19#define ____H_USBCONTROLLERIMPL
20
21#include "VirtualBoxBase.h"
22#include "USBDeviceFilterImpl.h"
23
24#include <VBox/cfgldr.h>
25
26#include <list>
27
28class Machine;
29class HostUSBDevice;
30
31/**
32 * @note we cannot use VirtualBoxBaseWithTypedChildren <USBDeviceFilter> as a
33 * base class, because we want a quick (map-based) way of validating
34 * IUSBDeviceFilter pointers passed from outside as method parameters that
35 * VirtualBoxBaseWithChildren::getDependentChild() gives us.
36 */
37
38class ATL_NO_VTABLE USBController :
39 public VirtualBoxBaseWithChildrenNEXT,
40 public VirtualBoxSupportErrorInfoImpl <USBController, IUSBController>,
41 public VirtualBoxSupportTranslation <USBController>,
42 public IUSBController
43{
44private:
45
46 struct Data
47 {
48 /* Constructor. */
49 Data() : mEnabled (FALSE) { }
50
51 bool operator== (const Data &that) const
52 {
53 return this == &that || mEnabled == that.mEnabled;
54 }
55
56 /** Enabled indicator. */
57 BOOL mEnabled;
58 };
59
60public:
61
62 VIRTUALBOXBASE_ADD_ERRORINFO_SUPPORT (USBController)
63
64 DECLARE_NOT_AGGREGATABLE (USBController)
65
66 DECLARE_PROTECT_FINAL_CONSTRUCT()
67
68 BEGIN_COM_MAP(USBController)
69 COM_INTERFACE_ENTRY (ISupportErrorInfo)
70 COM_INTERFACE_ENTRY (IUSBController)
71 END_COM_MAP()
72
73 NS_DECL_ISUPPORTS
74
75 DECLARE_EMPTY_CTOR_DTOR (USBController)
76
77 HRESULT FinalConstruct();
78 void FinalRelease();
79
80 // public initializer/uninitializer for internal purposes only
81 HRESULT init (Machine *aParent);
82 HRESULT init (Machine *aParent, USBController *aThat);
83 HRESULT initCopy (Machine *aParent, USBController *aThat);
84 void uninit();
85
86 // IUSBController properties
87 STDMETHOD(COMGETTER(Enabled)) (BOOL *aEnabled);
88 STDMETHOD(COMSETTER(Enabled)) (BOOL aEnabled);
89 STDMETHOD(COMGETTER(USBStandard)) (USHORT *aUSBStandard);
90 STDMETHOD(COMGETTER(DeviceFilters)) (IUSBDeviceFilterCollection **aDevicesFilters);
91
92 // IUSBController methods
93 STDMETHOD(CreateDeviceFilter) (INPTR BSTR aName, IUSBDeviceFilter **aFilter);
94 STDMETHOD(InsertDeviceFilter) (ULONG aPosition, IUSBDeviceFilter *aFilter);
95 STDMETHOD(RemoveDeviceFilter) (ULONG aPosition, IUSBDeviceFilter **aFilter);
96
97 // public methods only for internal purposes
98
99 HRESULT loadSettings (CFGNODE aMachine);
100 HRESULT saveSettings (CFGNODE aMachine);
101
102 bool isModified();
103 bool isReallyModified();
104 bool rollback();
105 void commit();
106 void copyFrom (USBController *aThat);
107
108 HRESULT onMachineRegistered (BOOL aRegistered);
109
110 HRESULT onDeviceFilterChange (USBDeviceFilter *aFilter,
111 BOOL aActiveChanged = FALSE);
112
113 bool hasMatchingFilter (ComObjPtr <HostUSBDevice> &aDevice);
114 bool hasMatchingFilter (IUSBDevice *aUSBDevice);
115
116 HRESULT notifyProxy (bool aInsertFilters);
117
118 // public methods for internal purposes only
119 // (ensure there is a caller and a read lock before calling them!)
120
121 /** @note this doesn't require a read lock since mParent is constant. */
122 const ComObjPtr <Machine, ComWeakRef> &parent() { return mParent; };
123
124 const Backupable<Data> &data() { return mData; }
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