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

#include "JHybridCameraDepthFrameOutputSpec.hpp"

// Forward declaration of `HybridNativeThreadSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridNativeThreadSpec; }
// Forward declaration of `HybridDepthSpec` to properly resolve imports.
namespace margelo::nitro::camera { class HybridDepthSpec; }
// Forward declaration of `FrameDroppedReason` to properly resolve imports.
namespace margelo::nitro::camera { enum class FrameDroppedReason; }
// Forward declaration of `MediaType` to properly resolve imports.
namespace margelo::nitro::camera { enum class MediaType; }
// Forward declaration of `CameraOrientation` to properly resolve imports.
namespace margelo::nitro::camera { enum class CameraOrientation; }
// Forward declaration of `Size` to properly resolve imports.
namespace margelo::nitro::camera { struct Size; }

#include <memory>
#include "HybridNativeThreadSpec.hpp"
#include "JHybridNativeThreadSpec.hpp"
#include "HybridDepthSpec.hpp"
#include <functional>
#include <optional>
#include "JFunc_bool_std__shared_ptr_HybridDepthSpec_.hpp"
#include <NitroModules/JNICallable.hpp>
#include "JHybridDepthSpec.hpp"
#include "FrameDroppedReason.hpp"
#include "JFunc_void_FrameDroppedReason.hpp"
#include "JFrameDroppedReason.hpp"
#include "MediaType.hpp"
#include "JMediaType.hpp"
#include "CameraOrientation.hpp"
#include "JCameraOrientation.hpp"
#include "Size.hpp"
#include "JSize.hpp"

namespace margelo::nitro::camera {

  std::shared_ptr<JHybridCameraDepthFrameOutputSpec> JHybridCameraDepthFrameOutputSpec::JavaPart::getJHybridCameraDepthFrameOutputSpec() {
    auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
    auto castHybridObject = std::dynamic_pointer_cast<JHybridCameraDepthFrameOutputSpec>(hybridObject);
    if (castHybridObject == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to downcast JHybridObject to JHybridCameraDepthFrameOutputSpec!");
    }
    return castHybridObject;
  }

  jni::local_ref<JHybridCameraDepthFrameOutputSpec::CxxPart::jhybriddata> JHybridCameraDepthFrameOutputSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
    return makeCxxInstance(jThis);
  }

  std::shared_ptr<JHybridObject> JHybridCameraDepthFrameOutputSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
    auto castJavaPart = jni::dynamic_ref_cast<JHybridCameraDepthFrameOutputSpec::JavaPart>(javaPart);
    if (castJavaPart == nullptr) [[unlikely]] {
      throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridCameraDepthFrameOutputSpec::JavaPart!");
    }
    return std::make_shared<JHybridCameraDepthFrameOutputSpec>(castJavaPart);
  }

  void JHybridCameraDepthFrameOutputSpec::CxxPart::registerNatives() {
    registerHybrid({
      makeNativeMethod("initHybrid", JHybridCameraDepthFrameOutputSpec::CxxPart::initHybrid),
    });
  }

  // Properties
  std::shared_ptr<HybridNativeThreadSpec> JHybridCameraDepthFrameOutputSpec::getThread() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JHybridNativeThreadSpec::JavaPart>()>("getThread");
    auto __result = method(_javaPart);
    return __result->getJHybridNativeThreadSpec();
  }
  MediaType JHybridCameraDepthFrameOutputSpec::getMediaType() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JMediaType>()>("getMediaType");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  CameraOrientation JHybridCameraDepthFrameOutputSpec::getOutputOrientation() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JCameraOrientation>()>("getOutputOrientation");
    auto __result = method(_javaPart);
    return __result->toCpp();
  }
  void JHybridCameraDepthFrameOutputSpec::setOutputOrientation(CameraOrientation outputOrientation) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JCameraOrientation> /* outputOrientation */)>("setOutputOrientation");
    method(_javaPart, JCameraOrientation::fromCpp(outputOrientation));
  }
  std::optional<Size> JHybridCameraDepthFrameOutputSpec::getCurrentResolution() {
    static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSize>()>("getCurrentResolution");
    auto __result = method(_javaPart);
    return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
  }

  // Methods
  void JHybridCameraDepthFrameOutputSpec::setOnDepthFrameCallback(const std::optional<std::function<bool(const std::shared_ptr<HybridDepthSpec>& /* depth */)>>& onDepthFrame) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_bool_std__shared_ptr_HybridDepthSpec_::javaobject> /* onDepthFrame */)>("setOnDepthFrameCallback_cxx");
    method(_javaPart, onDepthFrame.has_value() ? JFunc_bool_std__shared_ptr_HybridDepthSpec__cxx::fromCpp(onDepthFrame.value()) : nullptr);
  }
  void JHybridCameraDepthFrameOutputSpec::setOnDepthFrameDroppedCallback(const std::optional<std::function<void(FrameDroppedReason /* reason */)>>& onDepthFrameDropped) {
    static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_FrameDroppedReason::javaobject> /* onDepthFrameDropped */)>("setOnDepthFrameDroppedCallback_cxx");
    method(_javaPart, onDepthFrameDropped.has_value() ? JFunc_void_FrameDroppedReason_cxx::fromCpp(onDepthFrameDropped.value()) : nullptr);
  }

} // namespace margelo::nitro::camera
