blob: e813f06796c9f4e5acc0bce51ff6f7b909d45c33 [file] [log] [blame]
Deepak Kodihalli18aa0442017-07-21 07:07:09 -05001#pragma once
2
Patrick Venture0b02be92018-08-31 11:55:55 -07003#include <sdbusplus/bus.hpp>
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -05004
Deepak Kodihalli18aa0442017-07-21 07:07:09 -05005#include <string>
Deepak Kodihalli13791bd2017-08-28 06:50:51 -05006#include <tuple>
Deepak Kodihalli18aa0442017-07-21 07:07:09 -05007
8namespace settings
9{
10
11using Path = std::string;
12using Service = std::string;
13using Interface = std::string;
14
15constexpr auto root = "/";
16
17/** @class Objects
18 * @brief Fetch paths of settings d-bus objects of interest, upon construction
19 */
20struct Objects
21{
Patrick Venture0b02be92018-08-31 11:55:55 -070022 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 */
Patrick Williams5d82f472022-07-22 19:26:53 -050029 Objects(sdbusplus::bus_t& bus, const std::vector<Interface>& filter);
Patrick Venture0b02be92018-08-31 11:55:55 -070030 Objects(const Objects&) = default;
31 Objects& operator=(const Objects&) = default;
32 Objects(Objects&&) = delete;
33 Objects& operator=(Objects&&) = delete;
34 ~Objects() = default;
Deepak Kodihalli18aa0442017-07-21 07:07:09 -050035
Patrick Venture0b02be92018-08-31 11:55:55 -070036 /** @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;
Deepak Kodihalli18aa0442017-07-21 07:07:09 -050046
Patrick Venture0b02be92018-08-31 11:55:55 -070047 /** @brief map of settings objects */
48 std::map<Interface, std::vector<Path>> map;
Deepak Kodihalli18aa0442017-07-21 07:07:09 -050049
Patrick Venture0b02be92018-08-31 11:55:55 -070050 /** @brief The Dbus bus object */
Patrick Williams5d82f472022-07-22 19:26:53 -050051 sdbusplus::bus_t& bus;
Deepak Kodihalli18aa0442017-07-21 07:07:09 -050052};
53
Deepak Kodihalli13791bd2017-08-28 06:50:51 -050054namespace boot
55{
56
57using 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 */
68std::tuple<Path, OneTimeEnabled> setting(const Objects& objects,
69 const Interface& iface);
70
71} // namespace boot
72
Deepak Kodihalli18aa0442017-07-21 07:07:09 -050073} // namespace settings