blob: 5f721b89c1f52b6d513ff4aaaa4bbedc740c8932 [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>
Patrick Williams9a286db2024-01-17 06:29:47 -06004#include <xyz/openbmc_project/Control/Boot/RebootPolicy/client.hpp>
5#include <xyz/openbmc_project/Control/Power/RestorePolicy/client.hpp>
Deepak Kodihallia646edd2017-07-25 07:28:45 -05006
Andrew Geisslere426b582020-05-28 12:40:55 -05007#include <string>
8
Deepak Kodihallia646edd2017-07-25 07:28:45 -05009namespace settings
10{
11
12using Path = std::string;
13using Service = std::string;
14using Interface = std::string;
15
Potin Laic328a4c2022-03-18 23:49:37 +080016constexpr auto defaultRoot = "/";
Patrick Williams9a286db2024-01-17 06:29:47 -060017constexpr auto autoRebootIntf = sdbusplus::client::xyz::openbmc_project::
18 control::boot::RebootPolicy<>::interface;
Alexander Hansen0e38d192025-10-22 16:04:01 +020019using PowerRestorePolicy =
20 sdbusplus::common::xyz::openbmc_project::control::power::RestorePolicy;
21constexpr auto powerRestoreIntf = PowerRestorePolicy::interface;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050022
23/** @class Objects
24 * @brief Fetch paths of settings d-bus objects of interest, upon construction
25 */
26struct Objects
27{
Andrew Geissler58a18012018-01-19 19:36:05 -080028 public:
29 /** @brief Constructor - fetch settings objects
30 *
Potin Laic328a4c2022-03-18 23:49:37 +080031 * @param[in] bus - The Dbus bus object
32 * @param[in] root - The root object path
Andrew Geissler58a18012018-01-19 19:36:05 -080033 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050034 explicit Objects(sdbusplus::bus_t& bus, const Path& root = defaultRoot);
Andrew Geissler58a18012018-01-19 19:36:05 -080035 Objects(const Objects&) = delete;
36 Objects& operator=(const Objects&) = delete;
37 Objects(Objects&&) = delete;
38 Objects& operator=(Objects&&) = delete;
39 ~Objects() = default;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050040
Andrew Geissler58a18012018-01-19 19:36:05 -080041 /** @brief Fetch d-bus service, given a path and an interface. The
42 * service can't be cached because mapper returns unique
43 * service names.
44 *
45 * @param[in] path - The Dbus object
46 * @param[in] interface - The Dbus interface
47 *
48 * @return std::string - the dbus service name
49 */
50 Service service(const Path& path, const Interface& interface) const;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050051
Andrew Geisslere87db702020-10-22 19:33:26 -050052 /** @brief host auto_reboot user settings object */
Andrew Geissler58a18012018-01-19 19:36:05 -080053 Path autoReboot;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050054
Andrew Geisslere87db702020-10-22 19:33:26 -050055 /** @brief host auto_reboot one-time settings object */
56 Path autoRebootOneTime;
57
Andrew Geissler58a18012018-01-19 19:36:05 -080058 /** @brief host power_restore_policy settings object */
59 Path powerRestorePolicy;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050060
Andrew Geissler35ca2e32021-02-09 13:54:26 -060061 /** @brief host power_restore_policy one-time settings object */
62 Path powerRestorePolicyOneTime;
63
Andrew Geissler58a18012018-01-19 19:36:05 -080064 /** @brief The Dbus bus object */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050065 sdbusplus::bus_t& bus;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050066};
67
Potin Laic328a4c2022-03-18 23:49:37 +080068/** @class HostObjects
69 * @brief Fetch paths of settings d-bus objects of Host
70 * @note IMPORTANT: This class only supports settings under the
71 * /xyz/openbmc_project/control/hostX object paths
72 */
73struct HostObjects : public Objects
74{
75 public:
76 /** @brief Constructor - fetch settings objects of Host
77 *
78 * @param[in] bus - The Dbus bus object
79 * @param[in] id - The Host id
80 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050081 HostObjects(sdbusplus::bus_t& bus, size_t id);
Potin Laic328a4c2022-03-18 23:49:37 +080082};
83
Deepak Kodihallia646edd2017-07-25 07:28:45 -050084} // namespace settings