1 #pragma once
2
3 #include "utils/conversion.hpp"
4
5 #include <array>
6 #include <cstdint>
7 #include <string_view>
8 #include <type_traits>
9
10 enum class ReportAction : uint32_t
11 {
12 emitsReadingsUpdate,
13 logToMetricReportsCollection
14 };
15
16 namespace utils
17 {
18
19 template <>
20 struct EnumTraits<ReportAction>
21 {
22 static constexpr auto propertyName = ConstexprString{"ReportAction"};
23 };
24
25 constexpr std::array<std::pair<std::string_view, ReportAction>, 2>
26 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)}};
34
toReportAction(std::underlying_type_t<ReportAction> value)35 inline ReportAction toReportAction(std::underlying_type_t<ReportAction> value)
36 {
37 return toEnum<ReportAction, minEnumValue(convDataReportAction),
38 maxEnumValue(convDataReportAction)>(value);
39 }
40
toReportAction(const std::string & value)41 inline ReportAction toReportAction(const std::string& value)
42 {
43 return toEnum(convDataReportAction, value);
44 }
45
enumToString(ReportAction value)46 inline std::string enumToString(ReportAction value)
47 {
48 return std::string(enumToString(convDataReportAction, value));
49 }
50
51 } // namespace utils
52