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

#pragma once

#include "HybridRecorderSpec.hpp"

// Forward declaration of `HybridRecorderSpec_cxx` to properly resolve imports.
namespace VisionCamera { class HybridRecorderSpec_cxx; }

// Forward declaration of `RecordingFinishedReason` to properly resolve imports.
namespace margelo::nitro::camera { enum class RecordingFinishedReason; }

#include <string>
#include <NitroModules/Promise.hpp>
#include "RecordingFinishedReason.hpp"
#include <functional>
#include <exception>
#include <optional>

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

namespace margelo::nitro::camera {

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

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

  public:
    // Properties
    inline bool getIsRecording() noexcept override {
      return _swiftPart.isRecording();
    }
    inline bool getIsPaused() noexcept override {
      return _swiftPart.isPaused();
    }
    inline double getRecordedDuration() noexcept override {
      return _swiftPart.getRecordedDuration();
    }
    inline double getRecordedFileSize() noexcept override {
      return _swiftPart.getRecordedFileSize();
    }
    inline std::string getFilePath() noexcept override {
      auto __result = _swiftPart.getFilePath();
      return __result;
    }

  public:
    // Methods
    inline std::shared_ptr<Promise<void>> startRecording(const std::function<void(const std::string& /* filePath */, RecordingFinishedReason /* reason */)>& onRecordingFinished, const std::function<void(const std::exception_ptr& /* error */)>& onRecordingError, const std::optional<std::function<void()>>& onRecordingPaused, const std::optional<std::function<void()>>& onRecordingResumed) override {
      auto __result = _swiftPart.startRecording(onRecordingFinished, onRecordingError, onRecordingPaused, onRecordingResumed);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> stopRecording() override {
      auto __result = _swiftPart.stopRecording();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> pauseRecording() override {
      auto __result = _swiftPart.pauseRecording();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> resumeRecording() override {
      auto __result = _swiftPart.resumeRecording();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> cancelRecording() override {
      auto __result = _swiftPart.cancelRecording();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    VisionCamera::HybridRecorderSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::camera
