blob: b54f202304b0ec0145d4afde3ec7c9fadba91f1f [file] [log] [blame]
Deepak Kodihallia646edd2017-07-25 07:28:45 -05001#pragma once
2
Deepak Kodihallia646edd2017-07-25 07:28:45 -05003#include <sdbusplus/bus.hpp>
4
Andrew Geisslere426b582020-05-28 12:40:55 -05005#include <string>
6
Deepak Kodihallia646edd2017-07-25 07:28:45 -05007namespace settings
8{
9
10using Path = std::string;
11using Service = std::string;
12using Interface = std::string;
13
Potin Laic328a4c2022-03-18 23:49:37 +080014constexpr auto defaultRoot = "/";
Andrew Geissler58a18012018-01-19 19:36:05 -080015constexpr auto autoRebootIntf = "xyz.openbmc_project.Control.Boot.RebootPolicy";
Deepak Kodihallia646edd2017-07-25 07:28:45 -050016constexpr auto powerRestoreIntf =
17 "xyz.openbmc_project.Control.Power.RestorePolicy";
18
19/** @class Objects
20 * @brief Fetch paths of settings d-bus objects of interest, upon construction
21 */
22struct Objects
23{
Andrew Geissler58a18012018-01-19 19:36:05 -080024 public:
25 /** @brief Constructor - fetch settings objects
26 *
Potin Laic328a4c2022-03-18 23:49:37 +080027 * @param[in] bus - The Dbus bus object
28 * @param[in] root - The root object path
Andrew Geissler58a18012018-01-19 19:36:05 -080029 */
Potin Laic328a4c2022-03-18 23:49:37 +080030 explicit Objects(sdbusplus::bus::bus& bus, const Path& root = defaultRoot);
Andrew Geissler58a18012018-01-19 19:36:05 -080031 Objects(const Objects&) = delete;
32 Objects& operator=(const Objects&) = delete;
33 Objects(Objects&&) = delete;
34 Objects& operator=(Objects&&) = delete;
35 ~Objects() = default;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050036
Andrew Geissler58a18012018-01-19 19:36:05 -080037 /** @brief Fetch d-bus service, given a path and an interface. The
38 * service can't be cached because mapper returns unique
39 * service names.
40 *
41 * @param[in] path - The Dbus object
42 * @param[in] interface - The Dbus interface
43 *
44 * @return std::string - the dbus service name
45 */
46 Service service(const Path& path, const Interface& interface) const;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050047
Andrew Geisslere87db702020-10-22 19:33:26 -050048 /** @brief host auto_reboot user settings object */
Andrew Geissler58a18012018-01-19 19:36:05 -080049 Path autoReboot;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050050
Andrew Geisslere87db702020-10-22 19:33:26 -050051 /** @brief host auto_reboot one-time settings object */
52 Path autoRebootOneTime;
53
Andrew Geissler58a18012018-01-19 19:36:05 -080054 /** @brief host power_restore_policy settings object */
55 Path powerRestorePolicy;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050056
Andrew Geissler35ca2e32021-02-09 13:54:26 -060057 /** @brief host power_restore_policy one-time settings object */
58 Path powerRestorePolicyOneTime;
59
Andrew Geissler58a18012018-01-19 19:36:05 -080060 /** @brief The Dbus bus object */
61 sdbusplus::bus::bus& bus;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050062};
63
Potin Laic328a4c2022-03-18 23:49:37 +080064/** @class HostObjects
65 * @brief Fetch paths of settings d-bus objects of Host
66 * @note IMPORTANT: This class only supports settings under the
67 * /xyz/openbmc_project/control/hostX object paths
68 */
69struct HostObjects : public Objects
70{
71 public:
72 /** @brief Constructor - fetch settings objects of Host
73 *
74 * @param[in] bus - The Dbus bus object
75 * @param[in] id - The Host id
76 */
77 HostObjects(sdbusplus::bus::bus& bus, size_t id);
78};
79
Deepak Kodihallia646edd2017-07-25 07:28:45 -050080} // namespace settings