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

#pragma once

#include "HybridOneScreenCaptureSpec.hpp"

// Forward declaration of `HybridOneScreenCaptureSpec_cxx` to properly resolve imports.
namespace One { class HybridOneScreenCaptureSpec_cxx; }

// Forward declaration of `ScreenCaptureState` to properly resolve imports.
namespace margelo::nitro::one { enum class ScreenCaptureState; }
// Forward declaration of `ScreenCaptureResult` to properly resolve imports.
namespace margelo::nitro::one { struct ScreenCaptureResult; }

#include "ScreenCaptureState.hpp"
#include <NitroModules/Promise.hpp>
#include "ScreenCaptureResult.hpp"
#include <string>
#include <functional>

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

namespace margelo::nitro::one {

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

  public:
    // Get the Swift part
    inline One::HybridOneScreenCaptureSpec_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<HybridOneScreenCaptureSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline std::shared_ptr<Promise<ScreenCaptureState>> getState() override {
      auto __result = _swiftPart.getState();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<ScreenCaptureResult>> captureWindow() override {
      auto __result = _swiftPart.captureWindow();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<ScreenCaptureResult>> captureView(double viewTag) override {
      auto __result = _swiftPart.captureView(std::forward<decltype(viewTag)>(viewTag));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::function<void()> addStateListener(const std::function<void(ScreenCaptureState /* state */)>& onChange) override {
      auto __result = _swiftPart.addStateListener(onChange);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::function<void()> addScreenshotListener(const std::function<void(double /* timestampMs */)>& onScreenshot) override {
      auto __result = _swiftPart.addScreenshotListener(onScreenshot);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> prevent() override {
      auto __result = _swiftPart.prevent();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> allow() override {
      auto __result = _swiftPart.allow();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<bool>> isPrevented() override {
      auto __result = _swiftPart.isPrevented();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    One::HybridOneScreenCaptureSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::one
