diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-11-30 13:43:37 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-12 16:53:38 -0500 |
commit | b83a21ea3eb4848ae7009d6010062aa01620edd5 (patch) | |
tree | 090188e1bd8131f91be8dfcb8b91972e29b60c3b /manager.hpp | |
parent | 432e35277738a03f1ce71614a95d79750795d238 (diff) | |
download | phosphor-inventory-manager-b83a21ea3eb4848ae7009d6010062aa01620edd5.tar.gz phosphor-inventory-manager-b83a21ea3eb4848ae7009d6010062aa01620edd5.zip |
Add interface exposing utility functions
Add utility functions enabling easy method calls on sdbusplus interface
binding objects.
Change-Id: Ie1d01f82604406705869fea0ec19d84c95d90474
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'manager.hpp')
-rw-r--r-- | manager.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/manager.hpp b/manager.hpp index 92afd9f..6326336 100644 --- a/manager.hpp +++ b/manager.hpp @@ -116,6 +116,48 @@ class Manager final : sdbusplus::bus::bus &, const char *); using Makers = std::map<std::string, MakerType>; + /** @brief Provides weak references to interface holders. + * + * Common code for all types for the templated getInterface + * methods. + * + * @param[in] path - The DBus path for which the interface + * holder instance should be provided. + * @param[in] interface - The DBus interface for which the + * holder instance should be provided. + * + * @returns A weak reference to the holder instance. + */ + details::holder::Base& getInterfaceHolder( + const char *, const char *) const; + details::holder::Base& getInterfaceHolder( + const char *, const char *); + + /** @brief Provides weak references to interface holders. + * + * @tparam T - The sdbusplus server binding interface type. + * + * @param[in] path - The DBus path for which the interface + * should be provided. + * @param[in] interface - The DBus interface to obtain. + * + * @returns A weak reference to the interface holder. + */ + template<typename T> + auto& getInterface(const char *path, const char *interface) + { + auto &holder = getInterfaceHolder(path, interface); + return static_cast< + details::holder::Holder<T> &>(holder); + } + template<typename T> + auto& getInterface(const char *path, const char *interface) const + { + auto &holder = getInterfaceHolder(path, interface); + return static_cast< + const details::holder::Holder<T> &>(holder); + } + /** @brief Provided for testing only. */ bool _shutdown; |