blob: 549603f47d1d73747dd201bd3f82fb0eed218375 [file] [log] [blame]
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +02001#pragma once
2
3#include "interfaces/metric.hpp"
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +01004#include "interfaces/sensor.hpp"
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +02005#include "interfaces/sensor_listener.hpp"
6
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +01007class Metric :
8 public interfaces::Metric,
9 public interfaces::SensorListener,
10 public std::enable_shared_from_this<Metric>
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020011{
12 public:
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000013 Metric(std::shared_ptr<interfaces::Sensor> sensor,
Krzysztof Grobelny753e4b32021-02-11 12:58:58 +000014 OperationType operationType, std::string id, std::string metadata,
15 CollectionTimeScope, CollectionDuration);
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020016
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010017 void initialize() override;
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000018 const MetricValue& getReading() const override;
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010019 void sensorUpdated(interfaces::Sensor&, uint64_t) override;
20 void sensorUpdated(interfaces::Sensor&, uint64_t, double value) override;
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000021 LabeledMetricParameters dumpConfiguration() const override;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020022
23 private:
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010024 MetricValue& findMetric(interfaces::Sensor&);
25
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000026 std::shared_ptr<interfaces::Sensor> sensor;
27 OperationType operationType;
28 MetricValue reading;
Krzysztof Grobelny753e4b32021-02-11 12:58:58 +000029 CollectionTimeScope timeScope;
30 CollectionDuration collectionDuration;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020031};