Make the dbushelper own its own bus handle.
The dbushelper implements an interface that should not be sdbusplus
specific. By making the implementation own the sdbusplus aspects, an
alternate implementation can be swapped in.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I4109772499421e2e6497a0fcad663ebbd1210a7c
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 27255e7..84d1f93 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -34,7 +34,7 @@
std::unique_ptr<ReadInterface> DbusPassive::createDbusPassive(
sdbusplus::bus::bus& bus, const std::string& type, const std::string& id,
- DbusHelperInterface* helper, const conf::SensorConfig* info,
+ std::unique_ptr<DbusHelperInterface> helper, const conf::SensorConfig* info,
const std::shared_ptr<DbusPassiveRedundancy>& redundancy)
{
if (helper == nullptr)
@@ -74,18 +74,19 @@
settings.max = 0;
}
- return std::make_unique<DbusPassive>(bus, type, id, helper, settings,
- failed, path, redundancy);
+ return std::make_unique<DbusPassive>(bus, type, id, std::move(helper),
+ settings, failed, path, redundancy);
}
DbusPassive::DbusPassive(
sdbusplus::bus::bus& bus, const std::string& type, const std::string& id,
- DbusHelperInterface* helper, const struct SensorProperties& settings,
- bool failed, const std::string& path,
+ std::unique_ptr<DbusHelperInterface> helper,
+ const struct SensorProperties& settings, bool failed,
+ const std::string& path,
const std::shared_ptr<DbusPassiveRedundancy>& redundancy) :
ReadInterface(),
_bus(bus), _signal(bus, getMatch(type, id).c_str(), dbusHandleSignal, this),
- _id(id), _helper(helper), _failed(failed), path(path),
+ _id(id), _helper(std::move(helper)), _failed(failed), path(path),
redundancy(redundancy)
{