kpi_definition Last update: 16.07.2025 1 5 6 #pragma once 7 8 #include "core/time/i_clock/i_clock.h" 9 #include <string> 10 #include <vector> 11 12 namespace simulation_framework 13 { 14 namespace core 15 { 16 namespace kpi 17 { 18 19 enum class Type : uint8_t 20 { 22 kScalar = 0, 23 kTimeSeries, 24 kLog, 25 kOther 26 }; 27 28 class Datatype 29 { 30 public: 31 enum class Value : uint8_t 32 { 34 kDouble = 0, 35 kInteger, 36 kString, 37 kBoolean, 38 kOther 39 }; 40 41 Datatype(); 42 Datatype(Value value); 43 Datatype(const std::string& value_string); 44 45 ~Datatype() = default; 46 47 operator Value() const; 48 49 std::string ToString() const noexcept; 50 void FromString(const std::string& value_string) noexcept; 51 52 bool operator==(Datatype other) const; 53 54 private: 55 Value value_; 56 }; 57 59 62 struct KpiContent 63 { 64 core::time::Timestamp timestamp; 65 std::string name; 68 Datatype data_type; 69 std::string value; 70 std::string unit; 71 Type type; 72 }; 73 74 inline bool operator==(const core::kpi::KpiContent& lhs, const core::kpi::KpiContent& rhs) 75 { 76 return (lhs.timestamp == rhs.timestamp) && (lhs.name == rhs.name) && (lhs.data_type == rhs.data_type) && 77 (lhs.value == rhs.value) && (lhs.unit == rhs.unit) && (lhs.type == rhs.type); 78 } 79 85 using KpiMessage = std::vector<KpiContent>; 86 87 } // namespace kpi 88 } // namespace core 89 } // namespace simulation_framework