blob: 2c9f5008b5762a31b359c70574107beb697208cc [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 ReportingType : uint32_t
13{
14 periodic,
15 onRequest,
16 onChange
17};
18
19namespace utils
20{
21
22template <>
23struct EnumTraits<ReportingType>
24{
Krzysztof Grobelny62c08e92022-09-16 10:28:53 +020025 static constexpr auto propertyName = ConstexprString{"ReportingType"};
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010026};
27
28constexpr std::array<std::pair<std::string_view, ReportingType>, 3>
29 convDataReportingType = {{std::make_pair<std::string_view, ReportingType>(
30 "Periodic", ReportingType::periodic),
31 std::make_pair<std::string_view, ReportingType>(
32 "OnRequest", ReportingType::onRequest),
33 std::make_pair<std::string_view, ReportingType>(
34 "OnChange", ReportingType::onChange)}};
35
36inline ReportingType
37 toReportingType(std::underlying_type_t<ReportingType> value)
38{
39 return toEnum<ReportingType, minEnumValue(convDataReportingType),
40 maxEnumValue(convDataReportingType)>(value);
41}
42
43inline ReportingType toReportingType(const std::string& value)
44{
45 return toEnum(convDataReportingType, value);
46}
47
48inline std::string enumToString(ReportingType value)
49{
50 return std::string(enumToString(convDataReportingType, value));
51}
52
53} // namespace utils