/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #pragma once #include namespace OpenVulkano::AR { class ArDepthFormat final { static inline constexpr std::string_view ALT_NAMES[] = { "Unavailable", "FP32_METER", "FP64_METER", "U16_MILLIMETER", "U32_MILLIMETER" }; public: enum Format : uint8_t { UNAVAILABLE = 0, METER_FP16, METER_FP32, METER_FP64, MILLIMETER_U16, MILLIMETER_U32 }; ArDepthFormat() : ArDepthFormat(UNAVAILABLE) {} ArDepthFormat(Format format) : m_format(format) {} [[nodiscard]] std::string_view GetName() const { return magic_enum::enum_name(m_format); } static std::optional GetFromName(std::string_view name) { auto result = magic_enum::enum_cast(name); if (result.has_value()) return ArDepthFormat(result.value()); return GetFromAltName(name); } [[nodiscard]] const std::string_view& GetAltName() const { return ALT_NAMES[m_format]; } static std::optional GetFromAltName(std::string_view name) { uint8_t i = 0; for(const std::string_view& n : ALT_NAMES) { if (n == name) return { static_cast(i) }; i++; } return std::nullopt; } operator Format() const { return m_format; } private: Format m_format; }; }