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

import NitroModules

/**
 * A class implementation that bridges HybridCameraDeviceSpec over to C++.
 * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
 *
 * Also, some Swift types need to be bridged with special handling:
 * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
 * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
 * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
 */
open class HybridCameraDeviceSpec_cxx {
  /**
   * The Swift <> C++ bridge's namespace (`margelo::nitro::camera::bridge::swift`)
   * from `VisionCamera-Swift-Cxx-Bridge.hpp`.
   * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
   */
  public typealias bridge = margelo.nitro.camera.bridge.swift

  /**
   * Holds an instance of the `HybridCameraDeviceSpec` Swift protocol.
   */
  private var __implementation: any HybridCameraDeviceSpec

  /**
   * Holds a weak pointer to the C++ class that wraps the Swift class.
   */
  private var __cxxPart: bridge.std__weak_ptr_HybridCameraDeviceSpec_

  /**
   * Create a new `HybridCameraDeviceSpec_cxx` that wraps the given `HybridCameraDeviceSpec`.
   * All properties and methods bridge to C++ types.
   */
  public init(_ implementation: any HybridCameraDeviceSpec) {
    self.__implementation = implementation
    self.__cxxPart = .init()
    /* no base class */
  }

  /**
   * Get the actual `HybridCameraDeviceSpec` instance this class wraps.
   */
  @inline(__always)
  public func getHybridCameraDeviceSpec() -> any HybridCameraDeviceSpec {
    return __implementation
  }

  /**
   * Casts this instance to a retained unsafe raw pointer.
   * This acquires one additional strong reference on the object!
   */
  public func toUnsafe() -> UnsafeMutableRawPointer {
    return Unmanaged.passRetained(self).toOpaque()
  }

  /**
   * Casts an unsafe pointer to a `HybridCameraDeviceSpec_cxx`.
   * The pointer has to be a retained opaque `Unmanaged<HybridCameraDeviceSpec_cxx>`.
   * This removes one strong reference from the object!
   */
  public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridCameraDeviceSpec_cxx {
    return Unmanaged<HybridCameraDeviceSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
  }

  /**
   * Gets (or creates) the C++ part of this Hybrid Object.
   * The C++ part is a `std::shared_ptr<HybridCameraDeviceSpec>`.
   */
  public func getCxxPart() -> bridge.std__shared_ptr_HybridCameraDeviceSpec_ {
    let cachedCxxPart = self.__cxxPart.lock()
    if Bool(fromCxx: cachedCxxPart) {
      return cachedCxxPart
    } else {
      let newCxxPart = bridge.create_std__shared_ptr_HybridCameraDeviceSpec_(self.toUnsafe())
      __cxxPart = bridge.weakify_std__shared_ptr_HybridCameraDeviceSpec_(newCxxPart)
      return newCxxPart
    }
  }

  

  /**
   * Get the memory size of the Swift class (plus size of any other allocations)
   * so the JS VM can properly track it and garbage-collect the JS object if needed.
   */
  @inline(__always)
  public var memorySize: Int {
    return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
  }

  /**
   * Compares this object with the given [other] object for reference equality.
   */
  @inline(__always)
  public func equals(other: HybridCameraDeviceSpec_cxx) -> Bool {
    return self.__implementation === other.__implementation
  }

  /**
   * Call dispose() on the Swift class.
   * This _may_ be called manually from JS.
   */
  @inline(__always)
  public func dispose() {
    self.__implementation.dispose()
  }

  /**
   * Call toString() on the Swift class.
   */
  @inline(__always)
  public func toString() -> String {
    return self.__implementation.toString()
  }

  // Properties
  public final var id: std.string {
    @inline(__always)
    get {
      return std.string(self.__implementation.id)
    }
  }
  
  public final var modelID: std.string {
    @inline(__always)
    get {
      return std.string(self.__implementation.modelID)
    }
  }
  
  public final var localizedName: std.string {
    @inline(__always)
    get {
      return std.string(self.__implementation.localizedName)
    }
  }
  
  public final var manufacturer: std.string {
    @inline(__always)
    get {
      return std.string(self.__implementation.manufacturer)
    }
  }
  
  public final var type: Int32 {
    @inline(__always)
    get {
      return self.__implementation.type.rawValue
    }
  }
  
  public final var position: Int32 {
    @inline(__always)
    get {
      return self.__implementation.position.rawValue
    }
  }
  
  public final var physicalDevices: bridge.std__vector_std__shared_ptr_HybridCameraDeviceSpec__ {
    @inline(__always)
    get {
      return { () -> bridge.std__vector_std__shared_ptr_HybridCameraDeviceSpec__ in
        var __vector = bridge.create_std__vector_std__shared_ptr_HybridCameraDeviceSpec__(self.__implementation.physicalDevices.count)
        for __item in self.__implementation.physicalDevices {
          __vector.push_back({ () -> bridge.std__shared_ptr_HybridCameraDeviceSpec_ in
            let __cxxWrapped = __item.getCxxWrapper()
            return __cxxWrapped.getCxxPart()
          }())
        }
        return __vector
      }()
    }
  }
  
  public final var isVirtualDevice: Bool {
    @inline(__always)
    get {
      return self.__implementation.isVirtualDevice
    }
  }
  
  public final var supportedPixelFormats: bridge.std__vector_PixelFormat_ {
    @inline(__always)
    get {
      return { () -> bridge.std__vector_PixelFormat_ in
        var __vector = bridge.create_std__vector_PixelFormat_(self.__implementation.supportedPixelFormats.count)
        for __item in self.__implementation.supportedPixelFormats {
          __vector.push_back(__item)
        }
        return __vector
      }()
    }
  }
  
  public final var supportsPhotoHDR: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsPhotoHDR
    }
  }
  
  public final var supportedVideoDynamicRanges: bridge.std__vector_DynamicRange_ {
    @inline(__always)
    get {
      return { () -> bridge.std__vector_DynamicRange_ in
        var __vector = bridge.create_std__vector_DynamicRange_(self.__implementation.supportedVideoDynamicRanges.count)
        for __item in self.__implementation.supportedVideoDynamicRanges {
          __vector.push_back(__item)
        }
        return __vector
      }()
    }
  }
  
  public final var supportedFPSRanges: bridge.std__vector_Range_ {
    @inline(__always)
    get {
      return { () -> bridge.std__vector_Range_ in
        var __vector = bridge.create_std__vector_Range_(self.__implementation.supportedFPSRanges.count)
        for __item in self.__implementation.supportedFPSRanges {
          __vector.push_back(__item)
        }
        return __vector
      }()
    }
  }
  
  public final var supportsPreviewImage: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsPreviewImage
    }
  }
  
  public final var supportsSpeedQualityPrioritization: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsSpeedQualityPrioritization
    }
  }
  
  public final var focalLength: bridge.std__optional_double_ {
    @inline(__always)
    get {
      return { () -> bridge.std__optional_double_ in
        if let __unwrappedValue = self.__implementation.focalLength {
          return bridge.create_std__optional_double_(__unwrappedValue)
        } else {
          return .init()
        }
      }()
    }
  }
  
  public final var lensAperture: Double {
    @inline(__always)
    get {
      return self.__implementation.lensAperture
    }
  }
  
  public final var isContinuityCamera: Bool {
    @inline(__always)
    get {
      return self.__implementation.isContinuityCamera
    }
  }
  
  public final var companionDeskViewCamera: bridge.std__optional_std__shared_ptr_HybridCameraDeviceSpec__ {
    @inline(__always)
    get {
      return { () -> bridge.std__optional_std__shared_ptr_HybridCameraDeviceSpec__ in
        if let __unwrappedValue = self.__implementation.companionDeskViewCamera {
          return bridge.create_std__optional_std__shared_ptr_HybridCameraDeviceSpec__({ () -> bridge.std__shared_ptr_HybridCameraDeviceSpec_ in
            let __cxxWrapped = __unwrappedValue.getCxxWrapper()
            return __cxxWrapped.getCxxPart()
          }())
        } else {
          return .init()
        }
      }()
    }
  }
  
  public final var mediaTypes: bridge.std__vector_MediaType_ {
    @inline(__always)
    get {
      return { () -> bridge.std__vector_MediaType_ in
        var __vector = bridge.create_std__vector_MediaType_(self.__implementation.mediaTypes.count)
        for __item in self.__implementation.mediaTypes {
          __vector.push_back(__item)
        }
        return __vector
      }()
    }
  }
  
  public final var supportsFocusMetering: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsFocusMetering
    }
  }
  
  public final var supportsFocusLocking: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsFocusLocking
    }
  }
  
  public final var supportsSmoothAutoFocus: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsSmoothAutoFocus
    }
  }
  
  public final var supportsExposureMetering: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsExposureMetering
    }
  }
  
  public final var supportsExposureLocking: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsExposureLocking
    }
  }
  
  public final var supportsExposureBias: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsExposureBias
    }
  }
  
  public final var minExposureBias: Double {
    @inline(__always)
    get {
      return self.__implementation.minExposureBias
    }
  }
  
  public final var maxExposureBias: Double {
    @inline(__always)
    get {
      return self.__implementation.maxExposureBias
    }
  }
  
  public final var supportsWhiteBalanceMetering: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsWhiteBalanceMetering
    }
  }
  
  public final var maxWhiteBalanceGain: Double {
    @inline(__always)
    get {
      return self.__implementation.maxWhiteBalanceGain
    }
  }
  
  public final var supportsWhiteBalanceLocking: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsWhiteBalanceLocking
    }
  }
  
  public final var hasFlash: Bool {
    @inline(__always)
    get {
      return self.__implementation.hasFlash
    }
  }
  
  public final var hasTorch: Bool {
    @inline(__always)
    get {
      return self.__implementation.hasTorch
    }
  }
  
  public final var supportsTorchStrength: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsTorchStrength
    }
  }
  
  public final var minTorchStrength: Double {
    @inline(__always)
    get {
      return self.__implementation.minTorchStrength
    }
  }
  
  public final var maxTorchStrength: Double {
    @inline(__always)
    get {
      return self.__implementation.maxTorchStrength
    }
  }
  
  public final var supportsLowLightBoost: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsLowLightBoost
    }
  }
  
  public final var minZoom: Double {
    @inline(__always)
    get {
      return self.__implementation.minZoom
    }
  }
  
  public final var maxZoom: Double {
    @inline(__always)
    get {
      return self.__implementation.maxZoom
    }
  }
  
  public final var zoomLensSwitchFactors: bridge.std__vector_double_ {
    @inline(__always)
    get {
      return { () -> bridge.std__vector_double_ in
        var __vector = bridge.create_std__vector_double_(self.__implementation.zoomLensSwitchFactors.count)
        for __item in self.__implementation.zoomLensSwitchFactors {
          __vector.push_back(__item)
        }
        return __vector
      }()
    }
  }
  
  public final var supportsDistortionCorrection: Bool {
    @inline(__always)
    get {
      return self.__implementation.supportsDistortionCorrection
    }
  }

  // Methods
  @inline(__always)
  public final func getSupportedResolutions(outputStreamType: Int32) -> bridge.Result_std__vector_Size__ {
    do {
      let __result = try self.__implementation.getSupportedResolutions(outputStreamType: margelo.nitro.camera.OutputStreamType(rawValue: outputStreamType)!)
      let __resultCpp = { () -> bridge.std__vector_Size_ in
        var __vector = bridge.create_std__vector_Size_(__result.count)
        for __item in __result {
          __vector.push_back(__item)
        }
        return __vector
      }()
      return bridge.create_Result_std__vector_Size__(__resultCpp)
    } catch (let __error) {
      let __exceptionPtr = __error.toCpp()
      return bridge.create_Result_std__vector_Size__(__exceptionPtr)
    }
  }
  
  @inline(__always)
  public final func supportsOutput(output: bridge.std__shared_ptr_HybridCameraOutputSpec_) -> bridge.Result_bool_ {
    do {
      let __result = try self.__implementation.supportsOutput(output: { () -> any HybridCameraOutputSpec in
        let __unsafePointer = bridge.get_std__shared_ptr_HybridCameraOutputSpec_(output)
        let __instance = HybridCameraOutputSpec_cxx.fromUnsafe(__unsafePointer)
        return __instance.getHybridCameraOutputSpec()
      }())
      let __resultCpp = __result
      return bridge.create_Result_bool_(__resultCpp)
    } catch (let __error) {
      let __exceptionPtr = __error.toCpp()
      return bridge.create_Result_bool_(__exceptionPtr)
    }
  }
  
  @inline(__always)
  public final func supportsFPS(fps: Double) -> bridge.Result_bool_ {
    do {
      let __result = try self.__implementation.supportsFPS(fps: fps)
      let __resultCpp = __result
      return bridge.create_Result_bool_(__resultCpp)
    } catch (let __error) {
      let __exceptionPtr = __error.toCpp()
      return bridge.create_Result_bool_(__exceptionPtr)
    }
  }
  
  @inline(__always)
  public final func supportsVideoStabilizationMode(videoStabilizationMode: Int32) -> bridge.Result_bool_ {
    do {
      let __result = try self.__implementation.supportsVideoStabilizationMode(videoStabilizationMode: margelo.nitro.camera.TargetStabilizationMode(rawValue: videoStabilizationMode)!)
      let __resultCpp = __result
      return bridge.create_Result_bool_(__resultCpp)
    } catch (let __error) {
      let __exceptionPtr = __error.toCpp()
      return bridge.create_Result_bool_(__exceptionPtr)
    }
  }
  
  @inline(__always)
  public final func supportsPreviewStabilizationMode(previewStabilizationMode: Int32) -> bridge.Result_bool_ {
    do {
      let __result = try self.__implementation.supportsPreviewStabilizationMode(previewStabilizationMode: margelo.nitro.camera.TargetStabilizationMode(rawValue: previewStabilizationMode)!)
      let __resultCpp = __result
      return bridge.create_Result_bool_(__resultCpp)
    } catch (let __error) {
      let __exceptionPtr = __error.toCpp()
      return bridge.create_Result_bool_(__exceptionPtr)
    }
  }
  
  @inline(__always)
  public final func isSessionConfigSupported(config: bridge.std__shared_ptr_HybridCameraSessionConfigSpec_) -> bridge.Result_bool_ {
    do {
      let __result = try self.__implementation.isSessionConfigSupported(config: { () -> any HybridCameraSessionConfigSpec in
        let __unsafePointer = bridge.get_std__shared_ptr_HybridCameraSessionConfigSpec_(config)
        let __instance = HybridCameraSessionConfigSpec_cxx.fromUnsafe(__unsafePointer)
        return __instance.getHybridCameraSessionConfigSpec()
      }())
      let __resultCpp = __result
      return bridge.create_Result_bool_(__resultCpp)
    } catch (let __error) {
      let __exceptionPtr = __error.toCpp()
      return bridge.create_Result_bool_(__exceptionPtr)
    }
  }
}
