Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Patrick Williams | 9a286db | 2024-01-17 06:29:47 -0600 | [diff] [blame] | 4 | #include <xyz/openbmc_project/Control/Boot/RebootPolicy/client.hpp> |
| 5 | #include <xyz/openbmc_project/Control/Power/RestorePolicy/client.hpp> |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 6 | |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 7 | #include <string> |
| 8 | |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 9 | namespace settings |
| 10 | { |
| 11 | |
| 12 | using Path = std::string; |
| 13 | using Service = std::string; |
| 14 | using Interface = std::string; |
| 15 | |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 16 | constexpr auto defaultRoot = "/"; |
Patrick Williams | 9a286db | 2024-01-17 06:29:47 -0600 | [diff] [blame] | 17 | constexpr auto autoRebootIntf = sdbusplus::client::xyz::openbmc_project:: |
| 18 | control::boot::RebootPolicy<>::interface; |
| 19 | constexpr auto powerRestoreIntf = sdbusplus::client::xyz::openbmc_project:: |
| 20 | control::power::RestorePolicy<>::interface; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 21 | |
| 22 | /** @class Objects |
| 23 | * @brief Fetch paths of settings d-bus objects of interest, upon construction |
| 24 | */ |
| 25 | struct Objects |
| 26 | { |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 27 | public: |
| 28 | /** @brief Constructor - fetch settings objects |
| 29 | * |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 30 | * @param[in] bus - The Dbus bus object |
| 31 | * @param[in] root - The root object path |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 32 | */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 33 | explicit Objects(sdbusplus::bus_t& bus, const Path& root = defaultRoot); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 34 | Objects(const Objects&) = delete; |
| 35 | Objects& operator=(const Objects&) = delete; |
| 36 | Objects(Objects&&) = delete; |
| 37 | Objects& operator=(Objects&&) = delete; |
| 38 | ~Objects() = default; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 39 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 40 | /** @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 Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 50 | |
Andrew Geissler | e87db70 | 2020-10-22 19:33:26 -0500 | [diff] [blame] | 51 | /** @brief host auto_reboot user settings object */ |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 52 | Path autoReboot; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 53 | |
Andrew Geissler | e87db70 | 2020-10-22 19:33:26 -0500 | [diff] [blame] | 54 | /** @brief host auto_reboot one-time settings object */ |
| 55 | Path autoRebootOneTime; |
| 56 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 57 | /** @brief host power_restore_policy settings object */ |
| 58 | Path powerRestorePolicy; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 59 | |
Andrew Geissler | 35ca2e3 | 2021-02-09 13:54:26 -0600 | [diff] [blame] | 60 | /** @brief host power_restore_policy one-time settings object */ |
| 61 | Path powerRestorePolicyOneTime; |
| 62 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 63 | /** @brief The Dbus bus object */ |
Patrick Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 64 | sdbusplus::bus_t& bus; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 65 | }; |
| 66 | |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 67 | /** @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 | */ |
| 72 | struct 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 Williams | f053e6f | 2022-07-22 19:26:54 -0500 | [diff] [blame] | 80 | HostObjects(sdbusplus::bus_t& bus, size_t id); |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 81 | }; |
| 82 | |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 83 | } // namespace settings |