diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-06-14 16:51:55 -0400 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-02 20:18:18 +0000 |
commit | 878b964ae36a54537c1b020e9493a8ac2505f7dc (patch) | |
tree | bdc4f1e2f83ec52a681d6c633614a60d4c6cd90e /presence/psensor.hpp | |
parent | 825e31e5c2eec64384b78acfe9ab4d2f689020bf (diff) | |
download | phosphor-fan-presence-878b964ae36a54537c1b020e9493a8ac2505f7dc.tar.gz phosphor-fan-presence-878b964ae36a54537c1b020e9493a8ac2505f7dc.zip |
presence: Add presence sensor interface
Prepare to extend the fan presence model to include
sensors of other types with a presence sensor interface
class.
Presence sensors can be both event driven or polled. Provide
start and stop for the former and present for the latter.
Change-Id: Ia1b91a5e30e27fbe66c6f075e5e5ce620dac997e
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'presence/psensor.hpp')
-rw-r--r-- | presence/psensor.hpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/presence/psensor.hpp b/presence/psensor.hpp new file mode 100644 index 0000000..096c96c --- /dev/null +++ b/presence/psensor.hpp @@ -0,0 +1,77 @@ +#pragma once + +namespace phosphor +{ +namespace fan +{ +namespace presence +{ + +/** + * @class PresenceSensor + * @brief PresenceSensor interface. + * + * Provide concrete implementations of PresenceSensor to realize + * new presence detection methods. + * + * Note that implementations drive the inventory update process via + * a redundancy policy (rpolicy.hpp) - it is not enough to implement + * the interfaces below. + */ +class PresenceSensor +{ + public: + PresenceSensor(const PresenceSensor&) = default; + PresenceSensor& operator=(const PresenceSensor&) = default; + PresenceSensor(PresenceSensor&&) = default; + PresenceSensor& operator=(PresenceSensor&&) = default; + virtual ~PresenceSensor() = default; + PresenceSensor() = default; + + /** + * @brief start + * + * Implementations should peform any preparation + * for detecting presence. Typical implementations + * might register signal callbacks or start + * a polling loop. + * + * @return The state of the sensor. + */ + virtual bool start() = 0; + + /** + * @brief stop + * + * Implementations should stop issuing presence + * state change notifications. Typical implementations + * might de-register signal callbacks or terminate + * polling loops. + */ + virtual void stop() = 0; + + /** + * @brief Check the sensor. + * + * Implementations should perform an offline (the start + * method has not been invoked) query of the presence + * state. + * + * @return The state of the sensor. + */ + virtual bool present() = 0; + + /** + * @brief Mark the sensor as failed. + * + * Implementations should log an an event if the + * system policy requires it. + * + * Provide a default noop implementation. + */ + virtual void fail() {} +}; + +} // namespace presence +} // namespace fan +} // namespace phosphor |