PowerStatusMonitor: create DBus match in ctor

On request [1], create this change to create the DBus match for our
power status monitor in its constructor.

We get rid of the invalid state of the match not existing and can drop a
check for it.

We can also drop a call in 'main' function previously used to initialize
the match. The public API of this class is simplified.

Tested: Inspection only.

References:
[1] https://gerrit.openbmc.org/c/openbmc/entity-manager/+/81483/comment/858d95be_e2f9f6b8/

Change-Id: Ib05941a90ba2520b25e2c2b1e9a1e325caa722ae
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/power_status_monitor.cpp b/src/entity_manager/power_status_monitor.cpp
index 93617d2..b281602 100644
--- a/src/entity_manager/power_status_monitor.cpp
+++ b/src/entity_manager/power_status_monitor.cpp
@@ -15,12 +15,21 @@
 const static constexpr char* path = "/xyz/openbmc_project/state/host0";
 const static constexpr char* property = "CurrentHostState";
 
-bool PowerStatusMonitor::isPowerOn()
+PowerStatusMonitor::PowerStatusMonitor(sdbusplus::asio::connection& conn) :
+
+    powerMatch(static_cast<sdbusplus::bus_t&>(conn),
+               "type='signal',interface='" +
+                   std::string(em_utils::properties::interface) + "',path='" +
+                   std::string(power::path) + "',arg0='" +
+                   std::string(power::interface) + "'",
+               std::bind_front(&PowerStatusMonitor::handlePowerMatch, this))
+
 {
-    if (!powerMatch)
-    {
-        throw std::runtime_error("Power Match Not Created");
-    }
+    getInitialPowerStatus(conn);
+}
+
+bool PowerStatusMonitor::isPowerOn() const
+{
     return powerStatusOn;
 }
 
@@ -39,18 +48,10 @@
     }
 }
 
-void PowerStatusMonitor::setupPowerMatch(
-    const std::shared_ptr<sdbusplus::asio::connection>& conn)
+void PowerStatusMonitor::getInitialPowerStatus(
+    sdbusplus::asio::connection& conn)
 {
-    powerMatch = std::make_unique<sdbusplus::bus::match_t>(
-        static_cast<sdbusplus::bus_t&>(*conn),
-        "type='signal',interface='" +
-            std::string(em_utils::properties::interface) + "',path='" +
-            std::string(power::path) + "',arg0='" +
-            std::string(power::interface) + "'",
-        std::bind_front(&PowerStatusMonitor::handlePowerMatch, this));
-
-    conn->async_method_call(
+    conn.async_method_call(
         [this](boost::system::error_code ec,
                const std::variant<std::string>& state) {
             if (ec)