From 01d4bd1a6301ebbd892b9c15cf4e5501e96da79b Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Mon, 7 Aug 2017 15:53:25 +0530 Subject: Take bus as input parameter in util function Change-Id: I2de92a1d82939a539e19aca69561ad58a171a5d0 Signed-off-by: Ratan Gupta --- utils.cpp | 47 ++++++++--------------------------------------- 1 file changed, 8 insertions(+), 39 deletions(-) (limited to 'utils.cpp') diff --git a/utils.cpp b/utils.cpp index ad5f997..fa92e48 100644 --- a/utils.cpp +++ b/utils.cpp @@ -10,13 +10,6 @@ namespace ipmi using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Common::Error; -/** @brief Gets the dbus object info implementing the given interface - * from the given subtree. - * @param[in] interface - Dbus interface. - * @param[in] serviceRoot - subtree from where the search should start. - * @param[in] match - identifier for object. - * @return On success returns the object having objectpath and servicename. - */ //TODO There may be cases where an interface is implemented by multiple // objects,to handle such cases we are interested on that object @@ -24,14 +17,14 @@ using namespace sdbusplus::xyz::openbmc_project::Common::Error; // Currently mapper doesn't give the readable busname(gives busid) so we can't // use busname to find the object,will do later once the support is there. -DbusObjectInfo getDbusObject(const std::string& interface, +DbusObjectInfo getDbusObject(sdbusplus::bus::bus& bus, + const std::string& interface, const std::string& serviceRoot, const std::string& match) { std::vector interfaces; interfaces.emplace_back(interface); - auto bus = sdbusplus::bus::new_default(); auto depth = 0; auto mapperCall = bus.new_method_call(MAPPER_BUS_NAME, @@ -91,15 +84,8 @@ DbusObjectInfo getDbusObject(const std::string& interface, } -/** @brief Gets the value associated with the given object - * and the interface. - * @param[in] service - Dbus service name. - * @param[in] objPath - Dbus object path. - * @param[in] interface - Dbus interface. - * @param[in] property - name of the property. - * @return On success returns the value of the property. - */ -Value getDbusProperty(const std::string& service, +Value getDbusProperty(sdbusplus::bus::bus& bus, + const std::string& service, const std::string& objPath, const std::string& interface, const std::string& property) @@ -107,8 +93,6 @@ Value getDbusProperty(const std::string& service, Value value; - auto bus = sdbusplus::bus::new_default(); - auto method = bus.new_method_call( service.c_str(), objPath.c_str(), @@ -133,19 +117,12 @@ Value getDbusProperty(const std::string& service, return value; } -/** @brief Gets all the properties associated with the given object - * and the interface. - * @param[in] service - Dbus service name. - * @param[in] objPath - Dbus object path. - * @param[in] interface - Dbus interface. - * @return On success returns the map of name value pair. - */ -PropertyMap getAllDbusProperties(const std::string& service, +PropertyMap getAllDbusProperties(sdbusplus::bus::bus& bus, + const std::string& service, const std::string& objPath, const std::string& interface) { PropertyMap properties; - auto bus = sdbusplus::bus::new_default(); auto method = bus.new_method_call( service.c_str(), @@ -169,21 +146,13 @@ PropertyMap getAllDbusProperties(const std::string& service, return properties; } -/** @brief Sets the property value of the given object. - * @param[in] service - Dbus service name. - * @param[in] objPath - Dbus object path. - * @param[in] interface - Dbus interface. - * @param[in] property - name of the property. - * @param[in] value - value which needs to be set. - */ -void setDbusProperty(const std::string& service, +void setDbusProperty(sdbusplus::bus::bus& bus, + const std::string& service, const std::string& objPath, const std::string& interface, const std::string& property, const Value& value) { - auto bus = sdbusplus::bus::new_default(); - auto method = bus.new_method_call( service.c_str(), objPath.c_str(), -- cgit v1.2.1