blob: 39f525c5485b03b506cdc38fc9e2eb25f1fa7a87 [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 Grobelny6ccfcbf2020-11-04 09:31:36 +010013 Metric(std::vector<std::shared_ptr<interfaces::Sensor>> sensors,
14 std::string 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;
17 const std::vector<MetricValue>& getReadings() const override;
18 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
25 std::vector<std::shared_ptr<interfaces::Sensor>> sensors;
26 std::string operationType;
27 std::string id;
28 std::string metadata;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020029 std::vector<MetricValue> readings;
30};