Handle PSU inventory changes

Watch the PSU inventory property changes, so that when a PSU is plugged
out/in, the software object is removed or created.
If mutliple PSUs have the same software version, the related
associations are updated.

Tested: On Witherspoon, manually setting PSU's present property to false
        and true, when both PSUs have the same version.
        0. Before setting PSU's present false, verify the software
        object is associated with two PSUs;
        1. When one of the PSU is set false, verify the assocation is
        removed and only one PSU path is associated;
        2. When both of the PSUs are set false, verify the software
        object is removed;
        3. When a PSU is set to true, verify the software object is
        created and associated with the PSU;
        4. When the other PSU is set to true, verify the software object
        is associated with both PSUs.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I417a87bf57c01aa57f78f09b7abc4e948a4d1752
diff --git a/src/item_updater.hpp b/src/item_updater.hpp
index 6df7624..7bd9f66 100644
--- a/src/item_updater.hpp
+++ b/src/item_updater.hpp
@@ -111,10 +111,21 @@
                                 Version::VersionPurpose versionPurpose,
                             const std::string& filePath);
 
-    /** @brief Create Activation and Version object for PSU inventory */
+    /** @brief Create Activation and Version object for PSU inventory
+     *  @details If the same version exists for multiple PSUs, just add
+     *           related association, instead of creating new objects.
+     * */
     void createPsuObject(const std::string& psuInventoryPath,
                          const std::string& psuVersion);
 
+    /** @brief Remove Activation and Version object for PSU inventory
+     *  @details If the same version exists for mutliple PSUs, just remove
+     *           related association.
+     *           If the version has no association, the Activation and
+     *           Version object will be removed
+     */
+    void removePsuObject(const std::string& psuInventoryPath);
+
     /**
      * @brief Create and populate the active PSU Version.
      */
@@ -131,6 +142,21 @@
      * version id */
     std::map<std::string, std::unique_ptr<Version>> versions;
 
+    /** @brief The reference map of PSU Inventory objects and the
+     * Activation*/
+    std::map<std::string, const std::unique_ptr<Activation>&>
+        psuPathActivationMap;
+
+    /** @brief A struct to hold the PSU present status and version */
+    struct psuStatus
+    {
+        bool present;
+        std::string version;
+    };
+
+    /** @brief The map of PSU inventory path and the psuStatus */
+    std::map<std::string, psuStatus> psuStatusMap;
+
     /** @brief sdbusplus signal match for PSU Software*/
     sdbusplus::bus::match_t versionMatch;