VirtualBox

source: vbox/trunk/src/VBox/Main/include/USBDeviceImpl.h@ 4753

Last change on this file since 4753 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.6 KB
Line 
1/** @file
2 *
3 * VirtualBox COM class implementation
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_USBDEVICEIMPL
19#define ____H_USBDEVICEIMPL
20
21#include "VirtualBoxBase.h"
22#include "Collection.h"
23
24
25/**
26 * Object class used for maintaining devices attached to a USB controller.
27 * Generally this contains much less information.
28 */
29class ATL_NO_VTABLE OUSBDevice :
30 public VirtualBoxSupportErrorInfoImpl<OUSBDevice, IUSBDevice>,
31 public VirtualBoxSupportTranslation<OUSBDevice>,
32 public VirtualBoxBase,
33 public IUSBDevice
34{
35public:
36
37 OUSBDevice();
38 virtual ~OUSBDevice();
39
40 DECLARE_NOT_AGGREGATABLE(OUSBDevice)
41
42 DECLARE_PROTECT_FINAL_CONSTRUCT()
43
44 BEGIN_COM_MAP(OUSBDevice)
45 COM_INTERFACE_ENTRY(ISupportErrorInfo)
46 COM_INTERFACE_ENTRY(IUSBDevice)
47 END_COM_MAP()
48
49 NS_DECL_ISUPPORTS
50
51 // public initializer/uninitializer for internal purposes only
52 HRESULT init(IUSBDevice *a_pUSBDevice);
53
54 // IUSBDevice properties
55 STDMETHOD(COMGETTER(Id))(GUIDPARAMOUT aId);
56 STDMETHOD(COMGETTER(VendorId))(USHORT *aVendorId);
57 STDMETHOD(COMGETTER(ProductId))(USHORT *aProductId);
58 STDMETHOD(COMGETTER(Revision))(USHORT *aRevision);
59 STDMETHOD(COMGETTER(Manufacturer))(BSTR *aManufacturer);
60 STDMETHOD(COMGETTER(Product))(BSTR *aProduct);
61 STDMETHOD(COMGETTER(SerialNumber))(BSTR *aSerialNumber);
62 STDMETHOD(COMGETTER(Address))(BSTR *aAddress);
63 STDMETHOD(COMGETTER(Port))(USHORT *aPort);
64 STDMETHOD(COMGETTER(Remote))(BOOL *aRemote);
65
66 // public methods only for internal purposes
67 const Guid &id() { return mId; }
68
69 // for VirtualBoxSupportErrorInfoImpl
70 static const wchar_t *getComponentName() { return L"USBDevice"; }
71
72private:
73 /** The UUID of this device. */
74 Guid mId;
75
76 /** The vendor id of this USB device. */
77 USHORT mVendorId;
78 /** The product id of this USB device. */
79 USHORT mProductId;
80 /** The product revision number of this USB device.
81 * (high byte = integer; low byte = decimal) */
82 USHORT mRevision;
83 /** The Manufacturer string. (Quite possibly NULL.) */
84 Bstr mManufacturer;
85 /** The Product string. (Quite possibly NULL.) */
86 Bstr mProduct;
87 /** The SerialNumber string. (Quite possibly NULL.) */
88 Bstr mSerialNumber;
89 /** The host specific address of the device. */
90 Bstr mAddress;
91
92 USHORT mPort;
93 BOOL mRemote;
94};
95
96COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_BEGIN (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
97
98 STDMETHOD(FindById) (INPTR GUIDPARAM aId, IUSBDevice **aDevice)
99 {
100 Guid idToFind = aId;
101 if (idToFind.isEmpty())
102 return E_INVALIDARG;
103 if (!aDevice)
104 return E_POINTER;
105
106 *aDevice = NULL;
107 Vector::value_type found;
108 Vector::iterator it = vec.begin();
109 while (!found && it != vec.end())
110 {
111 Guid id;
112 (*it)->COMGETTER(Id) (id.asOutParam());
113 if (id == idToFind)
114 found = *it;
115 ++ it;
116 }
117
118 if (!found)
119 return setError (E_INVALIDARG, OUSBDeviceCollection::tr (
120 "Could not find a USB device with UUID {%s}"),
121 idToFind.toString().raw());
122
123 return found.queryInterfaceTo (aDevice);
124 }
125
126 STDMETHOD(FindByAddress) (INPTR BSTR aAddress, IUSBDevice **aDevice)
127 {
128 if (!aAddress)
129 return E_INVALIDARG;
130 if (!aDevice)
131 return E_POINTER;
132
133 *aDevice = NULL;
134 Vector::value_type found;
135 Vector::iterator it = vec.begin();
136 while (!found && it != vec.end())
137 {
138 Bstr address;
139 (*it)->COMGETTER(Address) (address.asOutParam());
140 if (address == aAddress)
141 found = *it;
142 ++ it;
143 }
144
145 if (!found)
146 return setError (E_INVALIDARG, OUSBDeviceCollection::tr (
147 "Could not find a USB device with address '%ls'"),
148 aAddress);
149
150 return found.queryInterfaceTo (aDevice);
151 }
152
153COM_DECL_READONLY_ENUM_AND_COLLECTION_EX_END (ComObjPtr <OUSBDevice>, IUSBDevice, OUSBDevice)
154
155#endif // ____H_USBDEVICEIMPL
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