1 #pragma once 2 3 #include <sdbusplus/bus.hpp> 4 #include "xyz/openbmc_project/Software/Version/server.hpp" 5 #include "xyz/openbmc_project/Object/Delete/server.hpp" 6 #include "xyz/openbmc_project/Common/FilePath/server.hpp" 7 #include <functional> 8 9 namespace phosphor 10 { 11 namespace software 12 { 13 namespace manager 14 { 15 16 typedef std::function<void(std::string)> eraseFunc; 17 18 using VersionInherit = sdbusplus::server::object::object< 19 sdbusplus::xyz::openbmc_project::Software::server::Version, 20 sdbusplus::xyz::openbmc_project::Object::server::Delete, 21 sdbusplus::xyz::openbmc_project::Common::server::FilePath>; 22 23 /** @class Version 24 * @brief OpenBMC version software management implementation. 25 * @details A concrete implementation for xyz.openbmc_project.Software.Version 26 * DBus API. 27 */ 28 class Version : public VersionInherit 29 { 30 public: 31 /** @brief Constructs Version Software Manager 32 * 33 * @param[in] bus - The Dbus bus object 34 * @param[in] objPath - The Dbus object path 35 * @param[in] versionId - The version identifier 36 * @param[in] versionPurpose - The version purpose 37 * @param[in] filePath - The image filesystem path 38 * @param[in] callback - The parent's erase callback 39 */ 40 Version(sdbusplus::bus::bus& bus, 41 const std::string& objPath, 42 const std::string& versionId, 43 VersionPurpose versionPurpose, 44 const std::string& filePath, 45 eraseFunc callback) : VersionInherit( 46 bus, (objPath).c_str(), true) 47 { 48 // Bind erase method 49 eraseCallback = callback; 50 // Set properties. 51 purpose(versionPurpose); 52 version(versionId); 53 path(filePath); 54 // Emit deferred signal. 55 emit_object_added(); 56 } 57 58 /** 59 * @brief Read the manifest file to get the value of the key. 60 * 61 * @return The value of the key. 62 **/ 63 static std::string getValue(const std::string& manifestFilePath, 64 std::string key); 65 66 /** 67 * @brief Get the Version id. 68 * 69 * @return The id. 70 **/ 71 static std::string getId(const std::string& version); 72 73 /** 74 * @brief Get the active bmc version identifier. 75 * 76 * @param[in] releaseFilePath - The Path to file which contains 77 * the release version. 78 * 79 * @return The version identifier. 80 */ 81 static std::string getBMCVersion(const std::string& releaseFilePath); 82 83 /** 84 * @brief Delete the d-bus object and image. 85 */ 86 void delete_() override; 87 88 89 private: 90 /** 91 * @brief The parent's erase callback. 92 */ 93 eraseFunc eraseCallback; 94 }; 95 96 } // namespace manager 97 } // namespace software 98 } // namespace phosphor 99 100