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

#pragma once

#include "HybridNitroBackgroundTimerSpec.hpp"

// Forward declaration of `HybridNitroBackgroundTimerSpec_cxx` to properly resolve imports.
namespace NitroBackgroundTimer { class HybridNitroBackgroundTimerSpec_cxx; }



#include <string>
#include <functional>
#include <vector>

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

namespace margelo::nitro::backgroundtimer {

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

  public:
    // Get the Swift part
    inline NitroBackgroundTimer::HybridNitroBackgroundTimerSpec_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<HybridNitroBackgroundTimerSpecSwift>(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 double schedule(double id, double delayMs, const std::string& kind, double intervalMs, const std::string& group, const std::string& driftPolicy, double maxRuns, double correlationToken, double retryMaxAttempts, double retryInitialBackoffMs, const std::string& cancellationToken, double tagMask, const std::string& policyProfile, const std::function<void(double /* id */)>& callback) override {
      auto __result = _swiftPart.schedule(std::forward<decltype(id)>(id), std::forward<decltype(delayMs)>(delayMs), kind, std::forward<decltype(intervalMs)>(intervalMs), group, driftPolicy, std::forward<decltype(maxRuns)>(maxRuns), std::forward<decltype(correlationToken)>(correlationToken), std::forward<decltype(retryMaxAttempts)>(retryMaxAttempts), std::forward<decltype(retryInitialBackoffMs)>(retryInitialBackoffMs), cancellationToken, std::forward<decltype(tagMask)>(tagMask), policyProfile, callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void cancel(double id) override {
      auto __result = _swiftPart.cancel(std::forward<decltype(id)>(id));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline double pauseGroup(const std::string& group) override {
      auto __result = _swiftPart.pauseGroup(group);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double resumeGroup(const std::string& group) override {
      auto __result = _swiftPart.resumeGroup(group);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline double cancelGroup(const std::string& group) override {
      auto __result = _swiftPart.cancelGroup(group);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::vector<double> listActiveTimerIds() override {
      auto __result = _swiftPart.listActiveTimerIds();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::string getStatsJson() override {
      auto __result = _swiftPart.getStatsJson();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::string getPersistWireJson() override {
      auto __result = _swiftPart.getPersistWireJson();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void restorePersistWireJson(const std::string& wireJson) override {
      auto __result = _swiftPart.restorePersistWireJson(wireJson);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline double setTimeout(double id, double duration, const std::function<void(double /* id */)>& callback) override {
      auto __result = _swiftPart.setTimeout(std::forward<decltype(id)>(id), std::forward<decltype(duration)>(duration), callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void clearTimeout(double id) override {
      auto __result = _swiftPart.clearTimeout(std::forward<decltype(id)>(id));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline double setInterval(double id, double interval, const std::function<void(double /* id */)>& callback) override {
      auto __result = _swiftPart.setInterval(std::forward<decltype(id)>(id), std::forward<decltype(interval)>(interval), callback);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void clearInterval(double id) override {
      auto __result = _swiftPart.clearInterval(std::forward<decltype(id)>(id));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    NitroBackgroundTimer::HybridNitroBackgroundTimerSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::backgroundtimer
