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

#pragma once

#include "HybridOneCalendarSpec.hpp"

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

// Forward declaration of `CalendarPermissionStatus` to properly resolve imports.
namespace margelo::nitro::one { enum class CalendarPermissionStatus; }
// Forward declaration of `CalendarEvent` to properly resolve imports.
namespace margelo::nitro::one { struct CalendarEvent; }
// Forward declaration of `CalendarRecurrence` to properly resolve imports.
namespace margelo::nitro::one { struct CalendarRecurrence; }
// Forward declaration of `CalendarRecurrenceFrequency` to properly resolve imports.
namespace margelo::nitro::one { enum class CalendarRecurrenceFrequency; }
// Forward declaration of `CalendarEventInput` to properly resolve imports.
namespace margelo::nitro::one { struct CalendarEventInput; }
// Forward declaration of `CalendarEventChanges` to properly resolve imports.
namespace margelo::nitro::one { struct CalendarEventChanges; }
// Forward declaration of `ReminderInfo` to properly resolve imports.
namespace margelo::nitro::one { struct ReminderInfo; }
// Forward declaration of `ReminderInput` to properly resolve imports.
namespace margelo::nitro::one { struct ReminderInput; }

#include "CalendarPermissionStatus.hpp"
#include <NitroModules/Promise.hpp>
#include "CalendarEvent.hpp"
#include <vector>
#include <string>
#include "CalendarRecurrence.hpp"
#include <optional>
#include "CalendarRecurrenceFrequency.hpp"
#include "CalendarEventInput.hpp"
#include "CalendarEventChanges.hpp"
#include "ReminderInfo.hpp"
#include "ReminderInput.hpp"

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

namespace margelo::nitro::one {

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

  public:
    // Get the Swift part
    inline One::HybridOneCalendarSpec_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<HybridOneCalendarSpecSwift>(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 CalendarPermissionStatus getPermissionStatus() override {
      auto __result = _swiftPart.getPermissionStatus();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<CalendarPermissionStatus>> requestPermission() override {
      auto __result = _swiftPart.requestPermission();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::vector<CalendarEvent>>> list(double startMs, double endMs, double limit) override {
      auto __result = _swiftPart.list(std::forward<decltype(startMs)>(startMs), std::forward<decltype(endMs)>(endMs), std::forward<decltype(limit)>(limit));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> create(const CalendarEventInput& input) override {
      auto __result = _swiftPart.create(std::forward<decltype(input)>(input));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<CalendarEvent>> update(const std::string& identifier, double originalStartMs, const CalendarEventChanges& changes) override {
      auto __result = _swiftPart.update(identifier, std::forward<decltype(originalStartMs)>(originalStartMs), std::forward<decltype(changes)>(changes));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> remove(const std::string& identifier, double startMs) override {
      auto __result = _swiftPart.remove(identifier, std::forward<decltype(startMs)>(startMs));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline CalendarPermissionStatus getRemindersPermissionStatus() override {
      auto __result = _swiftPart.getRemindersPermissionStatus();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<CalendarPermissionStatus>> requestRemindersPermission() override {
      auto __result = _swiftPart.requestRemindersPermission();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::vector<ReminderInfo>>> listReminders(double limit, bool includeCompleted) override {
      auto __result = _swiftPart.listReminders(std::forward<decltype(limit)>(limit), std::forward<decltype(includeCompleted)>(includeCompleted));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> createReminder(const ReminderInput& input) override {
      auto __result = _swiftPart.createReminder(std::forward<decltype(input)>(input));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> setReminderCompleted(const std::string& identifier, bool completed) override {
      auto __result = _swiftPart.setReminderCompleted(identifier, std::forward<decltype(completed)>(completed));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> removeReminder(const std::string& identifier) override {
      auto __result = _swiftPart.removeReminder(identifier);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    One::HybridOneCalendarSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::one
