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