fw_update: Introduce FirmwareInventory

Spec reference: [1]

Description:
FirmwareInventory is a class that manages all of the D-Bus
utilities for the firmware update functionality of each entry,
FirmwareInventoryManager is used to manage multiple FirmwareInventory
instances.

Flow of the routine when one or more firmware device is added:
1. When one or more firmware device is added, the InventoryManager
   instance will try to create a FirmwareInventory entry for the added
   device, to accomplish this, it will need to fetch the necessary
   information from various source (e.g. EM, device descriptors).

2. After the information is gathered, the InventoryManager will try to
   obtain a Name for each firmware devices, to fit the different
   platform condition, the name will be reference by the order below:
    1. From Entity Manager (EM), if the endpoint has a specific EM
       configuration with "Name" property listed.
    2. From device descriptors, if the device descriptor contains a
       vendor defined descriptor with "OpenBMC.Name" titled.
    3. Spawn a default one, named "Firmware_Device_<Endpoint ID>".

3. The InventoryManager will then invoke
   `FirmwareInventoryManager::createFirmwareInventory` to create a
   firmware inventory entry.

Properties managed by firmware Inventory:
1. Version
   Version object that represents the firmware version
2. Association
   Association object that represents the associations for the
   firmware

The object path pattern of the firmware inventory entry is:
`/xyz/openbmc_project/software/<BoardName>_<SoftwareName>_<SoftwareID>`

Where:
- `<BoardName>` represents the board the device is on.
- `<SoftwareName>` is the name of the firmware device obtained from the
  InventoryManager.
- `<SoftwareID>` is a 4-byte random number to help consumer
  distinguish from the new/old objects of a inventory item.
  For example:
  `server_board_slot_1_VR_2603`
  The new Activation object and its related interfaces needs to
  resides on a new objectPath, hence the softwareId is appended to
  the path.

Test results:
 - Build passed
 - Successfully create firmware inventory entries
   on Yosemite V4

[1]: https://github.com/openbmc/docs/blob/master/designs/code-update.md

Change-Id: Idebd7d013c82c60f08309a1860d5de1deeb3829a
Signed-off-by: Unive Tien <unive.tien.wiwynn@gmail.com>
Signed-off-by: Carter Chen <carter.chen.wiwynn@gmail.com>
diff --git a/fw-update/firmware_inventory.hpp b/fw-update/firmware_inventory.hpp
new file mode 100644
index 0000000..729989e
--- /dev/null
+++ b/fw-update/firmware_inventory.hpp
@@ -0,0 +1,83 @@
+#pragma once
+
+#include "common/types.hpp"
+#include "common/utils.hpp"
+
+#include <xyz/openbmc_project/Association/Definitions/server.hpp>
+#include <xyz/openbmc_project/Software/Version/server.hpp>
+
+class FirmwareInventoryTest;
+
+namespace pldm::fw_update
+{
+
+class FirmwareInventory;
+using SoftwareVersion = sdbusplus::server::object_t<
+    sdbusplus::xyz::openbmc_project::Software::server::Version>;
+using SoftwareAssociationDefinitions = sdbusplus::server::object_t<
+    sdbusplus::xyz::openbmc_project::Association::server::Definitions>;
+
+using SoftwareVersionPurpose = SoftwareVersion::VersionPurpose;
+
+using namespace pldm;
+
+class FirmwareInventory
+{
+  public:
+    friend class ::FirmwareInventoryTest;
+    FirmwareInventory() = delete;
+    FirmwareInventory(const FirmwareInventory&) = delete;
+    FirmwareInventory(FirmwareInventory&&) = delete;
+    FirmwareInventory& operator=(const FirmwareInventory&) = delete;
+    FirmwareInventory& operator=(FirmwareInventory&&) = delete;
+    ~FirmwareInventory() = default;
+
+    /**
+     * @brief Constructor
+     * @param[in] softwareIdentifier - Software identifier containing EID and
+     *                                 component identifier
+     * @param[in] softwarePath - D-Bus object path for the firmware inventory
+     * entry
+     * @param[in] softwareVersion - Active version of the firmware
+     * @param[in] associatedEndpoint - D-Bus object path of the endpoint
+     * associated with the firmware
+     * @param[in] descriptors - Descriptors associated with the firmware
+     * @param[in] componentInfo - Component information associated with the
+     * firmware
+     * @param[in] purpose - Purpose of the software version, default is Unknown
+     * @note The descriptors and componentInfo parameters are reserved for
+     * future use and currently not used in the implementation.
+     */
+    explicit FirmwareInventory(
+        SoftwareIdentifier /*softwareIdentifier*/,
+        const std::string& softwarePath, const std::string& softwareVersion,
+        const std::string& associatedEndpoint,
+        const Descriptors& /*descriptors*/,
+        const ComponentInfo& /*componentInfo*/,
+        SoftwareVersionPurpose purpose = SoftwareVersionPurpose::Unknown);
+
+  private:
+    /**
+     * @brief Reference to the sdbusplus bus
+     */
+    sdbusplus::bus_t& bus = utils::DBusHandler::getBus();
+
+    /**
+     * @brief The D-Bus object path for the firmware inventory entry, obtained
+     * by
+     */
+    std::string softwarePath;
+
+    /**
+     * @brief Software association object that represents the associations
+     *        for the firmware
+     */
+    SoftwareAssociationDefinitions association;
+
+    /**
+     * @brief Software version object that represents the firmware version
+     */
+    SoftwareVersion version;
+};
+
+} // namespace pldm::fw_update