blob: 9286e24e706971fb1064fb7097229f7bc885f653 [file] [log] [blame]
Krzysztof Grobelny51497a02021-11-09 14:56:22 +01001#pragma once
2
3#include "utils/conversion.hpp"
4
5#include <sdbusplus/exception.hpp>
6
7#include <array>
8#include <cstdint>
9#include <string_view>
10#include <type_traits>
11
12enum class ReportUpdates : uint32_t
13{
14 overwrite,
15 appendStopsWhenFull,
Krzysztof Grobelnya950e422021-12-31 13:49:00 +010016 appendWrapsWhenFull
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010017};
18
19namespace utils
20{
21
22template <>
23struct EnumTraits<ReportUpdates>
24{
Krzysztof Grobelny62c08e92022-09-16 10:28:53 +020025 static constexpr auto propertyName = ConstexprString{"ReportUpdates"};
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010026};
27
Patrick Williams3a1c2972023-05-10 07:51:04 -050028constexpr auto convDataReportUpdates = std::array{
Patrick Williams3a1c2972023-05-10 07:51:04 -050029 std::make_pair<std::string_view, ReportUpdates>(
Krzysztof Grobelnycff70c12022-10-27 07:16:08 +000030 "xyz.openbmc_project.Telemetry.Report.ReportUpdates.Overwrite",
31 ReportUpdates::overwrite),
Patrick Williams3a1c2972023-05-10 07:51:04 -050032 std::make_pair<std::string_view, ReportUpdates>(
Krzysztof Grobelnycff70c12022-10-27 07:16:08 +000033 "xyz.openbmc_project.Telemetry.Report.ReportUpdates."
34 "AppendStopsWhenFull",
35 ReportUpdates::appendStopsWhenFull),
36 std::make_pair<std::string_view, ReportUpdates>(
37 "xyz.openbmc_project.Telemetry.Report.ReportUpdates."
38 "AppendWrapsWhenFull",
39 ReportUpdates::appendWrapsWhenFull)};
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010040
41inline ReportUpdates
42 toReportUpdates(std::underlying_type_t<ReportUpdates> value)
43{
44 return toEnum<ReportUpdates, minEnumValue(convDataReportUpdates),
45 maxEnumValue(convDataReportUpdates)>(value);
46}
47
48inline ReportUpdates toReportUpdates(const std::string& value)
49{
50 return toEnum(convDataReportUpdates, value);
51}
52
53inline std::string enumToString(ReportUpdates value)
54{
55 return std::string(enumToString(convDataReportUpdates, value));
56}
57
58} // namespace utils