blob: a3dfe81fa4e4c2ba3c53ade2e2ac816e0af2aefc [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{
29 std::make_pair<std::string_view, ReportUpdates>("Overwrite",
30 ReportUpdates::overwrite),
31 std::make_pair<std::string_view, ReportUpdates>(
32 "AppendStopsWhenFull", ReportUpdates::appendStopsWhenFull),
33 std::make_pair<std::string_view, ReportUpdates>(
34 "AppendWrapsWhenFull", ReportUpdates::appendWrapsWhenFull)};
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010035
36inline ReportUpdates
37 toReportUpdates(std::underlying_type_t<ReportUpdates> value)
38{
39 return toEnum<ReportUpdates, minEnumValue(convDataReportUpdates),
40 maxEnumValue(convDataReportUpdates)>(value);
41}
42
43inline ReportUpdates toReportUpdates(const std::string& value)
44{
45 return toEnum(convDataReportUpdates, value);
46}
47
48inline std::string enumToString(ReportUpdates value)
49{
50 return std::string(enumToString(convDataReportUpdates, value));
51}
52
53} // namespace utils