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

#pragma once

#include "HybridClarionAzureSpec.hpp"

// Forward declaration of `HybridClarionAzureSpec_cxx` to properly resolve imports.
namespace ClarionAzure { class HybridClarionAzureSpec_cxx; }

// Forward declaration of `NativeAzureConfig` to properly resolve imports.
namespace margelo::nitro::clarion::azure { struct NativeAzureConfig; }
// Forward declaration of `NativeTranscriptResult` to properly resolve imports.
namespace margelo::nitro::clarion::azure { struct NativeTranscriptResult; }
// Forward declaration of `NativeTranscriptSegment` to properly resolve imports.
namespace margelo::nitro::clarion::azure { struct NativeTranscriptSegment; }
// Forward declaration of `NativeAzureError` to properly resolve imports.
namespace margelo::nitro::clarion::azure { struct NativeAzureError; }

#include <string>
#include <NitroModules/Promise.hpp>
#include "NativeAzureConfig.hpp"
#include "NativeTranscriptResult.hpp"
#include "NativeTranscriptSegment.hpp"
#include <vector>
#include <functional>
#include "NativeAzureError.hpp"

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

namespace margelo::nitro::clarion::azure {

  /**
   * The C++ part of HybridClarionAzureSpec_cxx.swift.
   *
   * HybridClarionAzureSpecSwift (C++) accesses HybridClarionAzureSpec_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, HybridClarionAzureSpec_cxx can directly inherit from the C++ class HybridClarionAzureSpec
   * to simplify the whole structure and memory management.
   */
  class HybridClarionAzureSpecSwift: public virtual HybridClarionAzureSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridClarionAzureSpecSwift(const ClarionAzure::HybridClarionAzureSpec_cxx& swiftPart):
      HybridObject(HybridClarionAzureSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline ClarionAzure::HybridClarionAzureSpec_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<HybridClarionAzureSpecSwift>(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::string getState() noexcept override {
      auto __result = _swiftPart.getState();
      return __result;
    }

  public:
    // Methods
    inline std::shared_ptr<Promise<bool>> isAvailable(const NativeAzureConfig& config) override {
      auto __result = _swiftPart.isAvailable(std::forward<decltype(config)>(config));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> prepare(const NativeAzureConfig& config) override {
      auto __result = _swiftPart.prepare(std::forward<decltype(config)>(config));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> start() override {
      auto __result = _swiftPart.start();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<NativeTranscriptResult>> stop() override {
      auto __result = _swiftPart.stop();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> discard() override {
      auto __result = _swiftPart.discard();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> release() override {
      auto __result = _swiftPart.release();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> updateAuthToken(const std::string& token) override {
      auto __result = _swiftPart.updateAuthToken(token);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double addStateListener(const std::function<void(const std::string& /* state */)>& listener) override {
      auto __result = _swiftPart.addStateListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double addAudioLevelListener(const std::function<void(double /* rms */, double /* peak */)>& listener) override {
      auto __result = _swiftPart.addAudioLevelListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double addPartialListener(const std::function<void(const NativeTranscriptResult& /* result */)>& listener) override {
      auto __result = _swiftPart.addPartialListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double addFinalListener(const std::function<void(const NativeTranscriptResult& /* result */)>& listener) override {
      auto __result = _swiftPart.addFinalListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double addErrorListener(const std::function<void(const NativeAzureError& /* error */)>& listener) override {
      auto __result = _swiftPart.addErrorListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double addSpeechBoundaryListener(const std::function<void(const std::string& /* kind */, double /* offsetMs */)>& listener) override {
      auto __result = _swiftPart.addSpeechBoundaryListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void removeListener(double id) override {
      auto __result = _swiftPart.removeListener(std::forward<decltype(id)>(id));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void removeAllListeners() override {
      auto __result = _swiftPart.removeAllListeners();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    ClarionAzure::HybridClarionAzureSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::clarion::azure
