Utils: add optional callback for power state changes

Some systems require sensors to be instantiated and destroyed on host
power state transitions; this plumbing provides infrastructure for
dbus-sensors daemons to be notified on power state changes so they can
respond appropriately.

Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I2fc24c91e6d62bb3da71928ef0761760cc90e75f
diff --git a/include/Utils.hpp b/include/Utils.hpp
index b823e5b..fdd1d8d 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -48,6 +48,13 @@
     return boost::replace_all_copy(sensorName, " ", "_");
 }
 
+enum class PowerState
+{
+    on,
+    biosPost,
+    always
+};
+
 std::optional<std::string> openAndRead(const std::string& hwmonFile);
 std::optional<std::string>
     getFullHwmonFilePath(const std::string& directory,
@@ -60,6 +67,9 @@
                int symlinkDepth = 1);
 bool isPowerOn(void);
 bool hasBiosPost(void);
+void setupPowerMatchCallback(
+    const std::shared_ptr<sdbusplus::asio::connection>& conn,
+    std::function<void(PowerState type, bool state)>&& callback);
 void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn);
 bool getSensorConfiguration(
     const std::string& type,
@@ -79,13 +89,6 @@
 void findLimits(std::pair<double, double>& limits,
                 const SensorBaseConfiguration* data);
 
-enum class PowerState
-{
-    on,
-    biosPost,
-    always
-};
-
 bool readingStateGood(const PowerState& powerState);
 
 namespace mapper