blob: a4ec5cc69f521e443a101da5a7e520f25d71ba88 [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;
19constexpr auto powerRestoreIntf = sdbusplus::client::xyz::openbmc_project::
20 control::power::RestorePolicy<>::interface;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050021
22/** @class Objects
23 * @brief Fetch paths of settings d-bus objects of interest, upon construction
24 */
25struct Objects
26{
Andrew Geissler58a18012018-01-19 19:36:05 -080027 public:
28 /** @brief Constructor - fetch settings objects
29 *
Potin Laic328a4c2022-03-18 23:49:37 +080030 * @param[in] bus - The Dbus bus object
31 * @param[in] root - The root object path
Andrew Geissler58a18012018-01-19 19:36:05 -080032 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050033 explicit Objects(sdbusplus::bus_t& bus, const Path& root = defaultRoot);
Andrew Geissler58a18012018-01-19 19:36:05 -080034 Objects(const Objects&) = delete;
35 Objects& operator=(const Objects&) = delete;
36 Objects(Objects&&) = delete;
37 Objects& operator=(Objects&&) = delete;
38 ~Objects() = default;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050039
Andrew Geissler58a18012018-01-19 19:36:05 -080040 /** @brief Fetch d-bus service, given a path and an interface. The
41 * service can't be cached because mapper returns unique
42 * service names.
43 *
44 * @param[in] path - The Dbus object
45 * @param[in] interface - The Dbus interface
46 *
47 * @return std::string - the dbus service name
48 */
49 Service service(const Path& path, const Interface& interface) const;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050050
Andrew Geisslere87db702020-10-22 19:33:26 -050051 /** @brief host auto_reboot user settings object */
Andrew Geissler58a18012018-01-19 19:36:05 -080052 Path autoReboot;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050053
Andrew Geisslere87db702020-10-22 19:33:26 -050054 /** @brief host auto_reboot one-time settings object */
55 Path autoRebootOneTime;
56
Andrew Geissler58a18012018-01-19 19:36:05 -080057 /** @brief host power_restore_policy settings object */
58 Path powerRestorePolicy;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050059
Andrew Geissler35ca2e32021-02-09 13:54:26 -060060 /** @brief host power_restore_policy one-time settings object */
61 Path powerRestorePolicyOneTime;
62
Andrew Geissler58a18012018-01-19 19:36:05 -080063 /** @brief The Dbus bus object */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050064 sdbusplus::bus_t& bus;
Deepak Kodihallia646edd2017-07-25 07:28:45 -050065};
66
Potin Laic328a4c2022-03-18 23:49:37 +080067/** @class HostObjects
68 * @brief Fetch paths of settings d-bus objects of Host
69 * @note IMPORTANT: This class only supports settings under the
70 * /xyz/openbmc_project/control/hostX object paths
71 */
72struct HostObjects : public Objects
73{
74 public:
75 /** @brief Constructor - fetch settings objects of Host
76 *
77 * @param[in] bus - The Dbus bus object
78 * @param[in] id - The Host id
79 */
Patrick Williamsf053e6f2022-07-22 19:26:54 -050080 HostObjects(sdbusplus::bus_t& bus, size_t id);
Potin Laic328a4c2022-03-18 23:49:37 +080081};
82
Deepak Kodihallia646edd2017-07-25 07:28:45 -050083} // namespace settings