summaryrefslogtreecommitdiffstats
path: root/qdb/server/usb-host/usbdevice.h
blob: e44d3f3acc13ff365c589cdad37937b573e4b195 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
/******************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** This file is part of the Qt Debug Bridge.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
******************************************************************************/
#ifndef USBDEVICE_H
#define USBDEVICE_H

#include "usbcommon.h"

#include <QtCore/qstring.h>

#include <cstdint>
#include <memory>

struct libusb_device;

// Class that wraps the libusb reference count incrementing and decrementing for
// a libusb_device
class LibUsbDevice {
public:
    LibUsbDevice();
    LibUsbDevice(libusb_device *device);
    LibUsbDevice(const LibUsbDevice &rhs);
    LibUsbDevice(LibUsbDevice&& rhs);
    ~LibUsbDevice();

    LibUsbDevice &operator=(const LibUsbDevice &rhs);

    libusb_device *pointer();

private:
    libusb_device *m_device;
};

struct UsbAddress
{
    uint8_t busNumber;
    uint8_t deviceAddress;
};

bool operator<(const UsbAddress &lhs, const UsbAddress &rhs);
bool operator==(const UsbAddress &lhs, const UsbAddress &rhs);

struct UsbDevice
{
    QString serial;
    UsbAddress address;
    LibUsbDevice usbDevice;
    UsbInterfaceInfo interfaceInfo;
};

#endif // USBDEVICE_H