blob: 23bf604a768cc2c76e4eeb5b6e6c1e360d73c201 [file] [log] [blame]
Saqib Khance148702017-06-11 12:01:58 -05001#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
7namespace openpower
8{
9namespace software
10{
11namespace updater
12{
13
14using 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 */
23class 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 Khan167601b2017-06-18 23:33:46 -050049
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 Khance148702017-06-11 12:01:58 -050071};
72
73} // namespace updater
74} // namespace software
75} // namespace openpower