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

#pragma once

#include "HybridNitroBatterySpec.hpp"

// Forward declaration of `HybridNitroBatterySpec_cxx` to properly resolve imports.
namespace NitroBattery { class HybridNitroBatterySpec_cxx; }



#include <string>
#include <functional>

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

namespace margelo::nitro::battery {

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

  public:
    // Get the Swift part
    inline NitroBattery::HybridNitroBatterySpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline double getLevel() override {
      auto __result = _swiftPart.getLevel();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline bool isCharging() override {
      auto __result = _swiftPart.isCharging();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::string getBatteryState() override {
      auto __result = _swiftPart.getBatteryState();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline bool isLowPowerModeEnabled() override {
      auto __result = _swiftPart.isLowPowerModeEnabled();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void addBatteryStateListener(const std::function<void(const std::string& /* state */)>& listener) override {
      auto __result = _swiftPart.addBatteryStateListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void removeBatteryStateListener(const std::function<void(const std::string& /* state */)>& listener) override {
      auto __result = _swiftPart.removeBatteryStateListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void addLowPowerListener(const std::function<void()>& listener) override {
      auto __result = _swiftPart.addLowPowerListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void removeLowPowerListener(const std::function<void()>& listener) override {
      auto __result = _swiftPart.removeLowPowerListener(listener);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    NitroBattery::HybridNitroBatterySpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::battery
