///
/// 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; }

// Forward declaration of `FiredTimerEvent` to properly resolve imports.
namespace margelo::nitro::backgroundtimer { struct FiredTimerEvent; }
// Forward declaration of `FiredTimerType` to properly resolve imports.
namespace margelo::nitro::backgroundtimer { enum class FiredTimerType; }

#include "FiredTimerEvent.hpp"
#include <vector>
#include "FiredTimerType.hpp"
#include <string>

#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 void setTimeout(double id, double duration) override {
      auto __result = _swiftPart.setTimeout(std::forward<decltype(id)>(id), std::forward<decltype(duration)>(duration));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    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 void setInterval(double id, double interval) override {
      auto __result = _swiftPart.setInterval(std::forward<decltype(id)>(id), std::forward<decltype(interval)>(interval));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void clearInterval(double id) override {
      auto __result = _swiftPart.clearInterval(std::forward<decltype(id)>(id));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::vector<FiredTimerEvent> drainFiredTimers() override {
      auto __result = _swiftPart.drainFiredTimers();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void startBackgroundMode() override {
      auto __result = _swiftPart.startBackgroundMode();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void stopBackgroundMode() override {
      auto __result = _swiftPart.stopBackgroundMode();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void configure(const std::string& configJson) override {
      auto __result = _swiftPart.configure(configJson);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void disableForegroundService() override {
      auto __result = _swiftPart.disableForegroundService();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    NitroBackgroundTimer::HybridNitroBackgroundTimerSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::backgroundtimer
