Let PowerState class run multiple callbacks

Previously the PowerState class could only handle a single callback
function.  This commit changes that to allow other callback functions to
be added with a addCallback() method.  The callback functions are then
executed when the power state changes.

This also changes the use of the PowerState object in the fan presence
code to a shared_ptr instead of a unique_ptr, and adds a function to
return the PowerState object to use in the app, creating it if
necessary.  This allows multiple pieces of the code to add their own
callbacks to the same object.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I35fc8ab94c4806f0c7fd2f1552c58131b8f30f23
diff --git a/presence/get_power_state.cpp b/presence/get_power_state.cpp
new file mode 100644
index 0000000..f1d913f
--- /dev/null
+++ b/presence/get_power_state.cpp
@@ -0,0 +1,17 @@
+#include "power_state.hpp"
+
+namespace phosphor::fan
+{
+
+std::shared_ptr<PowerState> powerState;
+
+std::shared_ptr<PowerState> getPowerStateObject()
+{
+    if (!powerState)
+    {
+        powerState = std::make_shared<PGoodState>();
+    }
+    return powerState;
+}
+
+} // namespace phosphor::fan