blob: 3a114e3f2f48b4d3b211fbb957a8b7ee797b05fb [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>
26 convDataReportAction = {
27 {std::make_pair<std::string_view, ReportAction>(
28 "EmitsReadingsUpdate", ReportAction::emitsReadingsUpdate),
29 std::make_pair<std::string_view, ReportAction>(
30 "LogToMetricReportsCollection",
31 ReportAction::logToMetricReportsCollection)}};
32
33inline ReportAction toReportAction(std::underlying_type_t<ReportAction> value)
34{
35 return toEnum<ReportAction, minEnumValue(convDataReportAction),
36 maxEnumValue(convDataReportAction)>(value);
37}
38
39inline ReportAction toReportAction(const std::string& value)
40{
41 return toEnum(convDataReportAction, value);
42}
43
44inline std::string enumToString(ReportAction value)
45{
46 return std::string(enumToString(convDataReportAction, value));
47}
48
Krzysztof Grobelny62c08e92022-09-16 10:28:53 +020049} // namespace utils