blob: 1ec74f96ad392d2538837093e129593e199d67ac [file] [log] [blame]
Krzysztof Grobelny51497a02021-11-09 14:56:22 +01001#pragma once
2
3#include "utils/conversion.hpp"
4
5#include <array>
6#include <cstdint>
7#include <string_view>
8#include <type_traits>
9
10enum class ReportAction : uint32_t
11{
12 emitsReadingsUpdate,
13 logToMetricReportsCollection
14};
15
16namespace utils
17{
18
Krzysztof Grobelny62c08e92022-09-16 10:28:53 +020019template <>
20struct EnumTraits<ReportAction>
21{
22 static constexpr auto propertyName = ConstexprString{"ReportAction"};
23};
24
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010025constexpr std::array<std::pair<std::string_view, ReportAction>, 2>
Krzysztof Grobelnycff70c12022-10-27 07:16:08 +000026 convDataReportAction = {{std::make_pair<std::string_view, ReportAction>(
27 "xyz.openbmc_project.Telemetry.Report."
28 "ReportActions.EmitsReadingsUpdate",
29 ReportAction::emitsReadingsUpdate),
30 std::make_pair<std::string_view, ReportAction>(
31 "xyz.openbmc_project.Telemetry.Report."
32 "ReportActions.LogToMetricReportsCollection",
33 ReportAction::logToMetricReportsCollection)}};
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010034
35inline ReportAction toReportAction(std::underlying_type_t<ReportAction> value)
36{
37 return toEnum<ReportAction, minEnumValue(convDataReportAction),
38 maxEnumValue(convDataReportAction)>(value);
39}
40
41inline ReportAction toReportAction(const std::string& value)
42{
43 return toEnum(convDataReportAction, value);
44}
45
46inline std::string enumToString(ReportAction value)
47{
48 return std::string(enumToString(convDataReportAction, value));
49}
50
Krzysztof Grobelny62c08e92022-09-16 10:28:53 +020051} // namespace utils