| // Copyright 2024 Google LLC |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| #pragma once |
| extern "C" |
| { |
| #include "libhoth.h" |
| #include "libhoth_usb.h" |
| #include "libhoth_usb_device.h" |
| } |
| |
| #include "libusb.hpp" |
| |
| #include <memory> |
| |
| // NOLINTNEXTLINE(cert-dcl58-cpp) |
| namespace google |
| { |
| namespace hoth |
| { |
| class LibHothUsbIntf |
| { |
| public: |
| using option = libhoth_usb_device_init_options; |
| using device = libhoth_device; |
| virtual int open(const option* opt, device** dev) = 0; |
| virtual int send(device* dev, const void* request, size_t size) = 0; |
| virtual int recv(device* dev, void* response, size_t response_size, |
| size_t* actual_size, int timeout_ms) = 0; |
| virtual int close(device* dev) = 0; |
| virtual int claim(device* dev) = 0; |
| virtual int release(device* dev) = 0; |
| virtual ~LibHothUsbIntf() = default; |
| }; |
| |
| class LibHothUsbImpl : public LibHothUsbIntf |
| { |
| public: |
| int open(const option* opt, device** dev) override; |
| int send(device* dev, const void* request, size_t size) override; |
| int recv(device* dev, void* response, size_t response_size, |
| size_t* actual_size, int timeout_ms) override; |
| int close(device* dev) override; |
| int claim(device* dev) override; |
| int release(device* dev) override; |
| }; |
| |
| extern LibHothUsbImpl libhoth_usb; |
| |
| } // namespace hoth |
| } // namespace google |