1dae0a8d7SMatt Spinler #pragma once 2dae0a8d7SMatt Spinler 3dae0a8d7SMatt Spinler #include <memory> 4dae0a8d7SMatt Spinler #include <string> 5dae0a8d7SMatt Spinler 6ab093328SLei YU namespace phosphor 7dae0a8d7SMatt Spinler { 8dae0a8d7SMatt Spinler namespace power 9dae0a8d7SMatt Spinler { 10dae0a8d7SMatt Spinler 11dae0a8d7SMatt Spinler /** 12dae0a8d7SMatt Spinler * @class Device 13dae0a8d7SMatt Spinler * 14dae0a8d7SMatt Spinler * This object is an abstract base class for a device that 15dae0a8d7SMatt Spinler * can be monitored for power faults. 16dae0a8d7SMatt Spinler */ 17dae0a8d7SMatt Spinler class Device 18dae0a8d7SMatt Spinler { 19dae0a8d7SMatt Spinler public: 20dae0a8d7SMatt Spinler Device() = delete; 21dae0a8d7SMatt Spinler virtual ~Device() = default; 22dae0a8d7SMatt Spinler Device(const Device&) = delete; 23dae0a8d7SMatt Spinler Device& operator=(const Device&) = delete; 24dae0a8d7SMatt Spinler Device(Device&&) = default; 25dae0a8d7SMatt Spinler Device& operator=(Device&&) = default; 26dae0a8d7SMatt Spinler 27dae0a8d7SMatt Spinler /** 28dae0a8d7SMatt Spinler * Constructor 29dae0a8d7SMatt Spinler * 30dae0a8d7SMatt Spinler * @param name - the device name 31dae0a8d7SMatt Spinler * @param inst - the device instance 32dae0a8d7SMatt Spinler */ Device(const std::string & name,size_t inst)33*48781aefSPatrick Williams Device(const std::string& name, size_t inst) : name(name), instance(inst) {} 34dae0a8d7SMatt Spinler 35dae0a8d7SMatt Spinler /** 36dae0a8d7SMatt Spinler * Returns the instance number 37dae0a8d7SMatt Spinler */ getInstance() const38dae0a8d7SMatt Spinler inline auto getInstance() const 39dae0a8d7SMatt Spinler { 40dae0a8d7SMatt Spinler return instance; 41dae0a8d7SMatt Spinler } 42dae0a8d7SMatt Spinler 43dae0a8d7SMatt Spinler /** 44dae0a8d7SMatt Spinler * Returns the name 45dae0a8d7SMatt Spinler */ getName() const46dae0a8d7SMatt Spinler inline auto getName() const 47dae0a8d7SMatt Spinler { 48dae0a8d7SMatt Spinler return name; 49dae0a8d7SMatt Spinler } 50dae0a8d7SMatt Spinler 51dae0a8d7SMatt Spinler /** 52dae0a8d7SMatt Spinler * Pure virtual function to analyze an error 53dae0a8d7SMatt Spinler */ 54dae0a8d7SMatt Spinler virtual void analyze() = 0; 55dae0a8d7SMatt Spinler 56dae0a8d7SMatt Spinler /** 57b54357f6SMatt Spinler * Stubbed virtual function to call when it's known 58b54357f6SMatt Spinler * the chip is in error state. Override if functionality 59b54357f6SMatt Spinler * is required 60b54357f6SMatt Spinler */ onFailure()61*48781aefSPatrick Williams virtual void onFailure() {} 62b54357f6SMatt Spinler 63b54357f6SMatt Spinler /** 64dae0a8d7SMatt Spinler * Pure virtual function to clear faults on the device 65dae0a8d7SMatt Spinler */ 66dae0a8d7SMatt Spinler virtual void clearFaults() = 0; 67dae0a8d7SMatt Spinler 68dae0a8d7SMatt Spinler private: 69dae0a8d7SMatt Spinler /** 70dae0a8d7SMatt Spinler * the device name 71dae0a8d7SMatt Spinler */ 72dae0a8d7SMatt Spinler const std::string name; 73dae0a8d7SMatt Spinler 74dae0a8d7SMatt Spinler /** 75dae0a8d7SMatt Spinler * the device instance number 76dae0a8d7SMatt Spinler */ 77dae0a8d7SMatt Spinler const size_t instance; 78dae0a8d7SMatt Spinler }; 79dae0a8d7SMatt Spinler 80f0f02b9aSMatt Spinler } // namespace power 81ab093328SLei YU } // namespace phosphor 82