Remove the inheritance between epoch base and bmc epoch
The epoch_base exists because it was managing bmc_time and host_time
before, and now the host_time has been removed, so the dependency on
epoch_base and bmc_epoch should be removed.
Tested: Built phosphor-time-manager successfully and CI passed.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Iff87f18d450095f8a673b2d73c50092c65adca20
diff --git a/bmc_epoch.hpp b/bmc_epoch.hpp
index 10dbf7b..2c5d501 100644
--- a/bmc_epoch.hpp
+++ b/bmc_epoch.hpp
@@ -1,6 +1,10 @@
#pragma once
-#include "epoch_base.hpp"
+#include "manager.hpp"
+#include "property_change_listener.hpp"
+
+#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Time/EpochTime/server.hpp>
#include <chrono>
@@ -11,17 +15,28 @@
using namespace std::chrono;
+using EpochTimeIntf = sdbusplus::server::object_t<
+ sdbusplus::xyz::openbmc_project::Time::server::EpochTime>;
+
/** @class BmcEpoch
* @brief OpenBMC BMC EpochTime implementation.
- * @details A concrete implementation for xyz.openbmc_project.Time.EpochTime
- * DBus API for BMC's epoch time.
+ * @details A concrete implementation for
+ * xyz.openbmc_project.Time.EpochTime DBus API for BMC's epoch time.
*/
-class BmcEpoch : public EpochBase
+class BmcEpoch : public EpochTimeIntf, public PropertyChangeListner
{
public:
- BmcEpoch(sdbusplus::bus_t& bus, const char* objPath, Manager& manager);
+ BmcEpoch(sdbusplus::bus_t& bus, const char* objPath, Manager& manager) :
+ EpochTimeIntf(bus, objPath), bus(bus), manager(manager)
+ {
+ initialize();
+ }
+
~BmcEpoch();
+ /** @brief Notified on time mode changed */
+ void onModeChanged(Mode mode) override;
+
/**
* @brief Get value of Elapsed property
*
@@ -37,6 +52,30 @@
**/
uint64_t elapsed(uint64_t value) override;
+ protected:
+ /** @brief Persistent sdbusplus DBus connection */
+ sdbusplus::bus_t& bus;
+
+ /** @brief The manager to handle OpenBMC time */
+ Manager& manager;
+
+ /** @brief Set current time to system
+ *
+ * This function set the time to system by invoking systemd
+ * org.freedesktop.timedate1's SetTime method.
+ *
+ * @param[in] timeOfDayUsec - Microseconds since UTC
+ *
+ * @return true or false to indicate if it sets time successfully
+ */
+ bool setTime(const std::chrono::microseconds& timeOfDayUsec);
+
+ /** @brief Get current time
+ *
+ * @return Microseconds since UTC
+ */
+ std::chrono::microseconds getTime() const;
+
private:
/** @brief The fd for time change event */
int timeFd = -1;