Implement HostEpoch set time logic

1. When setting host epoch, follow below logic:

        Mode  | Owner | Set Host Time
        ----- | ----- | -------------
        NTP   | BMC   | Not allowed
        NTP   | HOST  | Not allowed
        NTP   | SPLIT | OK, and just save offset
        NTP   | BOTH  | Not allowed
        MANUAL| BMC   | Not allowed
        MANUAL| HOST  | OK, and set time to BMC
        MANUAL| SPLIT | OK, and just save offset
        MANUAL| BOTH  | OK, and set time to BMC

2. If owner is SPLIT and BMC time is changed, update the offset accordinly;
3. Use timerfd to get notified on BMC time change, and update host time
diff accordingly;
4. Add unit test cases.

Change-Id: I2d60a821f7da9b689c579ae7ab672cc37967322c
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/main.cpp b/main.cpp
index b8a5adb..1798dc0 100644
--- a/main.cpp
+++ b/main.cpp
@@ -8,6 +8,20 @@
 int main()
 {
     auto bus = sdbusplus::bus::new_default();
+    sd_event* event = nullptr;
+
+    auto eventDeleter = [](sd_event* e) {
+        e = sd_event_unref(e);
+    };
+    using SdEvent = std::unique_ptr<sd_event, decltype(eventDeleter)>;
+
+    // acquire a referece to the default event loop
+    sd_event_default(&event);
+    SdEvent sdEvent {event, eventDeleter};
+    event = nullptr;
+
+    // attach bus to this event loop
+    bus.attach_event(sdEvent.get(), SD_EVENT_PRIORITY_NORMAL);
 
     // Add sdbusplus ObjectManager
     sdbusplus::server::manager::manager bmcEpochObjManager(bus, OBJPATH_BMC);
@@ -19,13 +33,14 @@
 
     manager.addListener(&bmc);
     manager.addListener(&host);
+    bmc.setBmcTimeChangeListener(&host);
 
     bus.request_name(BUSNAME);
 
-    while (true)
-    {
-        bus.process_discard();
-        bus.wait();
-    }
+    // Start event loop for all sd-bus events and timer event
+    sd_event_loop(bus.get_event());
+
+    bus.detach_event();
+
     return 0;
 }