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

#pragma once

#include "HybridAlarmKitSpec.hpp"

// Forward declaration of `HybridAlarmKitSpec_cxx` to properly resolve imports.
namespace NitroAlarmkit { class HybridAlarmKitSpec_cxx; }



#include <string>
#include <NitroModules/Promise.hpp>
#include <functional>

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

namespace margelo::nitro::alarmkit {

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

  public:
    // Get the Swift part
    inline NitroAlarmkit::HybridAlarmKitSpec_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<HybridAlarmKitSpecSwift>(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 getIsSupported() noexcept override {
      return _swiftPart.isSupported();
    }

  public:
    // Methods
    inline std::shared_ptr<Promise<std::string>> getAuthorizationState() override {
      auto __result = _swiftPart.getAuthorizationState();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<bool>> requestAuthorization() override {
      auto __result = _swiftPart.requestAuthorization();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> schedule(const std::string& id, const std::string& configJson) override {
      auto __result = _swiftPart.schedule(id, configJson);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> cancel(const std::string& id) override {
      auto __result = _swiftPart.cancel(id);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> stop(const std::string& id) override {
      auto __result = _swiftPart.stop(id);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> pause(const std::string& id) override {
      auto __result = _swiftPart.pause(id);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> resume(const std::string& id) override {
      auto __result = _swiftPart.resume(id);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> countdown(const std::string& id) override {
      auto __result = _swiftPart.countdown(id);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> getAlarms() override {
      auto __result = _swiftPart.getAlarms();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::string addAlarmsListener(const std::function<void(const std::string& /* alarmsJson */)>& callback) override {
      auto __result = _swiftPart.addAlarmsListener(callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void removeAlarmsListener(const std::string& subscriptionId) override {
      auto __result = _swiftPart.removeAlarmsListener(subscriptionId);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::string addAuthorizationListener(const std::function<void(const std::string& /* state */)>& callback) override {
      auto __result = _swiftPart.addAuthorizationListener(callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void removeAuthorizationListener(const std::string& subscriptionId) override {
      auto __result = _swiftPart.removeAuthorizationListener(subscriptionId);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    NitroAlarmkit::HybridAlarmKitSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::alarmkit
