Fix up Function to Populate collection Members

Added Doxygen comments, renamed the funciton, renamed several
variables, and made more generic.

Tested: Top commit passes validator and resources look good.
Change-Id: I9a13176b7f4c8611ae38c6563b0e119e0f66edf2
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index 31d5da1..e73fce3 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -10,13 +10,24 @@
 namespace collection_util
 {
 
-inline void getResourceList(std::shared_ptr<AsyncResp> aResp,
-                            const std::string& subclass,
-                            const std::vector<const char*>& collectionName)
+/**
+ * @brief Populate the collection "Members" from a GetSubTree search of
+ *        inventory
+ *
+ * @param[i,o] aResp  Async response object
+ * @param[i]   collectionPath  Redfish collection path which is used for the
+ *             Members Redfish Path
+ * @param[i]   interfaces  List of interfaces to constrain the GetSubTree search
+ *
+ * @return void
+ */
+inline void getCollectionMembers(std::shared_ptr<AsyncResp> aResp,
+                                 const std::string& collectionPath,
+                                 const std::vector<const char*>& interfaces)
 {
-    BMCWEB_LOG_DEBUG << "Get available system cpu/mem resources.";
+    BMCWEB_LOG_DEBUG << "Get collection members for: " << collectionPath;
     crow::connections::systemBus->async_method_call(
-        [subclass, aResp{std::move(aResp)}](
+        [collectionPath, aResp{std::move(aResp)}](
             const boost::system::error_code ec,
             const boost::container::flat_map<
                 std::string, boost::container::flat_map<
@@ -37,8 +48,7 @@
                 if ((iter != std::string::npos) && (iter < object.first.size()))
                 {
                     members.push_back(
-                        {{"@odata.id", "/redfish/v1/Systems/system/" +
-                                           subclass + "/" +
+                        {{"@odata.id", collectionPath + "/" +
                                            object.first.substr(iter + 1)}});
                 }
             }
@@ -47,7 +57,7 @@
         "xyz.openbmc_project.ObjectMapper",
         "/xyz/openbmc_project/object_mapper",
         "xyz.openbmc_project.ObjectMapper", "GetSubTree",
-        "/xyz/openbmc_project/inventory", 0, collectionName);
+        "/xyz/openbmc_project/inventory", 0, interfaces);
 }
 
 } // namespace collection_util
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index a172233..4fa7c11 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -765,8 +765,9 @@
         res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Memory";
         auto asyncResp = std::make_shared<AsyncResp>(res);
 
-        collection_util::getResourceList(
-            asyncResp, "Memory", {"xyz.openbmc_project.Inventory.Item.Dimm"});
+        collection_util::getCollectionMembers(
+            asyncResp, "/redfish/v1/Systems/system/Memory",
+            {"xyz.openbmc_project.Inventory.Item.Dimm"});
     }
 };
 
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index 5c98684..4c9b1dc 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -469,8 +469,8 @@
         res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Processors/";
         auto asyncResp = std::make_shared<AsyncResp>(res);
 
-        collection_util::getResourceList(
-            asyncResp, "Processors",
+        collection_util::getCollectionMembers(
+            asyncResp, "/redfish/v1/Systems/system/Processors",
             {"xyz.openbmc_project.Inventory.Item.Cpu",
              "xyz.openbmc_project.Inventory.Item.Accelerator"});
     }