blob: 60ee4d40ddcc62eab1280b5263eeb89d8ea0f053 [file] [log] [blame]
Deepak Kodihalli18aa0442017-07-21 07:07:09 -05001#pragma once
2
3#include <string>
4#include <sdbusplus/bus.hpp>
5
6namespace settings
7{
8
9using Path = std::string;
10using Service = std::string;
11using Interface = std::string;
12
13constexpr auto root = "/";
14
15/** @class Objects
16 * @brief Fetch paths of settings d-bus objects of interest, upon construction
17 */
18struct Objects
19{
20 public:
21 /** @brief Constructor - fetch settings objects
22 *
23 * @param[in] bus - The Dbus bus object
24 * @param[in] filter - A vector of settings interfaces the caller is
25 * interested in.
26 */
27 Objects(sdbusplus::bus::bus& bus, const std::vector<Interface>& filter);
28 Objects(const Objects&) = default;
29 Objects& operator=(const Objects&) = default;
30 Objects(Objects&&) = delete;
31 Objects& operator=(Objects&&) = delete;
32 ~Objects() = default;
33
34 /** @brief Fetch d-bus service, given a path and an interface. The
35 * service can't be cached because mapper returns unique
36 * service names.
37 *
38 * @param[in] path - The Dbus object
39 * @param[in] interface - The Dbus interface
40 *
41 * @return std::string - the dbus service
42 */
43 Service service(const Path& path, const Interface& interface) const;
44
45 // TODO openbmc/openbmc#2058 - This will break when multiple settings,
46 // or in general multiple objects implement a single setting interface.
47 // For instance this will break for a 2-blade server, because we'd have
48 // 2 sets of settings objects. Need to revisit and fix this.
49 /** @brief map of settings objects */
50 std::map<Interface, Path> map;
51
52 /** @brief The Dbus bus object */
53 sdbusplus::bus::bus& bus;
54};
55
56} // namespace settings