mainloop: Make HwmonIO injectable dependency

HwmonIO was make into a interface object implementation.  This patch
transitions mainloop to receive a pointer to this interface to allow for
injection testing.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Iaa470fafccb42c4d7fbabac0dc92f96c8075faf2
diff --git a/targets.hpp b/targets.hpp
index a954394..ffdb476 100644
--- a/targets.hpp
+++ b/targets.hpp
@@ -64,7 +64,7 @@
  */
 template <typename T>
 std::shared_ptr<T> addTarget(const SensorSet::key_type& sensor,
-                             const hwmonio::HwmonIO& ioAccess,
+                             const hwmonio::HwmonIOInterface* ioAccess,
                              const std::string& devPath, ObjectInfo& info)
 {
     std::shared_ptr<T> target;
@@ -97,7 +97,7 @@
     }
 
     sysfsFullPath =
-        sysfs::make_sysfs_path(ioAccess.path(), targetName, targetId, entry);
+        sysfs::make_sysfs_path(ioAccess->path(), targetName, targetId, entry);
     if (fs::exists(sysfsFullPath))
     {
         auto useTarget = true;
@@ -137,8 +137,8 @@
 
             try
             {
-                targetSpeed = ioAccess.read(targetName, targetId, entry,
-                                            hwmonio::retries, hwmonio::delay);
+                targetSpeed = ioAccess->read(targetName, targetId, entry,
+                                             hwmonio::retries, hwmonio::delay);
             }
             catch (const std::system_error& e)
             {
@@ -160,9 +160,11 @@
             static constexpr bool deferSignals = true;
             auto& bus = *std::get<sdbusplus::bus::bus*>(info);
 
-            // ioAccess.path() is a path like: /sys/class/hwmon/hwmon1
+            // ioAccess->path() is a path like: /sys/class/hwmon/hwmon1
+            // NOTE: When unit-testing, the target won't have an inject-ible
+            // ioAccess: fan_pwm/fan_speed.
             target = std::make_shared<T>(
-                std::move(std::make_unique<hwmonio::HwmonIO>(ioAccess.path())),
+                std::move(std::make_unique<hwmonio::HwmonIO>(ioAccess->path())),
                 devPath, targetId, bus, objPath.c_str(), deferSignals,
                 targetSpeed);
             obj[type] = target;