diff options
author | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-07-21 07:07:09 -0500 |
---|---|---|
committer | Deepak Kodihalli <dkodihal@in.ibm.com> | 2017-07-31 22:48:26 -0500 |
commit | 18aa044eace292d2d58406e06e3ca4a98fbfaaea (patch) | |
tree | c0b58725a4ef134e2d99910955fa2e9090526867 /settings.hpp | |
parent | 6c8d51baee01211c671567881dec27c327ae2c86 (diff) | |
download | phosphor-host-ipmid-18aa044eace292d2d58406e06e3ca4a98fbfaaea.tar.gz phosphor-host-ipmid-18aa044eace292d2d58406e06e3ca4a98fbfaaea.zip |
Add API to retrieve settings
Add API to retrieve and cache settings objects of interest.
Change-Id: I8afd58b5b3e9a691e4d3fa6bfba2ba5c92cd2568
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
Diffstat (limited to 'settings.hpp')
-rw-r--r-- | settings.hpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/settings.hpp b/settings.hpp new file mode 100644 index 0000000..60ee4d4 --- /dev/null +++ b/settings.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include <string> +#include <sdbusplus/bus.hpp> + +namespace settings +{ + +using Path = std::string; +using Service = std::string; +using Interface = std::string; + +constexpr auto root = "/"; + +/** @class Objects + * @brief Fetch paths of settings d-bus objects of interest, upon construction + */ +struct Objects +{ + public: + /** @brief Constructor - fetch settings objects + * + * @param[in] bus - The Dbus bus object + * @param[in] filter - A vector of settings interfaces the caller is + * interested in. + */ + Objects(sdbusplus::bus::bus& bus, const std::vector<Interface>& filter); + Objects(const Objects&) = default; + Objects& operator=(const Objects&) = default; + Objects(Objects&&) = delete; + Objects& operator=(Objects&&) = delete; + ~Objects() = default; + + /** @brief Fetch d-bus service, given a path and an interface. The + * service can't be cached because mapper returns unique + * service names. + * + * @param[in] path - The Dbus object + * @param[in] interface - The Dbus interface + * + * @return std::string - the dbus service + */ + Service service(const Path& path, const Interface& interface) const; + + // TODO openbmc/openbmc#2058 - This will break when multiple settings, + // or in general multiple objects implement a single setting interface. + // For instance this will break for a 2-blade server, because we'd have + // 2 sets of settings objects. Need to revisit and fix this. + /** @brief map of settings objects */ + std::map<Interface, Path> map; + + /** @brief The Dbus bus object */ + sdbusplus::bus::bus& bus; +}; + +} // namespace settings |