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