feat: implement Haptika PPG and Watch V1
This commit is contained in:
Generated
+124
@@ -0,0 +1,124 @@
|
||||
///
|
||||
/// NativePPGProcessingResult.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
|
||||
|
||||
// Forward declaration of `NativeBPMEstimate` to properly resolve imports.
|
||||
namespace margelo::nitro::haptika::ppg { struct NativeBPMEstimate; }
|
||||
// Forward declaration of `NativePRVMetrics` to properly resolve imports.
|
||||
namespace margelo::nitro::haptika::ppg { struct NativePRVMetrics; }
|
||||
// Forward declaration of `NativeSignalQualityResult` to properly resolve imports.
|
||||
namespace margelo::nitro::haptika::ppg { struct NativeSignalQualityResult; }
|
||||
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include "NativeBPMEstimate.hpp"
|
||||
#include "NativePRVMetrics.hpp"
|
||||
#include "NativeSignalQualityResult.hpp"
|
||||
|
||||
namespace margelo::nitro::haptika::ppg {
|
||||
|
||||
/**
|
||||
* A struct which can be represented as a JavaScript object (NativePPGProcessingResult).
|
||||
*/
|
||||
struct NativePPGProcessingResult final {
|
||||
public:
|
||||
bool valid SWIFT_PRIVATE;
|
||||
std::optional<std::string> invalidReason SWIFT_PRIVATE;
|
||||
NativeBPMEstimate bpm SWIFT_PRIVATE;
|
||||
NativePRVMetrics prv SWIFT_PRIVATE;
|
||||
NativeSignalQualityResult quality SWIFT_PRIVATE;
|
||||
double startedAtMonotonicSeconds SWIFT_PRIVATE;
|
||||
double endedAtMonotonicSeconds SWIFT_PRIVATE;
|
||||
double rawSampleCount SWIFT_PRIVATE;
|
||||
double resampledSampleCount SWIFT_PRIVATE;
|
||||
|
||||
public:
|
||||
NativePPGProcessingResult() = default;
|
||||
explicit NativePPGProcessingResult(bool valid, std::optional<std::string> invalidReason, NativeBPMEstimate bpm, NativePRVMetrics prv, NativeSignalQualityResult quality, double startedAtMonotonicSeconds, double endedAtMonotonicSeconds, double rawSampleCount, double resampledSampleCount): valid(valid), invalidReason(invalidReason), bpm(bpm), prv(prv), quality(quality), startedAtMonotonicSeconds(startedAtMonotonicSeconds), endedAtMonotonicSeconds(endedAtMonotonicSeconds), rawSampleCount(rawSampleCount), resampledSampleCount(resampledSampleCount) {}
|
||||
|
||||
public:
|
||||
friend bool operator==(const NativePPGProcessingResult& lhs, const NativePPGProcessingResult& rhs) = default;
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro::haptika::ppg
|
||||
|
||||
namespace margelo::nitro {
|
||||
|
||||
// C++ NativePPGProcessingResult <> JS NativePPGProcessingResult (object)
|
||||
template <>
|
||||
struct JSIConverter<margelo::nitro::haptika::ppg::NativePPGProcessingResult> final {
|
||||
static inline margelo::nitro::haptika::ppg::NativePPGProcessingResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
||||
jsi::Object obj = arg.asObject(runtime);
|
||||
return margelo::nitro::haptika::ppg::NativePPGProcessingResult(
|
||||
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "valid"))),
|
||||
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "invalidReason"))),
|
||||
JSIConverter<margelo::nitro::haptika::ppg::NativeBPMEstimate>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bpm"))),
|
||||
JSIConverter<margelo::nitro::haptika::ppg::NativePRVMetrics>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "prv"))),
|
||||
JSIConverter<margelo::nitro::haptika::ppg::NativeSignalQualityResult>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startedAtMonotonicSeconds"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endedAtMonotonicSeconds"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rawSampleCount"))),
|
||||
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resampledSampleCount")))
|
||||
);
|
||||
}
|
||||
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::haptika::ppg::NativePPGProcessingResult& arg) {
|
||||
jsi::Object obj(runtime);
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "valid"), JSIConverter<bool>::toJSI(runtime, arg.valid));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "invalidReason"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.invalidReason));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "bpm"), JSIConverter<margelo::nitro::haptika::ppg::NativeBPMEstimate>::toJSI(runtime, arg.bpm));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "prv"), JSIConverter<margelo::nitro::haptika::ppg::NativePRVMetrics>::toJSI(runtime, arg.prv));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "quality"), JSIConverter<margelo::nitro::haptika::ppg::NativeSignalQualityResult>::toJSI(runtime, arg.quality));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "startedAtMonotonicSeconds"), JSIConverter<double>::toJSI(runtime, arg.startedAtMonotonicSeconds));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "endedAtMonotonicSeconds"), JSIConverter<double>::toJSI(runtime, arg.endedAtMonotonicSeconds));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "rawSampleCount"), JSIConverter<double>::toJSI(runtime, arg.rawSampleCount));
|
||||
obj.setProperty(runtime, PropNameIDCache::get(runtime, "resampledSampleCount"), JSIConverter<double>::toJSI(runtime, arg.resampledSampleCount));
|
||||
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<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "valid")))) return false;
|
||||
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "invalidReason")))) return false;
|
||||
if (!JSIConverter<margelo::nitro::haptika::ppg::NativeBPMEstimate>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "bpm")))) return false;
|
||||
if (!JSIConverter<margelo::nitro::haptika::ppg::NativePRVMetrics>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "prv")))) return false;
|
||||
if (!JSIConverter<margelo::nitro::haptika::ppg::NativeSignalQualityResult>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startedAtMonotonicSeconds")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endedAtMonotonicSeconds")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rawSampleCount")))) return false;
|
||||
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resampledSampleCount")))) return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace margelo::nitro
|
||||
Reference in New Issue
Block a user