blob: 29bceb4bf2e2dafc0931a3196f3b4fbb44a15415 [file] [log] [blame]
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +00001#pragma once
2
3#include "utils/conversion.hpp"
4
5#include <array>
6#include <cstdint>
7#include <string_view>
8
9enum class OperationType : uint32_t
10{
11 single,
12 max,
13 min,
14 avg,
15 sum
16};
17
18namespace utils
19{
20
21constexpr std::array<std::pair<std::string_view, OperationType>, 5>
22 convDataOperationType = {
23 {std::make_pair<std::string_view, OperationType>("SINGLE",
24 OperationType::single),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010025 std::make_pair<std::string_view, OperationType>("Maximum",
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000026 OperationType::max),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010027 std::make_pair<std::string_view, OperationType>("Minimum",
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000028 OperationType::min),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010029 std::make_pair<std::string_view, OperationType>("Average",
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000030 OperationType::avg),
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010031 std::make_pair<std::string_view, OperationType>("Summation",
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000032 OperationType::sum)}};
33
34inline OperationType
35 toOperationType(std::underlying_type_t<OperationType> value)
36{
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010037 return toEnum<OperationType, minEnumValue(convDataOperationType),
38 maxEnumValue(convDataOperationType)>(value);
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000039}
40
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010041inline OperationType toOperationType(const std::string& value)
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000042{
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010043 return toEnum(convDataOperationType, value);
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000044}
45
46inline std::string enumToString(OperationType value)
47{
48 return std::string(enumToString(convDataOperationType, value));
49}
50
51} // namespace utils