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

#pragma once

#include "HybridOneBrightnessSpec.hpp"

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

// Forward declaration of `BrightnessMode` to properly resolve imports.
namespace margelo::nitro::one { enum class BrightnessMode; }
// Forward declaration of `BrightnessPermissionResponse` to properly resolve imports.
namespace margelo::nitro::one { struct BrightnessPermissionResponse; }
// Forward declaration of `BrightnessPermissionStatus` to properly resolve imports.
namespace margelo::nitro::one { enum class BrightnessPermissionStatus; }
// Forward declaration of `BrightnessEvent` to properly resolve imports.
namespace margelo::nitro::one { struct BrightnessEvent; }

#include <NitroModules/Promise.hpp>
#include "BrightnessMode.hpp"
#include "BrightnessPermissionResponse.hpp"
#include "BrightnessPermissionStatus.hpp"
#include <functional>
#include "BrightnessEvent.hpp"

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

namespace margelo::nitro::one {

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

  public:
    // Get the Swift part
    inline One::HybridOneBrightnessSpec_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<HybridOneBrightnessSpecSwift>(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<double>> get() override {
      auto __result = _swiftPart.get();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> set(double value) override {
      auto __result = _swiftPart.set(std::forward<decltype(value)>(value));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<double>> getSystem() override {
      auto __result = _swiftPart.getSystem();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> setSystem(double value) override {
      auto __result = _swiftPart.setSystem(std::forward<decltype(value)>(value));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<BrightnessMode>> getSystemMode() override {
      auto __result = _swiftPart.getSystemMode();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> setSystemMode(BrightnessMode mode) override {
      auto __result = _swiftPart.setSystemMode(static_cast<int>(mode));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<bool>> isUsingSystem() override {
      auto __result = _swiftPart.isUsingSystem();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> restoreSystem() override {
      auto __result = _swiftPart.restoreSystem();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<BrightnessPermissionResponse>> getPermissions() override {
      auto __result = _swiftPart.getPermissions();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<BrightnessPermissionResponse>> requestPermissions() override {
      auto __result = _swiftPart.requestPermissions();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline bool isAvailable() override {
      auto __result = _swiftPart.isAvailable();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::function<void()> addListener(const std::function<void(const BrightnessEvent& /* event */)>& listener) override {
      auto __result = _swiftPart.addListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    One::HybridOneBrightnessSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::one
