///
/// HybridNativeBleNitroSpecSwift.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include "HybridNativeBleNitroSpec.hpp"

// Forward declaration of `HybridNativeBleNitroSpec_cxx` to properly resolve imports.
namespace BleNitro { class HybridNativeBleNitroSpec_cxx; }

// Forward declaration of `BLEDevice` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
// Forward declaration of `ManufacturerData` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
// Forward declaration of `ManufacturerDataEntry` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
namespace NitroModules { class ArrayBufferHolder; }
// Forward declaration of `ServiceData` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ServiceData; }
// Forward declaration of `ServiceDataEntry` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ServiceDataEntry; }
// Forward declaration of `ScanFilter` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
// Forward declaration of `AndroidScanMode` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
// Forward declaration of `AndroidConnectionPriority` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { enum class AndroidConnectionPriority; }
// Forward declaration of `BLEState` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { enum class BLEState; }
// Forward declaration of `OperationResult` to properly resolve imports.
namespace margelo::nitro::co::zyke::ble { struct OperationResult; }

#include <string>
#include <optional>
#include "BLEDevice.hpp"
#include <vector>
#include <functional>
#include "ManufacturerData.hpp"
#include "ManufacturerDataEntry.hpp"
#include <NitroModules/ArrayBuffer.hpp>
#include <NitroModules/ArrayBufferHolder.hpp>
#include "ServiceData.hpp"
#include "ServiceDataEntry.hpp"
#include "ScanFilter.hpp"
#include "AndroidScanMode.hpp"
#include <NitroModules/Null.hpp>
#include <variant>
#include "AndroidConnectionPriority.hpp"
#include "BLEState.hpp"
#include "OperationResult.hpp"
#include <NitroModules/Promise.hpp>

#include "BleNitro-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::co::zyke::ble {

  /**
   * The C++ part of HybridNativeBleNitroSpec_cxx.swift.
   *
   * HybridNativeBleNitroSpecSwift (C++) accesses HybridNativeBleNitroSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridNativeBleNitroSpec_cxx can directly inherit from the C++ class HybridNativeBleNitroSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNativeBleNitroSpecSwift: public virtual HybridNativeBleNitroSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNativeBleNitroSpecSwift(const BleNitro::HybridNativeBleNitroSpec_cxx& swiftPart):
      HybridObject(HybridNativeBleNitroSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline BleNitro::HybridNativeBleNitroSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    bool equals(const std::shared_ptr<HybridObject>& other) override {
      if (auto otherCast = std::dynamic_pointer_cast<HybridNativeBleNitroSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    inline std::optional<std::string> getRestoreStateIdentifier() noexcept override {
      auto __result = _swiftPart.getRestoreStateIdentifier();
      return __result;
    }
    inline void setRestoreStateIdentifier(const std::optional<std::string>& restoreStateIdentifier) noexcept override {
      _swiftPart.setRestoreStateIdentifier(restoreStateIdentifier);
    }

  public:
    // Methods
    inline void setRestoreStateCallback(const std::function<void(const std::vector<BLEDevice>& /* restoredPeripherals */)>& callback) override {
      auto __result = _swiftPart.setRestoreStateCallback(callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void iosLazyInit() override {
      auto __result = _swiftPart.iosLazyInit();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void startScan(const ScanFilter& filter, const std::function<void(const std::optional<std::variant<nitro::NullType, BLEDevice>>& /* device */, const std::optional<std::variant<nitro::NullType, std::string>>& /* error */)>& callback) override {
      auto __result = _swiftPart.startScan(std::forward<decltype(filter)>(filter), callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline bool stopScan() override {
      auto __result = _swiftPart.stopScan();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline bool isScanning() override {
      auto __result = _swiftPart.isScanning();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::vector<BLEDevice> getConnectedDevices(const std::vector<std::string>& services) override {
      auto __result = _swiftPart.getConnectedDevices(services);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void connect(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>& callback, const std::optional<std::function<void(const std::string& /* deviceId */, bool /* interrupted */, const std::string& /* error */)>>& disconnectCallback, std::optional<bool> autoConnectAndroid) override {
      auto __result = _swiftPart.connect(deviceId, callback, disconnectCallback, autoConnectAndroid);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void disconnect(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.disconnect(deviceId, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline bool isConnected(const std::string& deviceId) override {
      auto __result = _swiftPart.isConnected(deviceId);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double requestMTU(const std::string& deviceId, double mtu) override {
      auto __result = _swiftPart.requestMTU(deviceId, std::forward<decltype(mtu)>(mtu));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline bool requestConnectionPriority(const std::string& deviceId, AndroidConnectionPriority androidConnectionPriority) override {
      auto __result = _swiftPart.requestConnectionPriority(deviceId, static_cast<int>(androidConnectionPriority));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void readRSSI(const std::string& deviceId, const std::function<void(bool /* success */, double /* rssi */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.readRSSI(deviceId, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void discoverServices(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.discoverServices(deviceId, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void discoverServicesWithCharacteristics(const std::string& deviceId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.discoverServicesWithCharacteristics(deviceId, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::vector<std::string> getServices(const std::string& deviceId) override {
      auto __result = _swiftPart.getServices(deviceId);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::vector<std::string> getCharacteristics(const std::string& deviceId, const std::string& serviceId) override {
      auto __result = _swiftPart.getCharacteristics(deviceId, serviceId);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void readCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.readCharacteristic(deviceId, serviceId, characteristicId, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void writeCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::shared_ptr<ArrayBuffer>& data, bool withResponse, const std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* responseData */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.writeCharacteristic(deviceId, serviceId, characteristicId, ArrayBufferHolder(data), std::forward<decltype(withResponse)>(withResponse), callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void subscribeToCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>& updateCallback, const std::function<void(bool /* success */, const std::string& /* error */)>& completionCallback) override {
      auto __result = _swiftPart.subscribeToCharacteristic(deviceId, serviceId, characteristicId, updateCallback, completionCallback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void unsubscribeFromCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId, const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.unsubscribeFromCharacteristic(deviceId, serviceId, characteristicId, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline bool isSubscribedToCharacteristic(const std::string& deviceId, const std::string& serviceId, const std::string& characteristicId) override {
      auto __result = _swiftPart.isSubscribedToCharacteristic(deviceId, serviceId, characteristicId);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void requestBluetoothEnable(const std::function<void(bool /* success */, const std::string& /* error */)>& callback) override {
      auto __result = _swiftPart.requestBluetoothEnable(callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline BLEState state() override {
      auto __result = _swiftPart.state();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline OperationResult subscribeToStateChange(const std::function<void(BLEState /* state */)>& stateCallback) override {
      auto __result = _swiftPart.subscribeToStateChange(stateCallback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline OperationResult unsubscribeFromStateChange() override {
      auto __result = _swiftPart.unsubscribeFromStateChange();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> openSettings() override {
      auto __result = _swiftPart.openSettings();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    BleNitro::HybridNativeBleNitroSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::co::zyke::ble
