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

#pragma once

#include "HybridOrientationManagerSpec.hpp"

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

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

#include "OrientationSource.hpp"
#include "CameraOrientation.hpp"
#include <optional>
#include <functional>

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

namespace margelo::nitro::camera {

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

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

  public:
    // Properties
    inline OrientationSource getSource() noexcept override {
      auto __result = _swiftPart.getSource();
      return static_cast<OrientationSource>(__result);
    }
    inline std::optional<CameraOrientation> getCurrentOrientation() noexcept override {
      auto __result = _swiftPart.getCurrentOrientation();
      return __result;
    }

  public:
    // Methods
    inline void startOrientationUpdates(const std::function<void(CameraOrientation /* orientation */)>& onChanged) override {
      auto __result = _swiftPart.startOrientationUpdates(onChanged);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void stopOrientationUpdates() override {
      auto __result = _swiftPart.stopOrientationUpdates();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    VisionCamera::HybridOrientationManagerSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::camera
