control: Pair profiles with name as key

Include the profiles of a configuration object in combination with its
name to construct a unique key for building the complete fan control
configuration. This is necessary for supporting the zones, groups, and
events configurations.

Tested:
    Object name and list of profiles construct key
    Profile objects always contain an empty list of profiles
    Fan objects may or may not contain a list of profiles

Change-Id: I4be7229e3fb695d845d60159d0f08f601512c812
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/json_parser.hpp b/control/json_parser.hpp
index 29d1697..df9c680 100644
--- a/control/json_parser.hpp
+++ b/control/json_parser.hpp
@@ -15,7 +15,6 @@
  */
 #pragma once
 
-#include "json/profile.hpp"
 #include "json_config.hpp"
 #include "types.hpp"
 
@@ -24,6 +23,8 @@
 
 #include <map>
 #include <memory>
+#include <utility>
+#include <vector>
 
 namespace phosphor::fan::control
 {
@@ -32,6 +33,15 @@
 constexpr auto confAppName = "control";
 
 /**
+ * Configuration object key to uniquely map to the configuration object
+ * Pair constructed of:
+ *      std::string = Configuration object's name
+ *      std::vector<std::string> = List of profiles the configuration object
+ *                                 is included in
+ */
+using configKey = std::pair<std::string, std::vector<std::string>>;
+
+/**
  * @brief Load the configuration of a given JSON class object type
  *
  * @param[in] bus - The dbus bus object
@@ -39,13 +49,13 @@
  *                         Defaults to false
  *
  * @return Map of configuration entries
- *     Map of configuration names to their corresponding configuration object
+ *     Map of configuration keys to their corresponding configuration object
  */
 template <typename T>
-std::map<std::string, std::unique_ptr<T>> getConfig(sdbusplus::bus::bus& bus,
-                                                    bool isOptional = false)
+std::map<configKey, std::unique_ptr<T>> getConfig(sdbusplus::bus::bus& bus,
+                                                  bool isOptional = false)
 {
-    std::map<std::string, std::unique_ptr<T>> config;
+    std::map<configKey, std::unique_ptr<T>> config;
 
     auto confFile = fan::JsonConfig::getConfFile(bus, confAppName,
                                                  T::confFileName, isOptional);
@@ -54,10 +64,10 @@
         for (const auto& entry : fan::JsonConfig::load(confFile))
         {
             auto obj = std::make_unique<T>(bus, entry);
-            config.emplace(obj->getName(), std::move(obj));
+            config.emplace(std::make_pair(obj->getName(), obj->getProfiles()),
+                           std::move(obj));
         }
     }
-
     return config;
 }