blob: 6d1962012c85bd33b731221c99390dcd57a20c7d [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{
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000011 max,
12 min,
13 avg,
14 sum
15};
16
17namespace utils
18{
19
Krzysztof Grobelny60fee072022-01-13 16:25:04 +010020constexpr std::array<std::pair<std::string_view, OperationType>, 4>
21 convDataOperationType = {{std::make_pair<std::string_view, OperationType>(
22 "Maximum", OperationType::max),
23 std::make_pair<std::string_view, OperationType>(
24 "Minimum", OperationType::min),
25 std::make_pair<std::string_view, OperationType>(
26 "Average", OperationType::avg),
27 std::make_pair<std::string_view, OperationType>(
28 "Summation", OperationType::sum)}};
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000029
30inline OperationType
31 toOperationType(std::underlying_type_t<OperationType> value)
32{
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010033 return toEnum<OperationType, minEnumValue(convDataOperationType),
34 maxEnumValue(convDataOperationType)>(value);
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000035}
36
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010037inline OperationType toOperationType(const std::string& value)
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000038{
Krzysztof Grobelny51497a02021-11-09 14:56:22 +010039 return toEnum(convDataOperationType, value);
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000040}
41
42inline std::string enumToString(OperationType value)
43{
44 return std::string(enumToString(convDataOperationType, value));
45}
46
47} // namespace utils