sched-host-tran: store/restore the value of scheduled time and
requested transition

Store/restore the value of scheduled time and requested transition, in case
BMC is rebooted. After BMC is back, go on the host transition process based
on the stored values.

Tested:
1. Get current time
 # date
   Tue Mar 10 08:16:40 UTC 2020
2. Set scheduled time 08:25:00
 # busctl set-property xyz.openbmc_project.State.ScheduledHostTransition \
   /xyz/openbmc_project/state/host0 \
   xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime t 1583828700
3. Reboot BMC
4. Check sheduled time
 # busctl get-property xyz.openbmc_project.State.ScheduledHostTransition \
   /xyz/openbmc_project/state/host0 \
   xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime
   t 1583828700
5. Do host transition after the scheduled time is reached.
6. Check the scheduled time again
  # busctl get-property xyz.openbmc_project.State.ScheduledHostTransition \
    /xyz/openbmc_project/state/host0 \
    xyz.openbmc_project.State.ScheduledHostTransition ScheduledTime
    t 0

Change-Id: I3bbae19a49e2fe84bf4e297e6daaa0461cbf2cb8
Signed-off-by: Carol Wang <wangkair@cn.ibm.com>
diff --git a/scheduled_host_transition.hpp b/scheduled_host_transition.hpp
index a17ca3b..b42c5ae 100644
--- a/scheduled_host_transition.hpp
+++ b/scheduled_host_transition.hpp
@@ -31,11 +31,16 @@
   public:
     ScheduledHostTransition(sdbusplus::bus::bus& bus, const char* objPath,
                             const sdeventplus::Event& event) :
-        ScheduledHostTransitionInherit(bus, objPath),
+        ScheduledHostTransitionInherit(bus, objPath, true),
         bus(bus), event(event),
         timer(event, std::bind(&ScheduledHostTransition::callback, this))
     {
         initialize();
+
+        restoreScheduledValues();
+
+        // We deferred this until we could get our property correct
+        this->emit_object_added();
     }
 
     ~ScheduledHostTransition();
@@ -111,6 +116,22 @@
 
     /** @brief Handle with the process when bmc time is changed*/
     void handleTimeUpdates();
+
+    /** @brief Serialize the scheduled values */
+    void serializeScheduledValues();
+
+    /** @brief Deserialize the scheduled values
+     *
+     *  @param[out] time - Deserialized scheduled time
+     *  @param[out] trans - Deserialized requested transition
+     *
+     *  @return bool - true if successful, false otherwise
+     */
+    bool deserializeScheduledValues(uint64_t& time, Transition& trans);
+
+    /** @brief Restore scheduled time and requested transition from persisted
+     * file */
+    void restoreScheduledValues();
 };
 } // namespace manager
 } // namespace state