Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "utils/conversion.hpp" |
| 4 | |
| 5 | #include <array> |
| 6 | #include <cstdint> |
| 7 | #include <string_view> |
| 8 | #include <type_traits> |
| 9 | |
| 10 | enum class CollectionTimeScope : uint32_t |
| 11 | { |
| 12 | point, |
| 13 | interval, |
| 14 | startup |
| 15 | }; |
| 16 | |
| 17 | namespace utils |
| 18 | { |
| 19 | |
| 20 | constexpr std::array<std::pair<std::string_view, CollectionTimeScope>, 3> |
| 21 | convDataCollectionTimeScope = { |
| 22 | {std::make_pair<std::string_view, CollectionTimeScope>( |
| 23 | "Point", CollectionTimeScope::point), |
| 24 | std::make_pair<std::string_view, CollectionTimeScope>( |
| 25 | "Interval", CollectionTimeScope::interval), |
| 26 | std::make_pair<std::string_view, CollectionTimeScope>( |
| 27 | "StartupInterval", CollectionTimeScope::startup)}}; |
| 28 | |
| 29 | inline CollectionTimeScope |
| 30 | toCollectionTimeScope(std::underlying_type_t<CollectionTimeScope> value) |
| 31 | { |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 32 | return toEnum<CollectionTimeScope, |
| 33 | minEnumValue(convDataCollectionTimeScope), |
| 34 | maxEnumValue(convDataCollectionTimeScope)>(value); |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 37 | inline CollectionTimeScope toCollectionTimeScope(const std::string& value) |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 38 | { |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 39 | return toEnum(convDataCollectionTimeScope, value); |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | inline std::string enumToString(CollectionTimeScope value) |
| 43 | { |
| 44 | return std::string(enumToString(convDataCollectionTimeScope, value)); |
| 45 | } |
| 46 | |
Krzysztof Grobelny | 51497a0 | 2021-11-09 14:56:22 +0100 | [diff] [blame] | 47 | } // namespace utils |