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 | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 17 | Metric(Sensors sensors, OperationType operationType, std::string id, |
Krzysztof Grobelny | b8cc78d | 2021-11-29 15:54:53 +0100 | [diff] [blame] | 18 | CollectionTimeScope, CollectionDuration, |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 19 | std::unique_ptr<interfaces::Clock>); |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 20 | |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 21 | void initialize() override; |
Lukasz Kazmierczak | 7e098e9 | 2021-09-16 15:59:56 +0200 | [diff] [blame] | 22 | void deinitialize() override; |
Krzysztof Grobelny | 9e8da54 | 2022-02-17 10:40:16 +0100 | [diff] [blame] | 23 | const std::vector<MetricValue>& getUpdatedReadings() override; |
Krzysztof Grobelny | 51f0fd5 | 2021-12-28 16:32:08 +0100 | [diff] [blame] | 24 | void sensorUpdated(interfaces::Sensor&, Milliseconds, |
| 25 | double value) override; |
Krzysztof Grobelny | d223819 | 2020-12-02 09:27:28 +0000 | [diff] [blame] | 26 | LabeledMetricParameters dumpConfiguration() const override; |
Krzysztof Grobelny | 18e7101 | 2022-11-02 13:17:01 +0000 | [diff] [blame] | 27 | uint64_t metricCount() const override; |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 28 | void registerForUpdates(interfaces::MetricListener& listener) override; |
| 29 | void unregisterFromUpdates(interfaces::MetricListener& listener) override; |
| 30 | void updateReadings(Milliseconds) override; |
| 31 | bool isTimerRequired() const override; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 32 | |
| 33 | private: |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 34 | metrics::CollectionData& |
| 35 | findAssociatedData(const interfaces::Sensor& notifier); |
Krzysztof Grobelny | 6ccfcbf | 2020-11-04 09:31:36 +0100 | [diff] [blame] | 36 | |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 37 | std::string id; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 38 | std::vector<MetricValue> readings; |
| 39 | Sensors sensors; |
Krzysztof Grobelny | e8fc575 | 2021-02-05 14:30:45 +0000 | [diff] [blame] | 40 | OperationType operationType; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 41 | CollectionTimeScope collectionTimeScope; |
Krzysztof Grobelny | dcc4e19 | 2021-03-08 09:09:34 +0000 | [diff] [blame] | 42 | CollectionDuration collectionDuration; |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 43 | std::vector<std::unique_ptr<metrics::CollectionData>> collectionAlgorithms; |
Krzysztof Grobelny | 8069771 | 2021-03-04 09:49:27 +0000 | [diff] [blame] | 44 | std::unique_ptr<interfaces::Clock> clock; |
Krzysztof Grobelny | f7ea299 | 2022-01-27 11:04:58 +0100 | [diff] [blame] | 45 | std::vector<std::reference_wrapper<interfaces::MetricListener>> listeners; |
Krzysztof Grobelny | c8e3a64 | 2020-10-23 12:29:16 +0200 | [diff] [blame] | 46 | }; |