Add support for AppendLimit and ReportUpdates

Added 2 new properties for Report interface: AppendLimit and
ReportUpdates. They were also added as arguments to the future version
of AddReport method of ReportManager.

ReportUpdates property defines the report update behavior:
- Overwrite: Each report update overrides previous "Readings" property.
  "AppendLimit" set by user is not respected - "Readings" property size
  is equal to count of all sensor across all metrics defined in report.
- AppendWrapsWhenFull: New readings are appended until limit specified
  by "AppendLimit" is reached. Then oldest readings are overwritten by
  new ones.
- AppendStopsWhenFull: New readings are appended until limit specified
  by "AppendLimit" is reached. Then updates are stopped.
- NewReport: not supported yet and will be implemented in the future.

Please note that if ReportingType is set to OnRequest, those 2 new
properties are ignored, and Readings property will contain one reading
per defined sensor, across all metrics. They are still stored, which
means that if ReportingType will be changed in the runtime, those
properties will be respected.

Tested:
- Both new properties can be accessed from dbus.
- Both properties are reflected in Readings property.
- Old AddReport method is working as before the change.
- UTs are passing.

Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I8a18f7e68215f0f6e5c403b533d2c4ff479df69e
diff --git a/src/report.hpp b/src/report.hpp
index 18574cf..c758988 100644
--- a/src/report.hpp
+++ b/src/report.hpp
@@ -5,6 +5,7 @@
 #include "interfaces/report.hpp"
 #include "interfaces/report_manager.hpp"
 #include "types/report_types.hpp"
+#include "utils/circular_vector.hpp"
 
 #include <boost/asio/io_context.hpp>
 #include <boost/asio/steady_timer.hpp>
@@ -18,9 +19,10 @@
   public:
     Report(boost::asio::io_context& ioc,
            const std::shared_ptr<sdbusplus::asio::object_server>& objServer,
-           const std::string& reportName, const std::string& reportingType,
+           const std::string& reportName, const ReportingType reportingType,
            const bool emitsReadingsSignal,
            const bool logToMetricReportsCollection, const Milliseconds period,
+           const uint64_t appendLimitIn, const ReportUpdates reportUpdatesIn,
            interfaces::ReportManager& reportManager,
            interfaces::JsonStorage& reportStorage,
            std::vector<std::shared_ptr<interfaces::Metric>> metrics,
@@ -49,17 +51,26 @@
     std::unique_ptr<sdbusplus::asio::dbus_interface> makeReportInterface();
     static void timerProc(boost::system::error_code, Report& self);
     void scheduleTimer(Milliseconds interval);
+    uint64_t deduceAppendLimit(const uint64_t appendLimitIn) const;
+    uint64_t deduceBufferSize(const ReportUpdates reportUpdatesIn,
+                              const ReportingType reportingTypeIn) const;
+    void setReportUpdates(const ReportUpdates newReportUpdates);
+    static uint64_t getSensorCount(
+        std::vector<std::shared_ptr<interfaces::Metric>>& metrics);
 
     std::string name;
     std::string path;
-    std::string reportingType;
+    ReportingType reportingType;
     Milliseconds interval;
     bool emitsReadingsUpdate;
     bool logToMetricReportsCollection;
     ReadingParametersPastVersion readingParametersPastVersion;
     ReadingParameters readingParameters;
     bool persistency = false;
-    Readings cachedReadings = {};
+    uint64_t sensorCount;
+    uint64_t appendLimit;
+    ReportUpdates reportUpdates;
+    CircularVector<ReadingData> readingsBuffer;
     Readings readings = {};
     std::shared_ptr<sdbusplus::asio::object_server> objServer;
     std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface;