monitor: Create PowerOffRules class
This class contains a PowerOffCause and a PowerOffAction. It provides a
check() method that takes the FanHealth map which it then checks against
the cause. If the cause is satisfied, it then starts the power off
action. It provides a cancel method that will force cancel a running
action in the case that the object owner detects a system power off and
so doesn't need to run this power off anymore.
The class's configuration data is read from the JSON config file.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I5c0c168591d6d62c894c4d036ec762797fd759af
diff --git a/monitor/json_parser.hpp b/monitor/json_parser.hpp
index ac91463..84876ff 100644
--- a/monitor/json_parser.hpp
+++ b/monitor/json_parser.hpp
@@ -26,6 +26,8 @@
{
using json = nlohmann::json;
+class PowerOffRule;
+class PowerInterfaceBase;
constexpr auto confAppName = "monitor";
constexpr auto confFileName = "config.json";
@@ -77,4 +79,18 @@
*/
const std::vector<FanDefinition> getFanDefs(const json& obj);
+/**
+ * @brief Get the configured power off rules
+ *
+ * @param[in] obj - JSON object to parse from
+ *
+ * @param[in] powerInterface - The power interface object to use
+ *
+ * @return std::vector<std::unique_ptr<PowerOffRule>> -
+ * The PowerOffRule objects
+ */
+std::vector<std::unique_ptr<PowerOffRule>>
+ getPowerOffRules(const json& obj,
+ std::shared_ptr<PowerInterfaceBase>& powerInterface);
+
} // namespace phosphor::fan::monitor