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 | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame^] | 13 | Metric(std::shared_ptr<interfaces::Sensor> sensor, |
| 14 | OperationType operationType, std::string id, std::string metadata); |
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 | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame^] | 17 | const MetricValue& getReading() 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 | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 23 | MetricValue& findMetric(interfaces::Sensor&); |
| 24 | |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame^] | 25 | std::shared_ptr<interfaces::Sensor> sensor; |
| 26 | OperationType operationType; |
| 27 | MetricValue reading; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 28 | }; |