blob: 08684dabb4350cc905eb895531e7d7e4529752d5 [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 Grobelnydcc4e192021-03-08 09:09:34 +000013 Metric(Sensors sensors, OperationType operationType, std::string id,
14 std::string metadata, CollectionTimeScope, CollectionDuration);
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020015
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010016 void initialize() override;
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000017 const std::vector<MetricValue>& getReadings() 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 Grobelnydcc4e192021-03-08 09:09:34 +000023 void tryUnpackJsonMetadata();
24
Krzysztof Grobelny6ccfcbf2020-11-04 09:31:36 +010025 MetricValue& findMetric(interfaces::Sensor&);
26
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000027 std::string id;
28 std::string metadata;
29 std::vector<MetricValue> readings;
30 Sensors sensors;
Krzysztof Grobelnye8fc5752021-02-05 14:30:45 +000031 OperationType operationType;
Krzysztof Grobelnydcc4e192021-03-08 09:09:34 +000032 CollectionTimeScope timeScope;
33 CollectionDuration collectionDuration;
Krzysztof Grobelnyc8e3a642020-10-23 12:29:16 +020034};