Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | #include <sdbusplus/bus.hpp> |
| 5 | |
| 6 | namespace settings |
| 7 | { |
| 8 | |
| 9 | using Path = std::string; |
| 10 | using Service = std::string; |
| 11 | using Interface = std::string; |
| 12 | |
| 13 | constexpr auto root = "/"; |
| 14 | |
| 15 | /** @class Objects |
| 16 | * @brief Fetch paths of settings d-bus objects of interest, upon construction |
| 17 | */ |
| 18 | struct 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 |