blob: 859315ed06a32a11ed7fb7af78a3c7ddab671fe9 [file] [log] [blame]
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +02001#pragma once
2
Krzysztof Grobelny80697712021-03-04 09:49:27 +00003#include "interfaces/clock.hpp"
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +02004#include "interfaces/metric.hpp"
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +01005#include "interfaces/sensor.hpp"
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +02006#include "interfaces/sensor_listener.hpp"
7
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +01008class Metric :
9 public interfaces::Metric,
10 public interfaces::SensorListener,
11 public std::enable_shared_from_this<Metric>
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020012{
13 public:
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000014 Metric(Sensors sensors, OperationType operationType, std::string id,
Krzysztof Grobelnyb8cc78d2021-11-29 15:54:53 +010015 CollectionTimeScope, CollectionDuration,
Krzysztof Grobelny80697712021-03-04 09:49:27 +000016 std::unique_ptr<interfaces::Clock>);
17 ~Metric();
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020018
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010019 void initialize() override;
Lukasz Kazmierczak7e098e92021-09-16 15:59:56 +020020 void deinitialize() override;
Krzysztof Grobelny80697712021-03-04 09:49:27 +000021 std::vector<MetricValue> getReadings() const override;
Krzysztof Grobelny51f0fd52021-12-28 16:32:08 +010022 void sensorUpdated(interfaces::Sensor&, Milliseconds) override;
23 void sensorUpdated(interfaces::Sensor&, Milliseconds,
24 double value) override;
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000025 LabeledMetricParameters dumpConfiguration() const override;
Szymon Dompke3eb56862021-09-20 15:32:04 +020026 uint64_t sensorCount() const override;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020027
28 private:
Krzysztof Grobelny80697712021-03-04 09:49:27 +000029 class CollectionData;
30 class DataPoint;
31 class DataInterval;
32 class DataStartup;
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000033
Krzysztof Grobelny80697712021-03-04 09:49:27 +000034 static std::vector<std::unique_ptr<CollectionData>>
35 makeCollectionData(size_t size, OperationType, CollectionTimeScope,
36 CollectionDuration);
37
Krzysztof Grobelny80697712021-03-04 09:49:27 +000038 CollectionData& findAssociatedData(const interfaces::Sensor& notifier);
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010039
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000040 std::string id;
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000041 std::vector<MetricValue> readings;
42 Sensors sensors;
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000043 OperationType operationType;
Krzysztof Grobelny80697712021-03-04 09:49:27 +000044 CollectionTimeScope collectionTimeScope;
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000045 CollectionDuration collectionDuration;
Krzysztof Grobelny80697712021-03-04 09:49:27 +000046 std::vector<std::unique_ptr<CollectionData>> collectionAlgorithms;
47 std::unique_ptr<interfaces::Clock> clock;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020048};