Update PowerSupply to be derived from Device

The PowerSupply will pass a name and instance number down to the Device
class it is derived from, but will also have an inventory path and a
path to monitor for PMBus interfaces.

Change-Id: I29f875fda1f07d031b58ec7ffd381d655495f248
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.hpp b/power-supply/power_supply.hpp
index 1eab5c4..4249024 100644
--- a/power-supply/power_supply.hpp
+++ b/power-supply/power_supply.hpp
@@ -1,6 +1,7 @@
 #pragma once
+#include "device.hpp"
 
-namespace phosphor
+namespace witherspoon
 {
 namespace power
 {
@@ -9,18 +10,61 @@
 
 /**
  * @class PowerSupply
- * Represents a PMBus power supply.
+ * Represents a PMBus power supply device.
  */
-class PowerSupply
+class PowerSupply : public Device
 {
     public:
         PowerSupply() = delete;
         PowerSupply(const PowerSupply&) = delete;
-        PowerSupply& operator=(const PowerSupply&) = delete;
         PowerSupply(PowerSupply&&) = default;
+        PowerSupply& operator=(const PowerSupply&) = default;
         PowerSupply& operator=(PowerSupply&&) = default;
         ~PowerSupply() = default;
 
+        /**
+         * Constructor
+         *
+         * @param[in] name - the device name
+         * @param[in] inst - the device instance
+         * @param[in] objpath - the path to monitor
+         * @param[in] invpath - the inventory path to use
+         */
+        PowerSupply(const std::string& name, size_t inst,
+                    const std::string& objpath, const std::string& invpath)
+            : Device(name, inst), monitorPath(objpath), inventoryPath(invpath)
+        {
+        }
+
+        /**
+         * Power supply specific function to analyze for faults/errors.
+         *
+         * Various PMBus status bits will be checked for fault conditions.
+         * If a certain fault bits are on, the appropriate error will be
+         * committed.
+         */
+        void analyze() override;
+
+        /**
+         * Write PMBus CLEAR_FAULTS
+         *
+         * This function will be called in various situations in order to clear
+         * any fault status bits that may have been set, in order to start over
+         * with a clean state. Presence changes and power state changes will
+         * want to clear any faults logged.
+         */
+        void clearFaults() override;
+
+    private:
+        /**
+         * The path to use for reading various PMBus bits/words.
+         */
+        std::string monitorPath;
+
+        /**
+         * The D-Bus path to use for this power supply's inventory status.
+         */
+        std::string inventoryPath;
 };
 
 }