/**
 * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
 *
 * Do not edit this file as changes may cause incorrect behavior and will be lost
 * once the code is regenerated.
 *
 * @generated by codegen project: GenerateModuleH.js
 */

#pragma once

#include <ReactCommon/TurboModule.h>
#include <react/bridging/Bridging.h>

namespace facebook::react {


  
#pragma mark - NativeAhrsAhrsData

template <typename P0, typename P1, typename P2>
struct NativeAhrsAhrsData {
  P0 roll;
  P1 pitch;
  P2 heading;
  bool operator==(const NativeAhrsAhrsData &other) const {
    return roll == other.roll && pitch == other.pitch && heading == other.heading;
  }
};

template <typename T>
struct NativeAhrsAhrsDataBridging {
  static T types;

  static T fromJs(
      jsi::Runtime &rt,
      const jsi::Object &value,
      const std::shared_ptr<CallInvoker> &jsInvoker) {
    T result{
      bridging::fromJs<decltype(types.roll)>(rt, value.getProperty(rt, "roll"), jsInvoker),
      bridging::fromJs<decltype(types.pitch)>(rt, value.getProperty(rt, "pitch"), jsInvoker),
      bridging::fromJs<decltype(types.heading)>(rt, value.getProperty(rt, "heading"), jsInvoker)};
    return result;
  }

#ifdef DEBUG
  static double rollToJs(jsi::Runtime &rt, decltype(types.roll) value) {
    return bridging::toJs(rt, value);
  }

  static double pitchToJs(jsi::Runtime &rt, decltype(types.pitch) value) {
    return bridging::toJs(rt, value);
  }

  static double headingToJs(jsi::Runtime &rt, decltype(types.heading) value) {
    return bridging::toJs(rt, value);
  }
#endif

  static jsi::Object toJs(
      jsi::Runtime &rt,
      const T &value,
      const std::shared_ptr<CallInvoker> &jsInvoker) {
    auto result = facebook::jsi::Object(rt);
    result.setProperty(rt, "roll", bridging::toJs(rt, value.roll, jsInvoker));
    result.setProperty(rt, "pitch", bridging::toJs(rt, value.pitch, jsInvoker));
    result.setProperty(rt, "heading", bridging::toJs(rt, value.heading, jsInvoker));
    return result;
  }
};

class JSI_EXPORT NativeAhrsCxxSpecJSI : public TurboModule {
protected:
  NativeAhrsCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);

public:
  virtual void startAhrs(jsi::Runtime &rt) = 0;
  virtual void stopAhrs(jsi::Runtime &rt) = 0;
  virtual void resetAhrs(jsi::Runtime &rt) = 0;
  virtual void levelAhrs(jsi::Runtime &rt) = 0;
  virtual void setAhrsRate(jsi::Runtime &rt, double newRate) = 0;
  virtual void setAhrsGain(jsi::Runtime &rt, double newGain) = 0;
  virtual void setAhrsRotation(jsi::Runtime &rt, jsi::String newRotation) = 0;

};

template <typename T>
class JSI_EXPORT NativeAhrsCxxSpec : public TurboModule {
public:
  jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
    return delegate_.create(rt, propName);
  }

  std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime& runtime) override {
    return delegate_.getPropertyNames(runtime);
  }

  static constexpr std::string_view kModuleName = "NativeAhrs";

protected:
  NativeAhrsCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
    : TurboModule(std::string{NativeAhrsCxxSpec::kModuleName}, jsInvoker),
      delegate_(reinterpret_cast<T*>(this), jsInvoker) {}

  template <typename OnAhrsUpdateType> void emitOnAhrsUpdate(OnAhrsUpdateType value) {
    static_assert(bridging::supportsFromJs<OnAhrsUpdateType, jsi::Object>, "value cannnot be converted to jsi::Object");
    static_cast<AsyncEventEmitter<jsi::Value>&>(*delegate_.eventEmitterMap_["onAhrsUpdate"]).emit([jsInvoker = jsInvoker_, eventValue = value](jsi::Runtime& rt) -> jsi::Value {
      return bridging::toJs(rt, eventValue, jsInvoker);
    });
  }

private:
  class Delegate : public NativeAhrsCxxSpecJSI {
  public:
    Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
      NativeAhrsCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
      eventEmitterMap_["onAhrsUpdate"] = std::make_shared<AsyncEventEmitter<jsi::Value>>();
    }

    void startAhrs(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::startAhrs) == 1,
          "Expected startAhrs(...) to have 1 parameters");

      return bridging::callFromJs<void>(
          rt, &T::startAhrs, jsInvoker_, instance_);
    }
    void stopAhrs(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::stopAhrs) == 1,
          "Expected stopAhrs(...) to have 1 parameters");

      return bridging::callFromJs<void>(
          rt, &T::stopAhrs, jsInvoker_, instance_);
    }
    void resetAhrs(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::resetAhrs) == 1,
          "Expected resetAhrs(...) to have 1 parameters");

      return bridging::callFromJs<void>(
          rt, &T::resetAhrs, jsInvoker_, instance_);
    }
    void levelAhrs(jsi::Runtime &rt) override {
      static_assert(
          bridging::getParameterCount(&T::levelAhrs) == 1,
          "Expected levelAhrs(...) to have 1 parameters");

      return bridging::callFromJs<void>(
          rt, &T::levelAhrs, jsInvoker_, instance_);
    }
    void setAhrsRate(jsi::Runtime &rt, double newRate) override {
      static_assert(
          bridging::getParameterCount(&T::setAhrsRate) == 2,
          "Expected setAhrsRate(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::setAhrsRate, jsInvoker_, instance_, std::move(newRate));
    }
    void setAhrsGain(jsi::Runtime &rt, double newGain) override {
      static_assert(
          bridging::getParameterCount(&T::setAhrsGain) == 2,
          "Expected setAhrsGain(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::setAhrsGain, jsInvoker_, instance_, std::move(newGain));
    }
    void setAhrsRotation(jsi::Runtime &rt, jsi::String newRotation) override {
      static_assert(
          bridging::getParameterCount(&T::setAhrsRotation) == 2,
          "Expected setAhrsRotation(...) to have 2 parameters");

      return bridging::callFromJs<void>(
          rt, &T::setAhrsRotation, jsInvoker_, instance_, std::move(newRotation));
    }

  private:
    friend class NativeAhrsCxxSpec;
    T *instance_;
  };

  Delegate delegate_;
};

} // namespace facebook::react
