summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-14 16:51:55 -0400
committerPatrick Williams <patrick@stwcx.xyz>2017-08-02 20:18:18 +0000
commit878b964ae36a54537c1b020e9493a8ac2505f7dc (patch)
treebdc4f1e2f83ec52a681d6c633614a60d4c6cd90e
parent825e31e5c2eec64384b78acfe9ab4d2f689020bf (diff)
downloadphosphor-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>
-rw-r--r--presence/psensor.hpp77
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
OpenPOWER on IntegriCloud