xref: /openbmc/pldm/fw-update/firmware_inventory.hpp (revision 7ad45b401134e3b3a05a75200dbba00afd5aee46)
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         const Descriptors& /*descriptors*/,
56         const ComponentInfo& /*componentInfo*/,
57         SoftwareVersionPurpose purpose = SoftwareVersionPurpose::Unknown);
58 
59   private:
60     /**
61      * @brief Reference to the sdbusplus bus
62      */
63     sdbusplus::bus_t& bus = utils::DBusHandler::getBus();
64 
65     /**
66      * @brief The D-Bus object path for the firmware inventory entry, obtained
67      * by
68      */
69     std::string softwarePath;
70 
71     /**
72      * @brief Software association object that represents the associations
73      *        for the firmware
74      */
75     SoftwareAssociationDefinitions association;
76 
77     /**
78      * @brief Software version object that represents the firmware version
79      */
80     SoftwareVersion version;
81 };
82 
83 } // namespace pldm::fw_update
84