created AddReportFutureVersion dbus method

New method will support CollectionTimeScope, CollectionDuration

In order to make not breaking interface changes bmcweb will switch to
AddReportFutureVersion, then AddReport will be changed to match
AddReportFutureVersion, then redfish will switch back to use AddReport,
then AddReportFutureVersion will be removed.

Tested:
  - Verified that current version of bmcweb works fine with old API

Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I51a9b7fb2f4da5b8d2f688ccd5e93710352b1ac7
diff --git a/src/report_factory.cpp b/src/report_factory.cpp
index 9dfdbb0..fb6edf9 100644
--- a/src/report_factory.cpp
+++ b/src/report_factory.cpp
@@ -16,24 +16,9 @@
 {}
 
 std::unique_ptr<interfaces::Report> ReportFactory::make(
-    boost::asio::yield_context& yield, const std::string& name,
-    const std::string& reportingType, bool emitsReadingsSignal,
-    bool logToMetricReportsCollection, std::chrono::milliseconds period,
-    const ReadingParameters& metricParams,
-    interfaces::ReportManager& reportManager,
-    interfaces::JsonStorage& reportStorage) const
-{
-    return make(name, reportingType, emitsReadingsSignal,
-                logToMetricReportsCollection, period, metricParams,
-                reportManager, reportStorage,
-                convertMetricParams(yield, metricParams));
-}
-
-std::unique_ptr<interfaces::Report> ReportFactory::make(
     const std::string& name, const std::string& reportingType,
     bool emitsReadingsSignal, bool logToMetricReportsCollection,
-    std::chrono::milliseconds period, const ReadingParameters& metricParams,
-    interfaces::ReportManager& reportManager,
+    Milliseconds period, interfaces::ReportManager& reportManager,
     interfaces::JsonStorage& reportStorage,
     std::vector<LabeledMetricParameters> labeledMetricParams) const
 {
@@ -41,25 +26,35 @@
         labeledMetricParams,
         [this](const LabeledMetricParameters& param)
             -> std::shared_ptr<interfaces::Metric> {
+            namespace ts = utils::tstring;
+
             return std::make_shared<Metric>(
-                getSensor(param.at_index<0>()), param.at_index<1>(),
-                param.at_index<2>(), param.at_index<3>());
+                getSensors(param.at_label<ts::SensorPath>()),
+                param.at_label<ts::OperationType>(), param.at_label<ts::Id>(),
+                param.at_label<ts::MetricMetadata>(),
+                param.at_label<ts::CollectionTimeScope>(),
+                param.at_label<ts::CollectionDuration>());
         });
 
     return std::make_unique<Report>(
         bus->get_io_context(), objServer, name, reportingType,
-        emitsReadingsSignal, logToMetricReportsCollection, period, metricParams,
+        emitsReadingsSignal, logToMetricReportsCollection, period,
         reportManager, reportStorage, std::move(metrics));
 }
 
-std::shared_ptr<interfaces::Sensor>
-    ReportFactory::getSensor(const LabeledSensorParameters& sensorPath) const
+Sensors ReportFactory::getSensors(
+    const std::vector<LabeledSensorParameters>& sensorPaths) const
 {
     using namespace utils::tstring;
 
-    return sensorCache.makeSensor<Sensor>(sensorPath.at_label<Service>(),
-                                          sensorPath.at_label<Path>(),
-                                          bus->get_io_context(), bus);
+    return utils::transform(sensorPaths,
+                            [this](const LabeledSensorParameters& sensorPath)
+                                -> std::shared_ptr<interfaces::Sensor> {
+                                return sensorCache.makeSensor<Sensor>(
+                                    sensorPath.at_label<Service>(),
+                                    sensorPath.at_label<Path>(),
+                                    bus->get_io_context(), bus);
+                            });
 }
 
 std::vector<LabeledMetricParameters> ReportFactory::convertMetricParams(
@@ -69,22 +64,35 @@
     auto tree = utils::getSubTreeSensors(yield, bus);
 
     return utils::transform(metricParams, [&tree](const auto& item) {
-        const auto& [sensorPath, operationType, id, metadata] = item;
+        const auto& [sensorPaths, operationType, id, metadata,
+                     collectionTimeScope, collectionDuration] = item;
 
-        auto it = std::find_if(
-            tree.begin(), tree.end(),
-            [&sensorPath](const auto& v) { return v.first == sensorPath; });
+        std::vector<LabeledSensorParameters> sensorParameters;
 
-        if (it != tree.end() && it->second.size() == 1)
+        for (const auto& sensorPath : sensorPaths)
         {
-            const auto& [service, ifaces] = it->second.front();
-            return LabeledMetricParameters(
-                LabeledSensorParameters(service, sensorPath),
-                utils::stringToOperationType(operationType), id, metadata);
+            auto it = std::find_if(
+                tree.begin(), tree.end(),
+                [&sensorPath](const auto& v) { return v.first == sensorPath; });
+
+            if (it != tree.end() && it->second.size() == 1)
+            {
+                const auto& [service, ifaces] = it->second.front();
+                sensorParameters.emplace_back(service, sensorPath);
+            }
         }
 
-        throw sdbusplus::exception::SdBusError(
-            static_cast<int>(std::errc::invalid_argument),
-            "Could not find service for provided sensors");
+        if (sensorParameters.size() != sensorPaths.size())
+        {
+            throw sdbusplus::exception::SdBusError(
+                static_cast<int>(std::errc::invalid_argument),
+                "Could not find service for provided sensors");
+        }
+
+        return LabeledMetricParameters(
+            std::move(sensorParameters),
+            utils::stringToOperationType(operationType), id, metadata,
+            utils::stringToCollectionTimeScope(collectionTimeScope),
+            CollectionDuration(Milliseconds(collectionDuration)));
     });
 }