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