blob: aab4d15e8d48e5e98f65c9438a5527a687c9c709 [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,
14 OperationType operationType, std::string id, std::string metadata);
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020015
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010016 void initialize() override;
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000017 const MetricValue& getReading() const override;
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010018 void sensorUpdated(interfaces::Sensor&, uint64_t) override;
19 void sensorUpdated(interfaces::Sensor&, uint64_t, double value) override;
Krzysztof Grobelnyd2238192020-12-02 09:27:28 +000020 LabeledMetricParameters dumpConfiguration() const override;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020021
22 private:
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010023 MetricValue& findMetric(interfaces::Sensor&);
24
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000025 std::shared_ptr<interfaces::Sensor> sensor;
26 OperationType operationType;
27 MetricValue reading;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020028};