1 #pragma once 2 3 #include "interfaces/metric.hpp" 4 #include "interfaces/sensor.hpp" 5 #include "interfaces/sensor_listener.hpp" 6 7 class Metric : 8 public interfaces::Metric, 9 public interfaces::SensorListener, 10 public std::enable_shared_from_this<Metric> 11 { 12 public: 13 Metric(Sensors sensors, OperationType operationType, std::string id, 14 std::string metadata, CollectionTimeScope, CollectionDuration); 15 16 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; 20 LabeledMetricParameters dumpConfiguration() const override; 21 22 private: 23 void tryUnpackJsonMetadata(); 24 25 MetricValue& findMetric(interfaces::Sensor&); 26 27 std::string id; 28 std::string metadata; 29 std::vector<MetricValue> readings; 30 Sensors sensors; 31 OperationType operationType; 32 CollectionTimeScope timeScope; 33 CollectionDuration collectionDuration; 34 }; 35