control: Add creating config object without a dbus object

For those configuration objects that do not need a dbus object, create
them using a similar method without requiring a dbus object to be given.
Updated each object to correctly reflect their current need of a dbus
object which was driven by moving the creation of the available group
objects to within the event.

Change-Id: I8ce4ea7baf4cfd1ad86268b760a334fcf0a4f25e
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json_parser.hpp b/control/json_parser.hpp
index 7c08875..adeacbe 100644
--- a/control/json_parser.hpp
+++ b/control/json_parser.hpp
@@ -42,7 +42,8 @@
 using configKey = std::pair<std::string, std::vector<std::string>>;
 
 /**
- * @brief Load the configuration of a given JSON class object type
+ * @brief Load the configuration of a given JSON class object type that requires
+ * a dbus object
  *
  * @param[in] bus - The dbus bus object
  * @param[in] isOptional - JSON configuration file is optional or not
@@ -72,6 +73,37 @@
 }
 
 /**
+ * @brief Load the configuration of a given JSON class object type that does not
+ * require a dbus object
+ *
+ * @param[in] isOptional - JSON configuration file is optional or not
+ *                         Defaults to false
+ *
+ * @return Map of configuration entries
+ *     Map of configuration keys to their corresponding configuration object
+ */
+template <typename T>
+std::map<configKey, std::unique_ptr<T>> getConfig(bool isOptional = false)
+{
+    // Dbus object is needed to retrieve the JSON configuration file
+    auto bus = sdbusplus::bus::new_default();
+    std::map<configKey, std::unique_ptr<T>> config;
+
+    auto confFile = fan::JsonConfig::getConfFile(bus, confAppName,
+                                                 T::confFileName, isOptional);
+    if (!confFile.empty())
+    {
+        for (const auto& entry : fan::JsonConfig::load(confFile))
+        {
+            auto obj = std::make_unique<T>(entry);
+            config.emplace(std::make_pair(obj->getName(), obj->getProfiles()),
+                           std::move(obj));
+        }
+    }
+    return config;
+}
+
+/**
  * @brief Helper function to determine when a configuration entry is included
  * based on the list of active profiles and its list of profiles
  *