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

#pragma once

#include "HybridViewModelStringPropertySpec.hpp"

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

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

#include <string>
#include <NitroModules/Promise.hpp>
#include <functional>
#include "HybridViewModelPropertySpecSwift.hpp"

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

namespace margelo::nitro::rive {

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

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

  public:
    // Properties
    inline std::string getValue() noexcept override {
      auto __result = _swiftPart.getValue();
      return __result;
    }
    inline void setValue(const std::string& value) noexcept override {
      _swiftPart.setValue(value);
    }

  public:
    // Methods
    inline std::shared_ptr<Promise<std::string>> getValueAsync() override {
      auto __result = _swiftPart.getValueAsync();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void set(const std::string& value) override {
      auto __result = _swiftPart.set(value);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::function<void()> addListener(const std::function<void(const std::string& /* value */)>& 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::HybridViewModelStringPropertySpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::rive
