Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 4 | #include <string> |
Deepak Kodihalli | 13791bd | 2017-08-28 06:50:51 -0500 | [diff] [blame] | 5 | #include <tuple> |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 6 | |
| 7 | namespace settings |
| 8 | { |
| 9 | |
| 10 | using Path = std::string; |
| 11 | using Service = std::string; |
| 12 | using Interface = std::string; |
| 13 | |
| 14 | constexpr auto root = "/"; |
| 15 | |
| 16 | /** @class Objects |
| 17 | * @brief Fetch paths of settings d-bus objects of interest, upon construction |
| 18 | */ |
| 19 | struct Objects |
| 20 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 21 | public: |
| 22 | /** @brief Constructor - fetch settings objects |
| 23 | * |
| 24 | * @param[in] bus - The Dbus bus object |
| 25 | * @param[in] filter - A vector of settings interfaces the caller is |
| 26 | * interested in. |
| 27 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 28 | Objects(sdbusplus::bus_t& bus, const std::vector<Interface>& filter); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 29 | Objects(const Objects&) = default; |
| 30 | Objects& operator=(const Objects&) = default; |
| 31 | Objects(Objects&&) = delete; |
| 32 | Objects& operator=(Objects&&) = delete; |
| 33 | ~Objects() = default; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 34 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 35 | /** @brief Fetch d-bus service, given a path and an interface. The |
| 36 | * service can't be cached because mapper returns unique |
| 37 | * service names. |
| 38 | * |
| 39 | * @param[in] path - The Dbus object |
| 40 | * @param[in] interface - The Dbus interface |
| 41 | * |
| 42 | * @return std::string - the dbus service |
| 43 | */ |
| 44 | Service service(const Path& path, const Interface& interface) const; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 45 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 46 | /** @brief map of settings objects */ |
| 47 | std::map<Interface, std::vector<Path>> map; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 48 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 49 | /** @brief The Dbus bus object */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 50 | sdbusplus::bus_t& bus; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 51 | }; |
| 52 | |
Deepak Kodihalli | 13791bd | 2017-08-28 06:50:51 -0500 | [diff] [blame] | 53 | namespace boot |
| 54 | { |
| 55 | |
| 56 | using OneTimeEnabled = bool; |
| 57 | |
| 58 | /** @brief Return the one-time boot setting object path if enabled, otherwise |
| 59 | * the regular boot setting object path. |
| 60 | * |
| 61 | * @param[in] objects - const reference to an object of type Objects |
| 62 | * @param[in] iface - boot setting interface |
| 63 | * |
| 64 | * @return A tuple - boot setting object path, a bool indicating whether the |
| 65 | * returned path corresponds to the one time boot setting. |
| 66 | */ |
| 67 | std::tuple<Path, OneTimeEnabled> setting(const Objects& objects, |
| 68 | const Interface& iface); |
| 69 | |
| 70 | } // namespace boot |
| 71 | |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 72 | } // namespace settings |