Debian Codegraph @

mtp/backend/haiku/usb/Interface.h

raw
1 /*
2 This file is part of Android File Transfer For Linux.
3 Copyright (C) 2015-2020 Vladimir Menshakov
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License,
8 or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this library; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 #ifndef AFTL_MTP_BACKEND_LIBUSB_USB_INTERFACE_H
21 #define AFTL_MTP_BACKEND_LIBUSB_USB_INTERFACE_H
22
23 #include <mtp/types.h>
24 #include <usb/Device.h>
25
26 namespace mtp { namespace usb
27 {
28
29 class Configuration;
30 DECLARE_PTR(Configuration);
31
32 class InterfaceToken : public IToken
33 {
34 BUSBDevice * _handle;
35 int _index;
36
37 public:
38 InterfaceToken(BUSBDevice *handle, int index);
39 ~InterfaceToken();
40 };
41 DECLARE_PTR(InterfaceToken);
42
43 class Interface
44 {
45 DevicePtr _device;
46 ConfigurationPtr _config;
47 const BUSBInterface & _interface;
48
49 public:
50 Interface(DevicePtr device, ConfigurationPtr config, const BUSBInterface &interface): _device(device), _config(config), _interface(interface) { }
51
52 u8 GetClass() const
53 { return _interface.Class(); }
54
55 u8 GetSubclass() const
56 { return _interface.Subclass(); }
57
58 int GetIndex() const
59 { return _interface.Index(); }
60
61 EndpointPtr GetEndpoint(int idx) const
62 { return std::make_shared<Endpoint>(*_interface.EndpointAt(idx)); }
63
64 int GetEndpointsCount() const
65 { return _interface.CountEndpoints(); }
66
67 std::string GetName() const
68 { return _interface.InterfaceString(); }
69 };
70 DECLARE_PTR(Interface);
71
72 }}
73
74 #endif