Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 4 | |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 5 | #include <string> |
Deepak Kodihalli | 13791bd | 2017-08-28 06:50:51 -0500 | [diff] [blame] | 6 | #include <tuple> |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 7 | |
| 8 | namespace settings |
| 9 | { |
| 10 | |
| 11 | using Path = std::string; |
| 12 | using Service = std::string; |
| 13 | using Interface = std::string; |
| 14 | |
| 15 | constexpr auto root = "/"; |
| 16 | |
| 17 | /** @class Objects |
| 18 | * @brief Fetch paths of settings d-bus objects of interest, upon construction |
| 19 | */ |
| 20 | struct Objects |
| 21 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 22 | 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 Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 29 | Objects(sdbusplus::bus_t& bus, const std::vector<Interface>& filter); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 30 | Objects(const Objects&) = default; |
| 31 | Objects& operator=(const Objects&) = default; |
| 32 | Objects(Objects&&) = delete; |
| 33 | Objects& operator=(Objects&&) = delete; |
| 34 | ~Objects() = default; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 35 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 36 | /** @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 Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 46 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 47 | /** @brief map of settings objects */ |
| 48 | std::map<Interface, std::vector<Path>> map; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 49 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 50 | /** @brief The Dbus bus object */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 51 | sdbusplus::bus_t& bus; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 52 | }; |
| 53 | |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 54 | } // namespace settings |