Add storeGroups/restoreGroups method to LED Manager

Use CEREAL to storeGroup/restoreGroups the current state of
asserted groups.
Call storeGroups() when the request comes to add to(remove from)
asserted group.
Call restoreGroups() as part of starting LED Manager daemon.

Tested: Manually set the Asserted property of each group to true,
after rebooting, all property values tested with the busctl command
are still true.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ibeb1de5f51e3d67e98eeea34764e9efc6d6d8b35
diff --git a/serialize.hpp b/serialize.hpp
new file mode 100644
index 0000000..23cffa2
--- /dev/null
+++ b/serialize.hpp
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <filesystem>
+#include <fstream>
+#include <set>
+#include <string>
+
+namespace phosphor
+{
+namespace led
+{
+
+namespace fs = std::filesystem;
+
+// the set of names of asserted groups, which contains the D-Bus Object path
+using SavedGroups = std::set<std::string>;
+
+/** @class Serialize
+ *  @brief Store and restore groups of LEDs
+ */
+class Serialize
+{
+  public:
+    Serialize(const fs::path& path) : path(path)
+    {
+        restoreGroups();
+    }
+
+    /** @brief Store asserted group names to SAVED_GROUPS_FILE
+     *
+     *  @param [in] group     - name of the group
+     *  @param [in] asserted  - asserted state, true or false
+     */
+    void storeGroups(const std::string& group, bool asserted);
+
+    /** @brief Is the group in asserted state stored in SAVED_GROUPS_FILE
+     *
+     *  @param [in] objPath - The D-Bus path that hosts LED group
+     *
+     *  @return             - true: exist, false: does not exist
+     */
+    bool getGroupSavedState(const std::string& objPath) const;
+
+  private:
+    /** @brief restore asserted group names from SAVED_GROUPS_FILE
+     */
+    void restoreGroups();
+
+    /** @brief the set of names of asserted groups */
+    SavedGroups savedGroups;
+
+    /** @brief the path of file for storing the names of asserted groups */
+    fs::path path;
+};
+
+} // namespace led
+} // namespace phosphor