Trigger: make dbus properties writable

This change allows to modify 'Sensors', 'ReportNames' and 'Thresholds'
dbus properties of Trigger interface. They are required by Redfish to
implement PATCH functionality for Trigger schema.

Some backend changes were required to enable this functionality, and as
such few improvements were made for existing code:
- NumericThreshold and DiscreteThreshold now have common implementation
  where it was possible.
- Internal sensor info structure for Trigger is now the same as the one
  used for Report. This resulted in breaking compatibility with previous
  Trigger persistency data.
- Added getInfo / getParams methods for Sensor and Threshold interfaces.
  They are used by Trigger dbus getters and persistency mechanism now,
  instead of storing this data in Trigger object.

Testing done:
- Unit tests were expanded and are passing
- dbus setters for Sensors and Thresholds are working and modifications
  are reflected by calling appropriate getters.

Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I7a14c15a30d78ce872342b5f938aba43c77be9c0
diff --git a/src/trigger_factory.hpp b/src/trigger_factory.hpp
index 494f5ab..223efe0 100644
--- a/src/trigger_factory.hpp
+++ b/src/trigger_factory.hpp
@@ -2,8 +2,10 @@
 
 #include "interfaces/report_manager.hpp"
 #include "interfaces/sensor.hpp"
+#include "interfaces/threshold.hpp"
 #include "interfaces/trigger_factory.hpp"
 #include "sensor_cache.hpp"
+#include "utils/dbus_mapper.hpp"
 
 #include <sdbusplus/asio/object_server.hpp>
 
@@ -28,6 +30,19 @@
     std::vector<LabeledSensorInfo>
         getLabeledSensorsInfo(boost::asio::yield_context& yield,
                               const SensorsInfo& sensorsInfo) const override;
+    std::vector<LabeledSensorInfo>
+        getLabeledSensorsInfo(const SensorsInfo& sensorsInfo) const override;
+
+    void updateThresholds(
+        std::vector<std::shared_ptr<interfaces::Threshold>>& currentThresholds,
+        const std::vector<TriggerAction>& triggerActions,
+        const std::shared_ptr<std::vector<std::string>>& reportIds,
+        const Sensors& sensors,
+        const LabeledTriggerThresholdParams& newParams) const override;
+
+    void updateSensors(Sensors& currentSensors,
+                       const std::vector<LabeledSensorInfo>& labeledSensorsInfo)
+        const override;
 
   private:
     std::shared_ptr<sdbusplus::asio::connection> bus;
@@ -35,6 +50,44 @@
     SensorCache& sensorCache;
     interfaces::ReportManager& reportManager;
 
-    std::pair<Sensors, std::vector<std::string>> getSensors(
+    Sensors getSensors(
         const std::vector<LabeledSensorInfo>& labeledSensorsInfo) const;
+
+    static std::vector<LabeledSensorInfo>
+        parseSensorTree(const std::vector<utils::SensorTree>& tree,
+                        const SensorsInfo& sensorsInfo);
+
+    void updateDiscreteThresholds(
+        std::vector<std::shared_ptr<interfaces::Threshold>>& currentThresholds,
+        const std::vector<TriggerAction>& triggerActions,
+        const std::shared_ptr<std::vector<std::string>>& reportIds,
+        const Sensors& sensors,
+        const std::vector<discrete::LabeledThresholdParam>& newParams) const;
+
+    void updateNumericThresholds(
+        std::vector<std::shared_ptr<interfaces::Threshold>>& currentThresholds,
+        const std::vector<TriggerAction>& triggerActions,
+        const std::shared_ptr<std::vector<std::string>>& reportIds,
+        const Sensors& sensors,
+        const std::vector<numeric::LabeledThresholdParam>& newParams) const;
+
+    void makeDiscreteThreshold(
+        std::vector<std::shared_ptr<interfaces::Threshold>>& thresholds,
+        const std::vector<TriggerAction>& triggerActions,
+        const std::shared_ptr<std::vector<std::string>>& reportIds,
+        const Sensors& sensors,
+        const discrete::LabeledThresholdParam& thresholdParam) const;
+
+    void makeNumericThreshold(
+        std::vector<std::shared_ptr<interfaces::Threshold>>& thresholds,
+        const std::vector<TriggerAction>& triggerActions,
+        const std::shared_ptr<std::vector<std::string>>& reportIds,
+        const Sensors& sensors,
+        const numeric::LabeledThresholdParam& thresholdParam) const;
+
+    void makeOnChangeThreshold(
+        std::vector<std::shared_ptr<interfaces::Threshold>>& thresholds,
+        const std::vector<TriggerAction>& triggerActions,
+        const std::shared_ptr<std::vector<std::string>>& reportIds,
+        const Sensors& sensors) const;
 };