#pragma once #include "interfaces/clock.hpp" #include "interfaces/metric.hpp" #include "interfaces/metric_listener.hpp" #include "interfaces/sensor.hpp" #include "interfaces/sensor_listener.hpp" #include "metrics/collection_data.hpp" #include "types/collection_duration.hpp" class Metric : public interfaces::Metric, public interfaces::SensorListener, public std::enable_shared_from_this { public: Metric(Sensors sensors, OperationType operationType, CollectionTimeScope, CollectionDuration, std::unique_ptr); void initialize() override; void deinitialize() override; const std::vector& getUpdatedReadings() override; void sensorUpdated(interfaces::Sensor&, Milliseconds, double value) override; LabeledMetricParameters dumpConfiguration() const override; uint64_t metricCount() const override; void registerForUpdates(interfaces::MetricListener& listener) override; void unregisterFromUpdates(interfaces::MetricListener& listener) override; void updateReadings(Milliseconds) override; bool isTimerRequired() const override; private: metrics::CollectionData& findAssociatedData(const interfaces::Sensor& notifier); std::vector readings; Sensors sensors; OperationType operationType; CollectionTimeScope collectionTimeScope; CollectionDuration collectionDuration; std::vector> collectionAlgorithms; std::unique_ptr clock; std::vector> listeners; };