summaryrefslogtreecommitdiffstats
path: root/utils.cpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@in.ibm.com>2017-08-07 15:53:25 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-08-11 17:29:08 +0000
commit01d4bd1a6301ebbd892b9c15cf4e5501e96da79b (patch)
treec262a73bc638540a056fabd641d45c230736ce31 /utils.cpp
parent11ddbd21ede92a1d46a4df5fa3d9328b9fe08486 (diff)
downloadphosphor-host-ipmid-01d4bd1a6301ebbd892b9c15cf4e5501e96da79b.tar.gz
phosphor-host-ipmid-01d4bd1a6301ebbd892b9c15cf4e5501e96da79b.zip
Take bus as input parameter in util function
Change-Id: I2de92a1d82939a539e19aca69561ad58a171a5d0 Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
Diffstat (limited to 'utils.cpp')
-rw-r--r--utils.cpp47
1 files changed, 8 insertions, 39 deletions
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<DbusInterface> 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(),
OpenPOWER on IntegriCloud