Review fixes for 'Created metric class'
- Changed metric to_json to dumpConfiguration returning LabeledTuple
- LabeledTuple can be created and assigned directly to json
- LabeledTuple can be readed from json using json.get<LabeledTuple>
- Added PrintTo for LabeledMetricParams, LabeledSensorParams
- Added helper method expectMake to ReportFactoryMock
- sensorPaths are serialized to tuple<service, path> instead of single
field with service and path separated via ':'
- Changed configuration version from 1 to 2
Change-Id: I7c45fb584687172f88fd549a93329264793b0b8e
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/interfaces/metric.hpp b/src/interfaces/metric.hpp
index d63c979..5a960a4 100644
--- a/src/interfaces/metric.hpp
+++ b/src/interfaces/metric.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "interfaces/types.hpp"
#include "metric_value.hpp"
#include <nlohmann/json.hpp>
@@ -16,7 +17,7 @@
virtual void initialize() = 0;
virtual const std::vector<MetricValue>& getReadings() const = 0;
- virtual nlohmann::json to_json() const = 0;
+ virtual LabeledMetricParameters dumpConfiguration() const = 0;
};
} // namespace interfaces
diff --git a/src/interfaces/report_factory.hpp b/src/interfaces/report_factory.hpp
index 056c9e0..237ae7b 100644
--- a/src/interfaces/report_factory.hpp
+++ b/src/interfaces/report_factory.hpp
@@ -20,11 +20,17 @@
virtual ~ReportFactory() = default;
virtual std::unique_ptr<interfaces::Report> make(
- std::optional<std::reference_wrapper<boost::asio::yield_context>> yield,
+ boost::asio::yield_context& yield, const std::string& name,
+ const std::string& reportingType, bool emitsReadingsSignal,
+ bool logToMetricReportsCollection, std::chrono::milliseconds period,
+ const ReadingParameters& metricParams, ReportManager& reportManager,
+ JsonStorage& reportStorage) const = 0;
+ virtual std::unique_ptr<interfaces::Report> make(
const std::string& name, const std::string& reportingType,
bool emitsReadingsSignal, bool logToMetricReportsCollection,
std::chrono::milliseconds period, const ReadingParameters& metricParams,
- ReportManager& reportManager, JsonStorage& reportStorage) const = 0;
+ ReportManager& reportManager, JsonStorage& reportStorage,
+ std::vector<LabeledMetricParameters> labeledMetricParams) const = 0;
};
} // namespace interfaces
diff --git a/src/interfaces/types.hpp b/src/interfaces/types.hpp
index 1eca51a..de97353 100644
--- a/src/interfaces/types.hpp
+++ b/src/interfaces/types.hpp
@@ -13,8 +13,13 @@
std::vector<std::tuple<std::vector<sdbusplus::message::object_path>,
std::string, std::string, std::string>>;
-using LabeledReadingParameter =
- utils::LabeledTuple<ReadingParameters::value_type,
+using LabeledSensorParameters =
+ utils::LabeledTuple<std::tuple<std::string, std::string>,
+ utils::tstring::Service, utils::tstring::Path>;
+
+using LabeledMetricParameters =
+ utils::LabeledTuple<std::tuple<std::vector<LabeledSensorParameters>,
+ std::string, std::string, std::string>,
utils::tstring::SensorPaths,
utils::tstring::OperationType, utils::tstring::Id,
utils::tstring::MetricMetadata>;