common: utils: Add get ancestors mapper function

Add get ancestors mapper function. A use case is getting an inventory
item's parent path for its board or chassis[1][2].

[1]: https://gerrit.openbmc.org/c/openbmc/pldm/+/73512/46/fw-update/inventory_item_manager.cpp#83
[2]: https://gerrit.openbmc.org/c/openbmc/pldm/+/67050/27/oem/meta/libpldmresponder/oem_meta_file_io_type_post_code.cpp#29

Change-Id: I7a25c8e11f7662fd07147b7da3b8db9fbff5e00e
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/common/utils.hpp b/common/utils.hpp
index cd02f6c..159a13e 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -194,6 +194,8 @@
 using MapperServiceMap = std::vector<std::pair<ServiceName, Interfaces>>;
 using GetSubTreeResponse = std::vector<std::pair<ObjectPath, MapperServiceMap>>;
 using GetSubTreePathsResponse = std::vector<std::string>;
+using GetAncestorsResponse =
+    std::vector<std::pair<ObjectPath, MapperServiceMap>>;
 using PropertyMap = std::map<std::string, PropertyValue>;
 using InterfaceMap = std::map<std::string, PropertyMap>;
 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
@@ -216,6 +218,10 @@
         const std::string& objectPath, int depth,
         const std::vector<std::string>& ifaceList) const = 0;
 
+    virtual GetAncestorsResponse getAncestors(
+        const std::string& path,
+        const std::vector<std::string>& ifaceList) const = 0;
+
     virtual void setDbusProperty(const DBusMapping& dBusMap,
                                  const PropertyValue& value) const = 0;
 
@@ -289,6 +295,21 @@
         const std::string& objectPath, int depth,
         const std::vector<std::string>& ifaceList) const override;
 
+    /**
+     *  @brief Get the Ancestors response from the mapper
+     *
+     *  @param[in] path - D-Bus object path
+     *  @param[in] ifaceList - an optional list of interfaces to constrain the
+     *                         search to queried from the mapper
+     *
+     *  @return GetAncestorsResponse - the mapper GetAncestors response
+     *
+     *  @throw sdbusplus::exception_t when it fails
+     */
+    GetAncestorsResponse getAncestors(
+        const std::string& path,
+        const std::vector<std::string>& ifaceList) const override;
+
     /** @brief Get property(type: variant) from the requested dbus
      *
      *  @param[in] objPath - The Dbus object path