xref: /openbmc/pldm/fw-update/firmware_inventory.hpp (revision ee2bd8ad3979dac8c41afa643e0eb24b31e70683)
1 #pragma once
2 
3 #include "common/types.hpp"
4 #include "common/utils.hpp"
5 
6 #include <xyz/openbmc_project/Association/Definitions/server.hpp>
7 #include <xyz/openbmc_project/Software/Version/server.hpp>
8 
9 class FirmwareInventoryTest;
10 
11 namespace pldm::fw_update
12 {
13 
14 class FirmwareInventory;
15 using SoftwareVersion = sdbusplus::server::object_t<
16     sdbusplus::xyz::openbmc_project::Software::server::Version>;
17 using SoftwareAssociationDefinitions = sdbusplus::server::object_t<
18     sdbusplus::xyz::openbmc_project::Association::server::Definitions>;
19 
20 using SoftwareVersionPurpose = SoftwareVersion::VersionPurpose;
21 
22 using namespace pldm;
23 
24 class FirmwareInventory
25 {
26   public:
27     friend class ::FirmwareInventoryTest;
28     FirmwareInventory() = delete;
29     FirmwareInventory(const FirmwareInventory&) = delete;
30     FirmwareInventory(FirmwareInventory&&) = delete;
31     FirmwareInventory& operator=(const FirmwareInventory&) = delete;
32     FirmwareInventory& operator=(FirmwareInventory&&) = delete;
33     ~FirmwareInventory() = default;
34 
35     /**
36      * @brief Constructor
37      * @param[in] softwareIdentifier - Software identifier containing EID and
38      *                                 component identifier
39      * @param[in] softwarePath - D-Bus object path for the firmware inventory
40      * entry
41      * @param[in] softwareVersion - Active version of the firmware
42      * @param[in] associatedEndpoint - D-Bus object path of the endpoint
43      * associated with the firmware
44      * @param[in] descriptors - Descriptors associated with the firmware
45      * @param[in] componentInfo - Component information associated with the
46      * firmware
47      * @param[in] purpose - Purpose of the software version, default is Unknown
48      * @note The descriptors and componentInfo parameters are reserved for
49      * future use and currently not used in the implementation.
50      */
51     explicit FirmwareInventory(
52         SoftwareIdentifier /*softwareIdentifier*/,
53         const std::string& softwarePath, const std::string& softwareVersion,
54         const std::string& associatedEndpoint,
55         SoftwareVersionPurpose purpose = SoftwareVersionPurpose::Unknown);
56 
57   private:
58     /**
59      * @brief Reference to the sdbusplus bus
60      */
61     sdbusplus::bus_t& bus = utils::DBusHandler::getBus();
62 
63     /**
64      * @brief The D-Bus object path for the firmware inventory entry, obtained
65      * by
66      */
67     std::string softwarePath;
68 
69     /**
70      * @brief Software association object that represents the associations
71      *        for the firmware
72      */
73     SoftwareAssociationDefinitions association;
74 
75     /**
76      * @brief Software version object that represents the firmware version
77      */
78     SoftwareVersion version;
79 };
80 
81 } // namespace pldm::fw_update
82