presence: Create ErrorReporter class

This class will, eventually, create event logs for missing fans.

This first commit will just create a stubbed out class if there is a
'reporting' section in the configuration JSON.  From the JSON, the class
will pull out the value for the number of seconds to wait between first
detecting a fan is missing and creating the event log for it.

This requires a slight change to the existing JSON format, however the
JsonConfig class was updated to support both the old and new formats.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I991ea7cf0457448411e65f4c8e274bb2584d15f4
diff --git a/presence/error_reporter.hpp b/presence/error_reporter.hpp
new file mode 100644
index 0000000..251aa7e
--- /dev/null
+++ b/presence/error_reporter.hpp
@@ -0,0 +1,67 @@
+#pragma once
+
+#include "fan.hpp"
+
+#include <nlohmann/json.hpp>
+#include <sdbusplus/bus.hpp>
+
+namespace phosphor::fan::presence
+{
+class PresenceSensor;
+
+/**
+ * @class ErrorReporter
+ *
+ * This class will create event logs for missing fans.  The logs are
+ * created after a fan has been missing for an amount of time
+ * specified in the JSON config file while power is on.
+ *
+ * The timers to create event logs are not started when power is off.
+ * When power is turned on, the timers for any missing fans will be
+ * be started.  If any timers are running when power is turned off,
+ * they will be stopped.
+ */
+class ErrorReporter
+{
+  public:
+    ErrorReporter() = delete;
+    ~ErrorReporter() = default;
+    ErrorReporter(const ErrorReporter&) = delete;
+    ErrorReporter& operator=(const ErrorReporter&) = delete;
+    ErrorReporter(ErrorReporter&&) = delete;
+    ErrorReporter& operator=(ErrorReporter&&) = delete;
+
+    /**
+     * @brief Constructor
+     *
+     * @param[in] bus - The sdbusplus bus object
+     * @param[in] jsonConf - The 'reporting' section of the JSON config file
+     * @param[in] fans - The fans for this configuration
+     */
+    ErrorReporter(
+        sdbusplus::bus::bus& bus, const nlohmann::json& jsonConf,
+        const std::vector<
+            std::tuple<Fan, std::vector<std::unique_ptr<PresenceSensor>>>>&
+            fans);
+
+  private:
+    /**
+     * @brief Reads in the configuration from the JSON section
+     *
+     * @param[in] jsonConf - The 'reporting' section of the JSON
+     */
+    void loadConfig(const nlohmann::json& jsonConf);
+
+    /**
+     * @brief Reference to the D-Bus connection object.
+     */
+    sdbusplus::bus::bus& _bus;
+
+    /**
+     * @brief The amount of time in seconds that a fan must be missing
+     *        before an event log is created for it.
+     */
+    std::chrono::seconds _fanMissingErrorTime;
+};
+
+} // namespace phosphor::fan::presence