Add OCC present count detection and watch

Add a Presence child class of Error to handle detecting the number of
OCCs available. Add an instance of this Presence class if the Device
detects that it is the master OCC, since the number of present OCCs is
only reported by the master OCC. When a change to the number of OCCs
reported is detected, compare with the number of OCCs determined to be
active by the Manager, and if there is a mismatch, follow the usual
error path (reset OCC, etc).

Partially resolves openbmc/openbmc#2285
See https://gerrit.openbmc-project.xyz/#/c/7843/

Change-Id: Idbaca52b307992d9b01fe15439ab746ef6d64397
Signed-off-by: Edward A. James <eajames@us.ibm.com>
diff --git a/occ_presence.hpp b/occ_presence.hpp
new file mode 100644
index 0000000..321dacb
--- /dev/null
+++ b/occ_presence.hpp
@@ -0,0 +1,52 @@
+#pragma once
+
+#include "occ_errors.hpp"
+namespace open_power
+{
+namespace occ
+{
+
+class Manager;
+
+/** @class Presence
+ *  @brief Monitors the number of OCCs present
+ */
+class Presence : public Error
+{
+    public:
+        Presence() = delete;
+        Presence(const Presence&) = delete;
+        Presence& operator=(const Presence&) = delete;
+        Presence(Presence&&) = default;
+        Presence& operator=(Presence&&) = default;
+
+        /** @brief Constructs the Presence object
+         *
+         *  @param[in] event    - Reference to sd_event unique_ptr
+         *  @param[in] file     - File used by driver to communicate errors
+         *  @param[in] mgr      - OCC manager instance
+         *  @param[in] callBack - Optional function callback on error condition
+         */
+        Presence(EventPtr& event,
+              const fs::path& file,
+              const Manager& mgr,
+              std::function<void()> callBack = nullptr) :
+            Error(event, file, callBack),
+            manager(mgr)
+        {
+            // Nothing to do here.
+        }
+
+    private:
+        /** Store the manager instance to enable getting number of OCCs */
+        const Manager& manager;
+
+        /** @brief When the error event is received, analyzes it
+         *         and makes a callback to error handler if the
+         *         content denotes an error condition
+         */
+        void analyzeEvent() override;
+};
+
+} // namespace occ
+} // namespace open_power