blob: 42a856009d67ca595c62c467187a9c44d8256dd2 [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 Kodihalli18aa0442017-07-21 07:07:09 -050054} // namespace settings