Save persistent triggers to storage

Create json storage file for persistent triggers.
Handle persistent dbus property.
Save/remove persistent triggers on add/delete.
Cover code with UTs.

Tested:
   - Passed unit tests
   - Tested on QEMU
     * adding new valid and invalid trigger from cli
     * verifying if valid trigger is properly stored
     * deleting existed trigger from storage

Change-Id: I243326e84833a8cb22075fbf565573b62b205b4a
Signed-off-by: Cezary Zwolak <cezary.zwolak@intel.com>
Signed-off-by: Lukasz Kazmierczak <lukasz.kazmierczak@intel.com>
diff --git a/src/trigger.hpp b/src/trigger.hpp
index 3405c5b..b2bdc1d 100644
--- a/src/trigger.hpp
+++ b/src/trigger.hpp
@@ -1,5 +1,6 @@
 #pragma once
 
+#include "interfaces/json_storage.hpp"
 #include "interfaces/threshold.hpp"
 #include "interfaces/trigger.hpp"
 #include "interfaces/trigger_manager.hpp"
@@ -23,7 +24,8 @@
         const std::vector<std::string>& reportNames,
         const TriggerThresholdParams& thresholdParams,
         std::vector<std::shared_ptr<interfaces::Threshold>>&& thresholds,
-        interfaces::TriggerManager& triggerManager);
+        interfaces::TriggerManager& triggerManager,
+        interfaces::JsonStorage& triggerStorage);
 
     Trigger(const Trigger&) = delete;
     Trigger(Trigger&&) = delete;
@@ -40,18 +42,26 @@
         return path;
     }
 
+    bool storeConfiguration() const;
+
   private:
     const std::string name;
+    bool isDiscrete;
+    bool logToJournal;
+    bool logToRedfish;
+    bool updateReport;
     const std::string path;
-    bool persistent;
-    std::vector<std::pair<sdbusplus::message::object_path, std::string>>
-        sensors;
+    bool persistent = false;
+    TriggerSensors sensors;
     std::vector<std::string> reportNames;
     TriggerThresholdParams thresholdParams;
     std::unique_ptr<sdbusplus::asio::dbus_interface> deleteIface;
     std::unique_ptr<sdbusplus::asio::dbus_interface> triggerIface;
     std::vector<std::shared_ptr<interfaces::Threshold>> thresholds;
 
+    interfaces::JsonStorage::FilePath fileName;
+    interfaces::JsonStorage& triggerStorage;
+
   public:
     static constexpr const char* triggerIfaceName =
         "xyz.openbmc_project.Telemetry.Trigger";
@@ -59,4 +69,5 @@
         "/xyz/openbmc_project/Telemetry/Triggers/";
     static constexpr const char* deleteIfaceName =
         "xyz.openbmc_project.Object.Delete";
+    static constexpr size_t triggerVersion = 0;
 };