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 | |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 15 | /** @class Objects |
| 16 | * @brief Fetch paths of settings d-bus objects of interest, upon construction |
| 17 | */ |
| 18 | struct Objects |
| 19 | { |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 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 | */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 27 | Objects(sdbusplus::bus_t& bus, const std::vector<Interface>& filter); |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 28 | Objects(const Objects&) = default; |
| 29 | Objects& operator=(const Objects&) = default; |
| 30 | Objects(Objects&&) = delete; |
| 31 | Objects& operator=(Objects&&) = delete; |
| 32 | ~Objects() = default; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 33 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 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; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 44 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 45 | /** @brief map of settings objects */ |
| 46 | std::map<Interface, std::vector<Path>> map; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 47 | |
Patrick Venture | 0b02be9 | 2018-08-31 11:55:55 -0700 | [diff] [blame] | 48 | /** @brief The Dbus bus object */ |
Patrick Williams | 5d82f47 | 2022-07-22 19:26:53 -0500 | [diff] [blame] | 49 | sdbusplus::bus_t& bus; |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 50 | }; |
| 51 | |
Deepak Kodihalli | 18aa044 | 2017-07-21 07:07:09 -0500 | [diff] [blame] | 52 | } // namespace settings |