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

#pragma once

#include "HybridViewModelListPropertySpec.hpp"

// Forward declaration of `HybridViewModelListPropertySpec_cxx` to properly resolve imports.
namespace RNRive { class HybridViewModelListPropertySpec_cxx; }

// Forward declaration of `HybridViewModelInstanceSpec` to properly resolve imports.
namespace margelo::nitro::rive { class HybridViewModelInstanceSpec; }
// Forward declaration of `HybridViewModelPropertySpecSwift` to properly resolve imports.
namespace margelo::nitro::rive { class HybridViewModelPropertySpecSwift; }

#include <memory>
#include "HybridViewModelInstanceSpec.hpp"
#include <optional>
#include <NitroModules/Promise.hpp>
#include <functional>
#include "HybridViewModelPropertySpecSwift.hpp"

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

namespace margelo::nitro::rive {

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

  public:
    // Get the Swift part
    inline RNRive::HybridViewModelListPropertySpec_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<HybridViewModelListPropertySpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    inline double getLength() noexcept override {
      return _swiftPart.getLength();
    }

  public:
    // Methods
    inline std::optional<std::shared_ptr<HybridViewModelInstanceSpec>> getInstanceAt(double index) override {
      auto __result = _swiftPart.getInstanceAt(std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<double>> getLengthAsync() override {
      auto __result = _swiftPart.getLengthAsync();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::optional<std::shared_ptr<HybridViewModelInstanceSpec>>>> getInstanceAtAsync(double index) override {
      auto __result = _swiftPart.getInstanceAtAsync(std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void addInstance(const std::shared_ptr<HybridViewModelInstanceSpec>& instance) override {
      auto __result = _swiftPart.addInstance(instance);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline bool addInstanceAt(const std::shared_ptr<HybridViewModelInstanceSpec>& instance, double index) override {
      auto __result = _swiftPart.addInstanceAt(instance, std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void removeInstance(const std::shared_ptr<HybridViewModelInstanceSpec>& instance) override {
      auto __result = _swiftPart.removeInstance(instance);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void removeInstanceAt(double index) override {
      auto __result = _swiftPart.removeInstanceAt(std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline bool swap(double index1, double index2) override {
      auto __result = _swiftPart.swap(std::forward<decltype(index1)>(index1), std::forward<decltype(index2)>(index2));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> addInstanceAsync(const std::shared_ptr<HybridViewModelInstanceSpec>& instance) override {
      auto __result = _swiftPart.addInstanceAsync(instance);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> addInstanceAtAsync(const std::shared_ptr<HybridViewModelInstanceSpec>& instance, double index) override {
      auto __result = _swiftPart.addInstanceAtAsync(instance, std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> removeInstanceAsync(const std::shared_ptr<HybridViewModelInstanceSpec>& instance) override {
      auto __result = _swiftPart.removeInstanceAsync(instance);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> removeInstanceAtAsync(double index) override {
      auto __result = _swiftPart.removeInstanceAtAsync(std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> swapAsync(double index1, double index2) override {
      auto __result = _swiftPart.swapAsync(std::forward<decltype(index1)>(index1), std::forward<decltype(index2)>(index2));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::function<void()> addListener(const std::function<void()>& onChanged) override {
      auto __result = _swiftPart.addListener(onChanged);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void removeListeners() override {
      auto __result = _swiftPart.removeListeners();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    RNRive::HybridViewModelListPropertySpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::rive
