113 lines
6.5 KiB
C++
Generated
113 lines
6.5 KiB
C++
Generated
///
|
|
/// NativeBPMEstimate.hpp
|
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
/// https://github.com/mrousavy/nitro
|
|
/// Copyright © Marc Rousavy @ Margelo
|
|
///
|
|
|
|
#pragma once
|
|
|
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
#include <NitroModules/JSIConverter.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
#include <NitroModules/NitroDefines.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
#include <NitroModules/JSIHelpers.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
#include <NitroModules/PropNameIDCache.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
|
|
|
|
|
|
#include <optional>
|
|
#include <string>
|
|
|
|
namespace margelo::nitro::haptika::ppg {
|
|
|
|
/**
|
|
* A struct which can be represented as a JavaScript object (NativeBPMEstimate).
|
|
*/
|
|
struct NativeBPMEstimate final {
|
|
public:
|
|
std::optional<double> bpm SWIFT_PRIVATE;
|
|
std::optional<double> temporalBpm SWIFT_PRIVATE;
|
|
std::optional<double> frequencyBpm SWIFT_PRIVATE;
|
|
std::optional<double> methodAgreementBpm SWIFT_PRIVATE;
|
|
double validPeakCount SWIFT_PRIVATE;
|
|
double rejectedPeakCount SWIFT_PRIVATE;
|
|
double confidence SWIFT_PRIVATE;
|
|
std::string selectedChannel SWIFT_PRIVATE;
|
|
|
|
public:
|
|
NativeBPMEstimate() = default;
|
|
explicit NativeBPMEstimate(std::optional<double> bpm, std::optional<double> temporalBpm, std::optional<double> frequencyBpm, std::optional<double> methodAgreementBpm, double validPeakCount, double rejectedPeakCount, double confidence, std::string selectedChannel): bpm(bpm), temporalBpm(temporalBpm), frequencyBpm(frequencyBpm), methodAgreementBpm(methodAgreementBpm), validPeakCount(validPeakCount), rejectedPeakCount(rejectedPeakCount), confidence(confidence), selectedChannel(selectedChannel) {}
|
|
|
|
public:
|
|
friend bool operator==(const NativeBPMEstimate& lhs, const NativeBPMEstimate& rhs) = default;
|
|
};
|
|
|
|
} // namespace margelo::nitro::haptika::ppg
|
|
|
|
namespace margelo::nitro {
|
|
|
|
// C++ NativeBPMEstimate <> JS NativeBPMEstimate (object)
|
|
template <>
|
|
struct JSIConverter<margelo::nitro::haptika::ppg::NativeBPMEstimate> final {
|
|
static inline margelo::nitro::haptika::ppg::NativeBPMEstimate fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
jsi::Object obj = arg.asObject(runtime);
|
|
return margelo::nitro::haptika::ppg::NativeBPMEstimate(
|
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bpm"))),
|
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "temporalBpm"))),
|
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequencyBpm"))),
|
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "methodAgreementBpm"))),
|
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "validPeakCount"))),
|
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rejectedPeakCount"))),
|
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confidence"))),
|
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selectedChannel")))
|
|
);
|
|
}
|
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::haptika::ppg::NativeBPMEstimate& arg) {
|
|
jsi::Object obj(runtime);
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bpm"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.bpm));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "temporalBpm"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.temporalBpm));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "frequencyBpm"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.frequencyBpm));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "methodAgreementBpm"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.methodAgreementBpm));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "validPeakCount"), JSIConverter<double>::toJSI(runtime, arg.validPeakCount));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "rejectedPeakCount"), JSIConverter<double>::toJSI(runtime, arg.rejectedPeakCount));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "confidence"), JSIConverter<double>::toJSI(runtime, arg.confidence));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "selectedChannel"), JSIConverter<std::string>::toJSI(runtime, arg.selectedChannel));
|
|
return obj;
|
|
}
|
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
if (!value.isObject()) {
|
|
return false;
|
|
}
|
|
jsi::Object obj = value.getObject(runtime);
|
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
return false;
|
|
}
|
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bpm")))) return false;
|
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "temporalBpm")))) return false;
|
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "frequencyBpm")))) return false;
|
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "methodAgreementBpm")))) return false;
|
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "validPeakCount")))) return false;
|
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rejectedPeakCount")))) return false;
|
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "confidence")))) return false;
|
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "selectedChannel")))) return false;
|
|
return true;
|
|
}
|
|
};
|
|
|
|
} // namespace margelo::nitro
|