Add object info tuple
The object path, bus connection, and sdbusplus interfaces are
almost always needed together so use a tuple for passing these
around.
Change-Id: I784edae95f03d306633ccf94209faa381b91a596
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index dfda21f..df85f26 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -117,14 +117,15 @@
int val = 0;
read_sysfs(sysfsPath, val);
- Object o;
std::string objectPath{_root};
-
objectPath.append("/");
objectPath.append(i.first.first);
objectPath.append("/");
objectPath.append(label);
+ ObjectInfo info(&_bus, std::move(objectPath), Object());
+ auto& o = std::get<Object>(info);
+
auto iface = std::make_shared<ValueObject>(_bus, objectPath.c_str());
iface->value(val);
@@ -146,7 +147,7 @@
auto value = std::make_tuple(
std::move(i.second),
std::move(label),
- std::move(o));
+ std::move(info));
state[std::move(i.first)] = std::move(value);
}
@@ -177,7 +178,8 @@
hwmon::entry::input),
value);
- auto& obj = std::get<Object>(i.second);
+ auto& objInfo = std::get<ObjectInfo>(i.second);
+ auto& obj = std::get<Object>(objInfo);
auto iface = obj.find(InterfaceType::VALUE);
if (iface != obj.end())
diff --git a/mainloop.hpp b/mainloop.hpp
index cff5123..c5038f7 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -8,6 +8,7 @@
#include "interface.hpp"
using Object = std::map<InterfaceType, std::experimental::any>;
+using ObjectInfo = std::tuple<sdbusplus::bus::bus*, std::string, Object>;
/** @class MainLoop
* @brief hwmon-readd main application loop.
@@ -51,7 +52,7 @@
void shutdown() noexcept;
private:
- using mapped_type = std::tuple<SensorSet::mapped_type, std::string, Object>;
+ using mapped_type = std::tuple<SensorSet::mapped_type, std::string, ObjectInfo>;
using SensorState = std::map<SensorSet::key_type, mapped_type>;
/** @brief sdbusplus bus client connection. */