forked from charlieh0tel/google-libusb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglibusb_device_internal.h
55 lines (42 loc) · 1.81 KB
/
glibusb_device_internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2012 Google Inc. All Rights Reserved.
//
// Wrapper for libusb's device that implements the UsbDevice interface.
#ifndef _GLIBUSB_GLIBUSB_DEVICE_INTERNAL_H_
#define _GLIBUSB_GLIBUSB_DEVICE_INTERNAL_H_
#include <stdint.h>
#include <utility>
#include <boost/function.hpp>
#include "glibusb.h"
#include "glibusb_endpoint.h"
namespace glibusb {
// Provides an interface to an individual USB device.
class PhysicalUsbDevice : public UsbDevice {
public:
virtual ~PhysicalUsbDevice();
private:
friend class Libusb; // For private constructor.
// Constructs a device given the context and handle.
// Frees the handle on destruction.
PhysicalUsbDevice(struct libusb_context *context,
struct libusb_device_handle *handle);
typedef boost::function<bool(const struct libusb_endpoint_descriptor *)>
EndpointMatcher;
// Iterates through all the endpoint descriptors for this device
// and allocates and allocates a UsbEndpointType for the first
// endpoint for which the matcher returns true.
template <class UsbEndpointType>
UsbEndpointType *MatchEndpoint(EndpointMatcher matcher);
virtual bool DoSetAlternateSetting(int setting);
virtual UsbInEndpoint *DoFindInEndpoint(UsbEndpoint::TransferType endpoint);
virtual UsbOutEndpoint *DoFindOutEndpoint(UsbEndpoint::TransferType endpoint);
virtual UsbInEndpoint *DoInEndpoint(int number);
virtual UsbOutEndpoint *DoOutEndpoint(int number);
virtual struct DeviceLocationAndId DoDeviceLocationAndId();
// Libusb context and handle used to interact with libusb.
struct libusb_context *libusb_context_;
struct libusb_device_handle *device_handle_;
PhysicalUsbDevice(const PhysicalUsbDevice &) = delete;
void operator=(const PhysicalUsbDevice &) = delete;
};
} // namespace glibusb
#endif // _GLIBUSB_GLIBUSB_DEVICE_INTERNAL_H_