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

#pragma once

#include "HybridOneAppIntentsSpec.hpp"

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

// Forward declaration of `AppIntentInvocation` to properly resolve imports.
namespace margelo::nitro::one { struct AppIntentInvocation; }

#include <functional>
#include <string>
#include "AppIntentInvocation.hpp"
#include <optional>
#include <vector>

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

namespace margelo::nitro::one {

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

  public:
    // Get the Swift part
    inline One::HybridOneAppIntentsSpec_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<HybridOneAppIntentsSpecSwift>(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::function<void()> addInvocationListener(const std::string& identifier, const std::function<void(const AppIntentInvocation& /* invocation */)>& listener) override {
      auto __result = _swiftPart.addInvocationListener(identifier, listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::vector<AppIntentInvocation> claimPending(const std::string& identifier) override {
      auto __result = _swiftPart.claimPending(identifier);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void complete(const std::string& executionId, bool success, const std::string& output) override {
      auto __result = _swiftPart.complete(executionId, std::forward<decltype(success)>(success), output);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    One::HybridOneAppIntentsSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::one
