#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H #define _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H #include #include #include #include #include namespace smo { namespace stim_buff { enum ParamComparatorOp { OP_CMP_GT, OP_CMP_LT, }; struct ParamComparator { ParamComparatorOp op; uint32_t value; bool operator()(float ambienceVal) const { switch (op) { case OP_CMP_GT: return ambienceVal > static_cast(value); case OP_CMP_LT: return ambienceVal < static_cast(value); } throw std::runtime_error("Unsupported ParamComparatorOp"); } }; inline std::optional parseOptionalPcloudAmbienceParamComparator( const std::shared_ptr& deviceAttachmentSpec) { const auto& params = deviceAttachmentSpec->qualeIfaceApiParams; constexpr int kParamNotSpecified = -1; const int gtVal = device::DeviceAttachmentSpec::parseOptionalParamAsInt( params, "ambience-count-gt-val", kParamNotSpecified); const int ltVal = device::DeviceAttachmentSpec::parseOptionalParamAsInt( params, "ambience-count-lt-val", kParamNotSpecified); if (gtVal != kParamNotSpecified && ltVal != kParamNotSpecified) { throw std::runtime_error( "Only one of 'ambience-count-gt-val' or 'ambience-count-lt-val' " "may be specified for a pcloudAmbience stim buff instance"); } if (gtVal != kParamNotSpecified) { return std::optional(ParamComparator{ .op = OP_CMP_GT, .value = static_cast(gtVal), }); } if (ltVal != kParamNotSpecified) { return std::optional(ParamComparator{ .op = OP_CMP_LT, .value = static_cast(ltVal), }); } return std::nullopt; } } // namespace stim_buff } // namespace smo #endif // _LIVOX_GEN1_PCLOUD_AMBIENCE_QUALE_IFACE_API_H