blob: 096c96c1ead3775b284a760905edf94e229e50e1 [file] [log] [blame]
Brad Bishop878b9642017-06-14 16:51:55 -04001#pragma once
2
3namespace phosphor
4{
5namespace fan
6{
7namespace presence
8{
9
10/**
11 * @class PresenceSensor
12 * @brief PresenceSensor interface.
13 *
14 * Provide concrete implementations of PresenceSensor to realize
15 * new presence detection methods.
16 *
17 * Note that implementations drive the inventory update process via
18 * a redundancy policy (rpolicy.hpp) - it is not enough to implement
19 * the interfaces below.
20 */
21class PresenceSensor
22{
23 public:
24 PresenceSensor(const PresenceSensor&) = default;
25 PresenceSensor& operator=(const PresenceSensor&) = default;
26 PresenceSensor(PresenceSensor&&) = default;
27 PresenceSensor& operator=(PresenceSensor&&) = default;
28 virtual ~PresenceSensor() = default;
29 PresenceSensor() = default;
30
31 /**
32 * @brief start
33 *
34 * Implementations should peform any preparation
35 * for detecting presence. Typical implementations
36 * might register signal callbacks or start
37 * a polling loop.
38 *
39 * @return The state of the sensor.
40 */
41 virtual bool start() = 0;
42
43 /**
44 * @brief stop
45 *
46 * Implementations should stop issuing presence
47 * state change notifications. Typical implementations
48 * might de-register signal callbacks or terminate
49 * polling loops.
50 */
51 virtual void stop() = 0;
52
53 /**
54 * @brief Check the sensor.
55 *
56 * Implementations should perform an offline (the start
57 * method has not been invoked) query of the presence
58 * state.
59 *
60 * @return The state of the sensor.
61 */
62 virtual bool present() = 0;
63
64 /**
65 * @brief Mark the sensor as failed.
66 *
67 * Implementations should log an an event if the
68 * system policy requires it.
69 *
70 * Provide a default noop implementation.
71 */
72 virtual void fail() {}
73};
74
75} // namespace presence
76} // namespace fan
77} // namespace phosphor