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/pldm.hpp b/pldm.hpp
index 48f80c7..7a93066 100644
--- a/pldm.hpp
+++ b/pldm.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "occ_status.hpp"
+#include "utils.hpp"
#include <libpldm/pldm.h>
@@ -48,17 +49,14 @@
/** @brief Constructs the PLDM Interface object for OCC functions
*
- * @param[in] bus - reference to systemd bus
* @param[in] callBack - callBack handler to invoke when the OCC state
* changes.
*/
explicit Interface(
- sdbusplus::bus::bus& bus,
std::function<bool(open_power::occ::instanceID, bool)> callBack) :
- bus(bus),
callBack(callBack),
pldmEventSignal(
- bus,
+ utils::getBus(),
MatchRules::type::signal() +
MatchRules::member("StateSensorEvent") +
MatchRules::path("/xyz/openbmc_project/pldm") +
@@ -66,7 +64,7 @@
std::bind(std::mem_fn(&Interface::sensorEvent), this,
std::placeholders::_1)),
hostStateSignal(
- bus,
+ utils::getBus(),
MatchRules::propertiesChanged("/xyz/openbmc_project/state/host0",
"xyz.openbmc_project.State.Host"),
std::bind(std::mem_fn(&Interface::hostStateEvent), this,
@@ -122,9 +120,6 @@
void resetOCC(open_power::occ::instanceID occInstanceId);
private:
- /** @brief reference to the systemd bus*/
- sdbusplus::bus::bus& bus;
-
/** @brief Callback handler to be invoked when the state of the OCC
* changes
*/