regulators: Implements support for run_rule

Implements support for parsing the run_rule JSON elements in the
configuration file parser.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I9b8d96716a7710e3829fc346d89ef418cc091858
diff --git a/phosphor-regulators/src/config_file_parser.cpp b/phosphor-regulators/src/config_file_parser.cpp
index 3959978..1d64c96 100644
--- a/phosphor-regulators/src/config_file_parser.cpp
+++ b/phosphor-regulators/src/config_file_parser.cpp
@@ -148,9 +148,8 @@
     }
     else if (element.contains("run_rule"))
     {
-        // TODO: Not implemented yet
-        // action = parseRunRule(element["run_rule"]);
-        // ++propertyCount;
+        action = parseRunRule(element["run_rule"]);
+        ++propertyCount;
     }
     else if (element.contains("set_device"))
     {
@@ -422,6 +421,14 @@
     return rules;
 }
 
+std::unique_ptr<RunRuleAction> parseRunRule(const json& element)
+{
+    // String ruleID
+    std::string ruleID = parseString(element);
+
+    return std::make_unique<RunRuleAction>(ruleID);
+}
+
 } // namespace internal
 
 } // namespace phosphor::power::regulators::config_file_parser
diff --git a/phosphor-regulators/src/config_file_parser.hpp b/phosphor-regulators/src/config_file_parser.hpp
index a8286f1..0a931d8 100644
--- a/phosphor-regulators/src/config_file_parser.hpp
+++ b/phosphor-regulators/src/config_file_parser.hpp
@@ -22,6 +22,7 @@
 #include "i2c_write_bytes_action.hpp"
 #include "pmbus_write_vout_command_action.hpp"
 #include "rule.hpp"
+#include "run_rule_action.hpp"
 
 #include <nlohmann/json.hpp>
 
@@ -367,6 +368,18 @@
     parseRuleArray(const nlohmann::json& element);
 
 /**
+ * Parses a JSON element containing a run_rule action.
+ *
+ * Returns the corresponding C++ RunRuleAction object.
+ *
+ * Throws an exception if parsing fails.
+ *
+ * @param element JSON element
+ * @return RunRuleAction object
+ */
+std::unique_ptr<RunRuleAction> parseRunRule(const nlohmann::json& element);
+
+/**
  * Parses a JSON element containing a string.
  *
  * Returns the corresponding C++ string.