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/occ_status.hpp b/occ_status.hpp
index abdc3ed..df2ef51 100644
--- a/occ_status.hpp
+++ b/occ_status.hpp
@@ -4,6 +4,7 @@
#include "occ_command.hpp"
#include "occ_device.hpp"
#include "occ_events.hpp"
+#include "utils.hpp"
#include <functional>
#include <org/open_power/Control/Host/server.hpp>
@@ -57,7 +58,6 @@
/** @brief Constructs the Status object and
* the underlying device object
*
- * @param[in] bus - DBus bus to attach to
* @param[in] event - sd_event unique pointer reference
* @param[in] path - DBus object path
* @param[in] manager - OCC manager instance
@@ -67,16 +67,16 @@
* OCC if PLDM is the host communication
* protocol
*/
- Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path,
- const Manager& manager, std::function<void(bool)> callBack = nullptr
+ Status(EventPtr& event, const char* path, const Manager& manager,
+ std::function<void(bool)> callBack = nullptr
#ifdef PLDM
,
std::function<void(instanceID)> resetCallBack = nullptr
#endif
) :
- Interface(bus, getDbusPath(path).c_str(), true),
- bus(bus), path(path), callBack(callBack), instance(getInstance(path)),
+ Interface(utils::getBus(), getDbusPath(path).c_str(), true),
+ path(path), callBack(callBack), instance(getInstance(path)),
device(event,
#ifdef I2C_OCC
fs::path(DEV_PATH) / i2c_occ::getI2cDeviceName(path),
@@ -88,7 +88,7 @@
std::bind(std::mem_fn(&Status::deviceErrorHandler), this,
std::placeholders::_1)),
hostControlSignal(
- bus,
+ utils::getBus(),
sdbusRule::type::signal() + sdbusRule::member("CommandComplete") +
sdbusRule::path("/org/open_power/control/host0") +
sdbusRule::interface("org.open_power.Control.Host") +
@@ -96,10 +96,9 @@
Control::Host::Command::OCCReset)),
std::bind(std::mem_fn(&Status::hostControlEvent), this,
std::placeholders::_1)),
- occCmd(instance, bus,
- (fs::path(OCC_CONTROL_ROOT) /
- (std::string(OCC_NAME) + std::to_string(instance)))
- .c_str())
+ occCmd(instance, (fs::path(OCC_CONTROL_ROOT) /
+ (std::string(OCC_NAME) + std::to_string(instance)))
+ .c_str())
#ifdef PLDM
,
resetCallBack(resetCallBack)
@@ -151,9 +150,6 @@
void readOccState();
private:
- /** @brief sdbus handle */
- sdbusplus::bus::bus& bus;
-
/** @brief OCC dbus object path */
std::string path;