Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include "xyz/openbmc_project/Software/Version/server.hpp" |
| 5 | #include "xyz/openbmc_project/Common/FilePath/server.hpp" |
| 6 | |
| 7 | namespace openpower |
| 8 | { |
| 9 | namespace software |
| 10 | { |
| 11 | namespace updater |
| 12 | { |
| 13 | |
| 14 | using VersionInherit = sdbusplus::server::object::object< |
| 15 | sdbusplus::xyz::openbmc_project::Software::server::Version, |
| 16 | sdbusplus::xyz::openbmc_project::Common::server::FilePath>; |
| 17 | |
| 18 | /** @class Version |
| 19 | * @brief OpenBMC version software management implementation. |
| 20 | * @details A concrete implementation for xyz.openbmc_project.Software.Version |
| 21 | * DBus API. |
| 22 | */ |
| 23 | class Version : public VersionInherit |
| 24 | { |
| 25 | public: |
| 26 | /** @brief Constructs Version Software Manager. |
| 27 | * |
| 28 | * @param[in] bus - The Dbus bus object |
| 29 | * @param[in] objPath - The Dbus object path |
| 30 | * @param[in] versionId - The version identifier |
| 31 | * @param[in] versionPurpose - The version purpose |
| 32 | * @param[in] filePath - The image filesystem path |
| 33 | */ |
| 34 | Version(sdbusplus::bus::bus& bus, |
| 35 | const std::string& objPath, |
| 36 | const std::string& versionId, |
| 37 | VersionPurpose versionPurpose, |
| 38 | const std::string& filePath) : VersionInherit( |
| 39 | bus, (objPath).c_str(), true) |
| 40 | { |
| 41 | // Set properties. |
| 42 | purpose(versionPurpose); |
| 43 | version(versionId); |
| 44 | path(filePath); |
| 45 | |
| 46 | // Emit deferred signal. |
| 47 | emit_object_added(); |
| 48 | } |
Saqib Khan | 167601b | 2017-06-18 23:33:46 -0500 | [diff] [blame^] | 49 | |
| 50 | /** |
| 51 | * @brief Read the manifest file to get the value of the key. |
| 52 | * |
| 53 | * @param[in] filePath - The path to file which contains the value |
| 54 | * of keys. |
| 55 | * @param[in] keys - A map of keys with empty values. |
| 56 | * |
| 57 | * @return The map of keys with filled values. |
| 58 | **/ |
| 59 | static std::map<std::string, std::string> getValue( |
| 60 | const std::string& filePath, |
| 61 | std::map<std::string, std::string> keys); |
| 62 | |
| 63 | /** |
| 64 | * @brief Get the Version id. |
| 65 | * |
| 66 | * @param[in] version - The image version. |
| 67 | * |
| 68 | * @return The id. |
| 69 | */ |
| 70 | static std::string getId(const std::string& version); |
Saqib Khan | ce14870 | 2017-06-11 12:01:58 -0500 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | } // namespace updater |
| 74 | } // namespace software |
| 75 | } // namespace openpower |