blob: 5382fddcc9f3dd3b9b64bccd77bbcae000eb19be [file] [log] [blame]
Tom Joseph19b4f402017-08-02 17:59:30 +05301#pragma once
2
Vernon Mauery9e801a22018-10-12 13:20:49 -07003#include <sdbusplus/bus.hpp>
Tom Joseph19b4f402017-08-02 17:59:30 +05304#include <string>
Tom Joseph9c60a582017-09-13 17:10:46 +05305#include <tuple>
Tom Joseph19b4f402017-08-02 17:59:30 +05306
7namespace settings
8{
9
10using Path = std::string;
11using Service = std::string;
12using Interface = std::string;
13
14constexpr auto root = "/";
15
16/** @class Objects
17 * @brief Fetch paths of settings d-bus objects of interest, upon construction
18 */
19struct Objects
20{
Vernon Mauery9e801a22018-10-12 13:20:49 -070021 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 */
28 Objects(sdbusplus::bus::bus& bus, const std::vector<Interface>& filter);
29 Objects(const Objects&) = default;
30 Objects& operator=(const Objects&) = default;
31 Objects(Objects&&) = delete;
32 Objects& operator=(Objects&&) = delete;
33 ~Objects() = default;
Tom Joseph19b4f402017-08-02 17:59:30 +053034
Vernon Mauery9e801a22018-10-12 13:20:49 -070035 /** @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;
Tom Joseph19b4f402017-08-02 17:59:30 +053045
Vernon Mauery9e801a22018-10-12 13:20:49 -070046 /** @brief map of settings objects */
47 std::map<Interface, std::vector<Path>> map;
Tom Joseph19b4f402017-08-02 17:59:30 +053048
Vernon Mauery9e801a22018-10-12 13:20:49 -070049 /** @brief The Dbus bus object */
50 sdbusplus::bus::bus& bus;
Tom Joseph19b4f402017-08-02 17:59:30 +053051};
52
Tom Joseph9c60a582017-09-13 17:10:46 +053053namespace boot
54{
55
56using 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 */
67std::tuple<Path, OneTimeEnabled> setting(const Objects& objects,
68 const Interface& iface);
69
70} // namespace boot
71
Tom Joseph19b4f402017-08-02 17:59:30 +053072} // namespace settings