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> |
| 4 | |
Andrew Geissler | e426b58 | 2020-05-28 12:40:55 -0500 | [diff] [blame] | 5 | #include <string> |
| 6 | |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 7 | namespace settings |
| 8 | { |
| 9 | |
| 10 | using Path = std::string; |
| 11 | using Service = std::string; |
| 12 | using Interface = std::string; |
| 13 | |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 14 | constexpr auto defaultRoot = "/"; |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 15 | constexpr auto autoRebootIntf = "xyz.openbmc_project.Control.Boot.RebootPolicy"; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 16 | constexpr 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 | */ |
| 22 | struct Objects |
| 23 | { |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 24 | public: |
| 25 | /** @brief Constructor - fetch settings objects |
| 26 | * |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 27 | * @param[in] bus - The Dbus bus object |
| 28 | * @param[in] root - The root object path |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 29 | */ |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 30 | explicit Objects(sdbusplus::bus::bus& bus, const Path& root = defaultRoot); |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 31 | Objects(const Objects&) = delete; |
| 32 | Objects& operator=(const Objects&) = delete; |
| 33 | Objects(Objects&&) = delete; |
| 34 | Objects& operator=(Objects&&) = delete; |
| 35 | ~Objects() = default; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 36 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 37 | /** @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 Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 47 | |
Andrew Geissler | e87db70 | 2020-10-22 19:33:26 -0500 | [diff] [blame] | 48 | /** @brief host auto_reboot user settings object */ |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 49 | Path autoReboot; |
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 one-time settings object */ |
| 52 | Path autoRebootOneTime; |
| 53 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 54 | /** @brief host power_restore_policy settings object */ |
| 55 | Path powerRestorePolicy; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 56 | |
Andrew Geissler | 35ca2e3 | 2021-02-09 13:54:26 -0600 | [diff] [blame] | 57 | /** @brief host power_restore_policy one-time settings object */ |
| 58 | Path powerRestorePolicyOneTime; |
| 59 | |
Andrew Geissler | 58a1801 | 2018-01-19 19:36:05 -0800 | [diff] [blame] | 60 | /** @brief The Dbus bus object */ |
| 61 | sdbusplus::bus::bus& bus; |
Deepak Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 62 | }; |
| 63 | |
Potin Lai | c328a4c | 2022-03-18 23:49:37 +0800 | [diff] [blame] | 64 | /** @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 | */ |
| 69 | struct 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 Kodihalli | a646edd | 2017-07-25 07:28:45 -0500 | [diff] [blame] | 80 | } // namespace settings |