Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 3 | #include "interfaces/clock.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 4 | #include "interfaces/metric.hpp" |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 5 | #include "interfaces/metric_listener.hpp" |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 6 | #include "interfaces/sensor.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 7 | #include "interfaces/sensor_listener.hpp" |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 8 | #include "metrics/collection_data.hpp" |
| 9 | #include "types/collection_duration.hpp" |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 10 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 11 | class Metric : |
| 12 | public interfaces::Metric, |
| 13 | public interfaces::SensorListener, |
| 14 | public std::enable_shared_from_this<Metric> |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 15 | { |
| 16 | public: |
Krzysztof Grobelny | cff70c1 | 2022-10-27 07:16:08 +0000 | [diff] [blame] | 17 | Metric(Sensors sensors, OperationType operationType, CollectionTimeScope, |
| 18 | CollectionDuration, std::unique_ptr<interfaces::Clock>); |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 19 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 20 | void initialize() override; |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 21 | void deinitialize() override; |
Krzysztof Grobelny | 9e8da54 | 2022-02-17 10:40:16 +0100 | [diff] [blame] | 22 | const std::vector<MetricValue>& getUpdatedReadings() override; |
Krzysztof Grobelny | 51f0fd5 | 2021-12-28 16:32:08 +0100 | [diff] [blame] | 23 | void sensorUpdated(interfaces::Sensor&, Milliseconds, |
| 24 | double value) override; |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 25 | LabeledMetricParameters dumpConfiguration() const override; |
Krzysztof Grobelny | 18e7101 | 2022-11-02 13:17:01 +0000 | [diff] [blame] | 26 | uint64_t metricCount() const override; |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 27 | void registerForUpdates(interfaces::MetricListener& listener) override; |
| 28 | void unregisterFromUpdates(interfaces::MetricListener& listener) override; |
| 29 | void updateReadings(Milliseconds) override; |
| 30 | bool isTimerRequired() const override; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 31 | |
| 32 | private: |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 33 | metrics::CollectionData& |
| 34 | findAssociatedData(const interfaces::Sensor& notifier); |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 35 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 36 | std::vector<MetricValue> readings; |
| 37 | Sensors sensors; |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 38 | OperationType operationType; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 39 | CollectionTimeScope collectionTimeScope; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 40 | CollectionDuration collectionDuration; |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 41 | std::vector<std::unique_ptr<metrics::CollectionData>> collectionAlgorithms; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 42 | std::unique_ptr<interfaces::Clock> clock; |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 43 | std::vector<std::reference_wrapper<interfaces::MetricListener>> listeners; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 44 | }; |