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.cpp b/bmc_epoch.cpp
index 9fc3097..db4051a 100644
--- a/bmc_epoch.cpp
+++ b/bmc_epoch.cpp
@@ -9,6 +9,7 @@
 #include <phosphor-logging/elog.hpp>
 #include <phosphor-logging/lg2.hpp>
 #include <xyz/openbmc_project/Common/error.hpp>
+#include <xyz/openbmc_project/Time/error.hpp>
 
 // Need to do this since its not exported outside of the kernel.
 // Refer : https://gist.github.com/lethean/446cea944b7441228298
@@ -23,15 +24,17 @@
 {
 namespace time
 {
+namespace // anonymous
+{
+constexpr auto SYSTEMD_TIME_SERVICE = "org.freedesktop.timedate1";
+constexpr auto SYSTEMD_TIME_PATH = "/org/freedesktop/timedate1";
+constexpr auto SYSTEMD_TIME_INTERFACE = "org.freedesktop.timedate1";
+constexpr auto METHOD_SET_TIME = "SetTime";
+} // namespace
+
 namespace server = sdbusplus::xyz::openbmc_project::Time::server;
 using namespace phosphor::logging;
-
-BmcEpoch::BmcEpoch(sdbusplus::bus_t& bus, const char* objPath,
-                   Manager& manager) :
-    EpochBase(bus, objPath, manager)
-{
-    initialize();
-}
+using FailedError = sdbusplus::xyz::openbmc_project::Time::Error::Failed;
 
 void BmcEpoch::initialize()
 {
@@ -109,5 +112,37 @@
     return 0;
 }
 
+void BmcEpoch::onModeChanged(Mode mode)
+{
+    manager.setTimeMode(mode);
+}
+
+bool BmcEpoch::setTime(const microseconds& usec)
+{
+    auto method = bus.new_method_call(SYSTEMD_TIME_SERVICE, SYSTEMD_TIME_PATH,
+                                      SYSTEMD_TIME_INTERFACE, METHOD_SET_TIME);
+    method.append(static_cast<int64_t>(usec.count()),
+                  false,  // relative
+                  false); // user_interaction
+
+    try
+    {
+        bus.call_noreply(method);
+    }
+    catch (const sdbusplus::exception_t& ex)
+    {
+        lg2::error("Error in setting system time: {ERROR}", "ERROR", ex);
+        using namespace xyz::openbmc_project::Time;
+        elog<FailedError>(Failed::REASON(ex.what()));
+    }
+    return true;
+}
+
+microseconds BmcEpoch::getTime() const
+{
+    auto now = system_clock::now();
+    return duration_cast<microseconds>(now.time_since_epoch());
+}
+
 } // namespace time
 } // namespace phosphor
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;
diff --git a/epoch_base.cpp b/epoch_base.cpp
deleted file mode 100644
index 1761bea..0000000
--- a/epoch_base.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "epoch_base.hpp"
-
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/lg2.hpp>
-#include <xyz/openbmc_project/Time/error.hpp>
-
-#include <iomanip>
-#include <sstream>
-
-namespace // anonymous
-{
-constexpr auto SYSTEMD_TIME_SERVICE = "org.freedesktop.timedate1";
-constexpr auto SYSTEMD_TIME_PATH = "/org/freedesktop/timedate1";
-constexpr auto SYSTEMD_TIME_INTERFACE = "org.freedesktop.timedate1";
-constexpr auto METHOD_SET_TIME = "SetTime";
-} // namespace
-
-namespace phosphor
-{
-namespace time
-{
-
-using namespace phosphor::logging;
-using FailedError = sdbusplus::xyz::openbmc_project::Time::Error::Failed;
-
-EpochBase::EpochBase(sdbusplus::bus_t& bus, const char* objPath,
-                     Manager& manager) :
-    sdbusplus::server::object_t<EpochTime>(bus, objPath),
-    bus(bus), manager(manager)
-{}
-
-void EpochBase::onModeChanged(Mode mode)
-{
-    manager.setTimeMode(mode);
-}
-
-using namespace std::chrono;
-bool EpochBase::setTime(const microseconds& usec)
-{
-    auto method = bus.new_method_call(SYSTEMD_TIME_SERVICE, SYSTEMD_TIME_PATH,
-                                      SYSTEMD_TIME_INTERFACE, METHOD_SET_TIME);
-    method.append(static_cast<int64_t>(usec.count()),
-                  false,  // relative
-                  false); // user_interaction
-
-    try
-    {
-        bus.call_noreply(method);
-    }
-    catch (const sdbusplus::exception_t& ex)
-    {
-        lg2::error("Error in setting system time: {ERROR}", "ERROR", ex);
-        using namespace xyz::openbmc_project::Time;
-        elog<FailedError>(Failed::REASON(ex.what()));
-    }
-    return true;
-}
-
-microseconds EpochBase::getTime() const
-{
-    auto now = system_clock::now();
-    return duration_cast<microseconds>(now.time_since_epoch());
-}
-
-} // namespace time
-} // namespace phosphor
diff --git a/epoch_base.hpp b/epoch_base.hpp
deleted file mode 100644
index 9c2a9e0..0000000
--- a/epoch_base.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-#pragma once
-
-#include "config.h"
-
-#include "manager.hpp"
-#include "property_change_listener.hpp"
-
-#include <sdbusplus/bus.hpp>
-#include <xyz/openbmc_project/Time/EpochTime/server.hpp>
-
-#include <chrono>
-
-namespace phosphor
-{
-namespace time
-{
-
-/** @class EpochBase
- *  @brief Base class for OpenBMC EpochTime implementation.
- *  @details A base class that implements xyz.openbmc_project.Time.EpochTime
- *  DBus API for epoch time.
- */
-class EpochBase :
-    public sdbusplus::server::object_t<
-        sdbusplus::xyz::openbmc_project::Time::server::EpochTime>,
-    public PropertyChangeListner
-{
-  public:
-    EpochBase(sdbusplus::bus_t& bus, const char* objPath, Manager& manager);
-
-    /** @brief Notified on time mode changed */
-    void onModeChanged(Mode mode) 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;
-};
-
-} // namespace time
-} // namespace phosphor
diff --git a/meson.build b/meson.build
index dffc259..a58580a 100644
--- a/meson.build
+++ b/meson.build
@@ -51,7 +51,6 @@
 # Gather sources for the target binaries
 
 phosphor_time_manager_sources = [
-                                 'epoch_base.cpp',
                                  'bmc_epoch.cpp',
                                  'manager.cpp',
                                  'utils.cpp',