made MetricValues persistent

MetricValues are persistent for reportUpdates AppendStopsWhenFull and
reportingType different than OnRequest.

Tested:
- New unit tests are passing
- Confirmed MetricValues are preserved after restarting telemetry
  service

Change-Id: I7e1990fb391da9debb0d7df2f1dbda86473350cc
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/src/types/readings.cpp b/src/types/readings.cpp
new file mode 100644
index 0000000..2f6246b
--- /dev/null
+++ b/src/types/readings.cpp
@@ -0,0 +1,28 @@
+#include "types/readings.hpp"
+
+#include "utils/transform.hpp"
+
+namespace utils
+{
+
+namespace ts = utils::tstring;
+
+LabeledReadings toLabeledReadings(const Readings& readings)
+{
+    return LabeledReadings{
+        std::get<0>(readings),
+        utils::transform(std::get<1>(readings), [](const auto& readingData) {
+            return LabeledReadingData{readingData};
+        })};
+}
+
+Readings toReadings(const LabeledReadings& labeledReadings)
+{
+    return Readings{labeledReadings.at_label<ts::Timestamp>(),
+                    utils::transform(labeledReadings.at_label<ts::Readings>(),
+                                     [](const auto& labeledReadingData) {
+                                         return labeledReadingData.to_tuple();
+                                     })};
+}
+
+} // namespace utils
diff --git a/src/types/readings.hpp b/src/types/readings.hpp
new file mode 100644
index 0000000..6749bbf
--- /dev/null
+++ b/src/types/readings.hpp
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "utils/labeled_tuple.hpp"
+#include "utils/tstring.hpp"
+
+using ReadingData = std::tuple<std::string, std::string, double, uint64_t>;
+using Readings = std::tuple<uint64_t, std::vector<ReadingData>>;
+
+using LabeledReadingData =
+    utils::LabeledTuple<ReadingData, utils::tstring::MetricId,
+                        utils::tstring::MetricProperty,
+                        utils::tstring::MetricValue, utils::tstring::Timestamp>;
+
+using LabeledReadings =
+    utils::LabeledTuple<std::tuple<uint64_t, std::vector<LabeledReadingData>>,
+                        utils::tstring::Timestamp, utils::tstring::Readings>;
+
+namespace utils
+{
+
+LabeledReadings toLabeledReadings(const Readings&);
+Readings toReadings(const LabeledReadings&);
+
+} // namespace utils
diff --git a/src/types/report_types.hpp b/src/types/report_types.hpp
index c0f7b39..d927d0e 100644
--- a/src/types/report_types.hpp
+++ b/src/types/report_types.hpp
@@ -30,9 +30,5 @@
     utils::tstring::Id, utils::tstring::CollectionTimeScope,
     utils::tstring::CollectionDuration>;
 
-using ReadingData = std::tuple<std::string, std::string, double, uint64_t>;
-
-using Readings = std::tuple<uint64_t, std::vector<ReadingData>>;
-
 ReadingParameters
     toReadingParameters(const std::vector<LabeledMetricParameters>& labeled);