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

#pragma once

#include "HybridTextToSpeechSpec.hpp"

// Forward declaration of `HybridTextToSpeechSpec_cxx` to properly resolve imports.
namespace NitroTextToSpeech { class HybridTextToSpeechSpec_cxx; }

// Forward declaration of `TextToSpeechOptions` to properly resolve imports.
namespace margelo::nitro::nitrotexttospeech { struct TextToSpeechOptions; }
// Forward declaration of `TextToSpeechVoice` to properly resolve imports.
namespace margelo::nitro::nitrotexttospeech { struct TextToSpeechVoice; }
// Forward declaration of `EventName` to properly resolve imports.
namespace margelo::nitro::nitrotexttospeech { enum class EventName; }

#include <NitroModules/Promise.hpp>
#include <string>
#include <optional>
#include "TextToSpeechOptions.hpp"
#include <vector>
#include "TextToSpeechVoice.hpp"
#include <functional>
#include "EventName.hpp"

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

namespace margelo::nitro::nitrotexttospeech {

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

  public:
    // Get the Swift part
    inline NitroTextToSpeech::HybridTextToSpeechSpec_cxx getSwiftPart() noexcept { return _swiftPart; }

  public:
    // Get memory pressure
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline std::shared_ptr<Promise<void>> speak(const std::string& text, const std::optional<TextToSpeechOptions>& options) override {
      auto __result = _swiftPart.speak(text, options);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<bool>> 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<bool>> pause() override {
      auto __result = _swiftPart.pause();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<bool>> resume() override {
      auto __result = _swiftPart.resume();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::vector<TextToSpeechVoice>>> getVoices() override {
      auto __result = _swiftPart.getVoices();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::function<void()> addEventListener(EventName event, const std::function<void(const std::optional<std::string>& /* word */)>& listener) override {
      auto __result = _swiftPart.addEventListener(static_cast<int>(event), listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    NitroTextToSpeech::HybridTextToSpeechSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitrotexttospeech
