blob: 75289a3dfe026f8d7867e1c04d3142ecf9fd669a [file] [log] [blame]
Gunnar Mills392f2942017-04-12 11:04:37 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4#include "xyz/openbmc_project/Software/Version/server.hpp"
Gunnar Millsef4781f2017-04-19 11:28:24 -05005#include "xyz/openbmc_project/Common/FilePath/server.hpp"
Gunnar Mills392f2942017-04-12 11:04:37 -05006
7namespace phosphor
8{
9namespace software
10{
11namespace manager
12{
13
14using VersionInherit = sdbusplus::server::object::object<
Gunnar Millsef4781f2017-04-19 11:28:24 -050015 sdbusplus::xyz::openbmc_project::Software::server::Version,
16 sdbusplus::xyz::openbmc_project::Common::server::FilePath>;
Gunnar Mills392f2942017-04-12 11:04:37 -050017
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 *
Gunnar Millscebd1022017-04-17 16:10:15 -050028 * @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
Gunnar Millsef4781f2017-04-19 11:28:24 -050032 * @param[in] filePath - The image filesystem path
Gunnar Mills392f2942017-04-12 11:04:37 -050033 */
34 Version(sdbusplus::bus::bus& bus,
35 const std::string& objPath,
Gunnar Millscebd1022017-04-17 16:10:15 -050036 const std::string& versionId,
Gunnar Millsef4781f2017-04-19 11:28:24 -050037 VersionPurpose versionPurpose,
38 const std::string& filePath) : VersionInherit(
Gunnar Mills392f2942017-04-12 11:04:37 -050039 bus, (objPath).c_str(), true)
40 {
41 // Set properties.
Gunnar Millscebd1022017-04-17 16:10:15 -050042 purpose(versionPurpose);
Gunnar Mills392f2942017-04-12 11:04:37 -050043 version(versionId);
Gunnar Millsef4781f2017-04-19 11:28:24 -050044 path(filePath);
Gunnar Mills392f2942017-04-12 11:04:37 -050045
46 // Emit deferred signal.
47 emit_object_added();
48 }
49
50 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050051 * @brief Read the manifest file to get the value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050052 *
Gunnar Millscebd1022017-04-17 16:10:15 -050053 * @return The value of the key.
Gunnar Mills392f2942017-04-12 11:04:37 -050054 **/
Gunnar Millscebd1022017-04-17 16:10:15 -050055 static std::string getValue(const std::string& manifestFilePath,
56 std::string key);
Gunnar Mills392f2942017-04-12 11:04:37 -050057
58 /**
Gunnar Millscebd1022017-04-17 16:10:15 -050059 * @brief Get the Version id.
Gunnar Mills392f2942017-04-12 11:04:37 -050060 *
61 * @return The id.
62 **/
63 static std::string getId(const std::string& version);
Gunnar Millscebd1022017-04-17 16:10:15 -050064
Gunnar Mills392f2942017-04-12 11:04:37 -050065};
66
67} // namespace manager
68} // namespace software
69} // namespace phosphor
70