Move status iface creation into sensor object

For sensors that have a status interface created with a functional
property set according to its fault sysfs file value, the object
associated with the sensor should contain the creation of this
interface.

Tested:
    No change in status interface creation for sensors

Change-Id: Ic3c0a81c661ac481b90ad9bd4c8bf415dae3520e
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index c7ede15..be9b680 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -288,7 +288,9 @@
         return {};
     }
 
-    auto sensorObj = std::make_unique<sensor::Sensor>(sensor.first);
+    auto sensorObj = std::make_unique<sensor::Sensor>(sensor.first,
+                                                      ioAccess,
+                                                      _devPath);
 
     // Get list of return codes for removing sensors on device
     auto devRmRCs = env::getEnv("REMOVERCS");
@@ -314,7 +316,7 @@
     try
     {
         // Add status interface based on _fault file being present
-        sensor::addStatus(sensor.first, ioAccess, _devPath, info);
+        sensorObj->addStatus(info);
         valueInterface = addValue(sensor.first, retryIO, ioAccess, info);
     }
     catch (const std::system_error& e)
diff --git a/sensor.cpp b/sensor.cpp
index 5fb1f38..3a1ed73 100644
--- a/sensor.cpp
+++ b/sensor.cpp
@@ -11,16 +11,16 @@
 namespace sensor
 {
 
-Sensor::Sensor(const SensorSet::key_type& sensor) :
-    sensor(sensor)
+Sensor::Sensor(const SensorSet::key_type& sensor,
+               const hwmonio::HwmonIO& ioAccess,
+               const std::string& devPath) :
+    sensor(sensor),
+    ioAccess(ioAccess),
+    devPath(devPath)
 {
 }
 
-std::shared_ptr<StatusObject> addStatus(
-        const SensorSet::key_type& sensor,
-        const hwmonio::HwmonIO& ioAccess,
-        const std::string& devPath,
-        ObjectInfo& info)
+std::shared_ptr<StatusObject> Sensor::addStatus(ObjectInfo& info)
 {
     namespace fs = std::experimental::filesystem;
 
diff --git a/sensor.hpp b/sensor.hpp
index 4d3dc3c..978467b 100644
--- a/sensor.hpp
+++ b/sensor.hpp
@@ -27,31 +27,36 @@
          * @brief Constructs Sensor object
          *
          * @param[in] sensor - A pair of sensor indentifiers
+         * @param[in] ioAccess - Hwmon sysfs access
+         * @param[in] devPath - Device sysfs path
          */
-        explicit Sensor(const SensorSet::key_type& sensor);
+        explicit Sensor(const SensorSet::key_type& sensor,
+                        const hwmonio::HwmonIO& ioAccess,
+                        const std::string& devPath);
+
+        /**
+         * @brief Add status interface and functional property for sensor
+         * @details When a sensor has an associated fault file, the
+         * OperationalStatus interface is added along with setting the
+         * Functional property to the corresponding value found in the
+         * fault file.
+         *
+         * @param[in] info - Sensor object information
+         *
+         * @return - Shared pointer to the status object
+         */
+        std::shared_ptr<StatusObject> addStatus(
+                ObjectInfo& info);
 
     private:
         /** @brief Sensor object's identifiers */
         SensorSet::key_type sensor;
-};
 
-/**
- * @brief Add status interface and functional property for sensor
- * @details When a sensor has an associated fault file, the OperationalStatus
- * interface is added along with setting the Functional property to the
- * corresponding value found in the fault file.
- *
- * @param[in] sensor - Sensor identification data
- * @param[in] ioAccess - I/O access to sysfs
- * @param[in] devPath - Device path
- * @param[in] info - Sensor object information
- *
- * @return - Shared pointer to the status object
- */
-std::shared_ptr<StatusObject> addStatus(
-        const SensorSet::key_type& sensor,
-        const hwmonio::HwmonIO& ioAccess,
-        const std::string& devPath,
-        ObjectInfo& info);
+        /** @brief Hwmon sysfs access. */
+        const hwmonio::HwmonIO& ioAccess;
+
+        /** @brief Physical device sysfs path. */
+        const std::string& devPath;
+};
 
 } // namespace sensor