Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "interfaces/metric.hpp" |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 4 | #include "interfaces/sensor.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 5 | #include "interfaces/sensor_listener.hpp" |
| 6 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 7 | class Metric : |
| 8 | public interfaces::Metric, |
| 9 | public interfaces::SensorListener, |
| 10 | public std::enable_shared_from_this<Metric> |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 11 | { |
| 12 | public: |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame^] | 13 | Metric(Sensors sensors, OperationType operationType, std::string id, |
| 14 | std::string metadata, CollectionTimeScope, CollectionDuration); |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 15 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 16 | void initialize() override; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame^] | 17 | const std::vector<MetricValue>& getReadings() const override; |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 18 | void sensorUpdated(interfaces::Sensor&, uint64_t) override; |
| 19 | void sensorUpdated(interfaces::Sensor&, uint64_t, double value) override; |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 20 | LabeledMetricParameters dumpConfiguration() const override; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 21 | |
| 22 | private: |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame^] | 23 | void tryUnpackJsonMetadata(); |
| 24 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 25 | MetricValue& findMetric(interfaces::Sensor&); |
| 26 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame^] | 27 | std::string id; |
| 28 | std::string metadata; |
| 29 | std::vector<MetricValue> readings; |
| 30 | Sensors sensors; |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 31 | OperationType operationType; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame^] | 32 | CollectionTimeScope timeScope; |
| 33 | CollectionDuration collectionDuration; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 34 | }; |