presence: Add JSON config class
Add a JSON config class that will be used to parse a given JSON config
file and generate the fan presence policies from that config.
Tested:
N/A
Change-Id: Iac1703ea8d9e1e1d0d40e15a58145181d4f1a0f9
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/presence/json_config.hpp b/presence/json_config.hpp
new file mode 100644
index 0000000..dcb1aa3
--- /dev/null
+++ b/presence/json_config.hpp
@@ -0,0 +1,53 @@
+#pragma once
+
+#include <string>
+#include <vector>
+#include <memory>
+
+#include "config.h"
+#include "rpolicy.hpp"
+
+namespace phosphor
+{
+namespace fan
+{
+namespace presence
+{
+
+using policies = std::vector<std::unique_ptr<RedundancyPolicy>>;
+
+class JsonConfig
+{
+ public:
+
+ JsonConfig() = delete;
+ JsonConfig(const JsonConfig&) = delete;
+ JsonConfig(JsonConfig&&) = delete;
+ JsonConfig& operator=(const JsonConfig&) = delete;
+ JsonConfig& operator=(JsonConfig&&) = delete;
+ ~JsonConfig() = default;
+
+ /**
+ * Constructor
+ * Parses and populates the fan presence policies from a json file
+ *
+ * @param[in] jsonFile - json configuration file
+ */
+ explicit JsonConfig(const std::string& jsonFile);
+
+ /**
+ * @brief Get the json config based fan presence policies
+ *
+ * @return - The fan presence policies
+ */
+ static const policies& get();
+
+ private:
+
+ /* Fan presence policies */
+ static policies _policies;
+};
+
+} // namespace presence
+} // namespace fan
+} // namespace phosphor