Refactor D-Bus object
- The intent behind this commit is to refactor D-Bus, and abstract
the bus, getService, getProperty and other methods into the utils
file, and other file operations D-Bus only need to include
uitls.hpp.
- We can also continue to add other general methods such as
setPropery, getSubTree in the utils file in the future.
- Also, removed redundant files(occ_finder.hpp and occ_finder.cpp).
Tested: built openpower-occ-control successfully and worked.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I53e61e30a76173c154a9f47fc122936468abbc4b
diff --git a/powercap.hpp b/powercap.hpp
index c7861a4..bb4dc8b 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -3,6 +3,7 @@
#include "config.h"
#include "occ_status.hpp"
+#include "utils.hpp"
#include <experimental/filesystem>
#include <sdbusplus/bus.hpp>
@@ -34,15 +35,14 @@
* power cap enable properties. If a change is detected, and the occ
* is active, then this object will notify the OCC of the change.
*
- * @param[in] bus - The Dbus bus object
* @param[in] occStatus - The occ status object
*/
- PowerCap(sdbusplus::bus::bus& bus, Status& occStatus,
+ PowerCap(Status& occStatus,
const std::string& occMasterName = OCC_MASTER_NAME) :
- bus(bus),
- occMasterName(occMasterName), occStatus(occStatus),
+ occMasterName(occMasterName),
+ occStatus(occStatus),
pcapMatch(
- bus,
+ utils::getBus(),
sdbusRule::member("PropertiesChanged") +
sdbusRule::path(
"/xyz/openbmc_project/control/host0/power_cap") +
@@ -70,15 +70,6 @@
*/
void pcapChanged(sdbusplus::message::message& msg);
- /** @brief Look up DBUS service for input path/interface
- *
- * @param[in] path - DBUS path
- * @param[in] path - DBUS interface
- *
- * @return Distinct service name for input path/interface
- */
- std::string getService(std::string path, std::string interface);
-
/** @brief Get the power cap property
*
* @return Power cap, 0 on failure to indicate no pcap
@@ -110,9 +101,6 @@
std::string
getPcapFilename(const std::experimental::filesystem::path& path);
- /** @brief Reference to sdbus **/
- sdbusplus::bus::bus& bus;
-
/** @brief The master occ name */
std::string occMasterName;