co_usb
Loading...
Searching...
No Matches
interface.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "co_usb/raii.hpp"
4#include <boost/capy/io_result.hpp>
5#include <libusb-1.0/libusb.h>
6
7namespace co_usb
8{
9
10struct interface;
11
18{
19 static boost::capy::io_result<interface> claim(libusb_device_handle *devh,
20 int iface_num) noexcept;
21 static boost::capy::io_result<interface> claim(unique_dev_handle &devh, int iface_num) noexcept;
22
23 libusb_device_handle *dev() const noexcept;
24 int number() const noexcept;
25
29 void release() const noexcept;
30
31 private:
33
34 std::shared_ptr<libusb_device_handle> m_devh;
35 int m_iface_num;
36};
37
38} // namespace co_usb
Definition context.hpp:14
std::unique_ptr< libusb_device_handle, dev_handle_deleter_t > unique_dev_handle
Definition raii.hpp:19
use_service
Definition context.hpp:17
RAII wrapper than claims interface on ctor and releases on dtor.
Definition interface.hpp:18
void release() const noexcept
Releases the interface and attaches the driver if was detached.
Definition interface.cpp:31
static boost::capy::io_result< interface > claim(libusb_device_handle *devh, int iface_num) noexcept
Definition interface.cpp:12
int number() const noexcept
Definition interface.cpp:42
libusb_device_handle * dev() const noexcept
Definition interface.cpp:37