Return sensor object state data as optional

Previously, the getObject function moved the sensor data passed in as a
constant reference, which should not have been done. The intention of
the getObject function is to retrieve the sensor's object state data.
Then, the necessary sensor data and the created object state data can be
appropriately handled for monitoring.

This change is to remove this confusion and clearly create the sensor's
object state data without modifying the sensor set data passed in to
getObject.

Tested:
    Sensor objects are still created correctly
    Sensor states are monitoring and updated as before

Change-Id: I19fc22fa79094d749e7d5f3b2693094e245b5a4a
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/mainloop.hpp b/mainloop.hpp
index d139593..3fbc059 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -3,6 +3,7 @@
 #include <string>
 #include <vector>
 #include <experimental/any>
+#include <experimental/optional>
 #include <memory>
 #include <sdbusplus/server.hpp>
 #include "hwmonio.hpp"
@@ -16,11 +17,14 @@
 using Object = std::map<InterfaceType, std::experimental::any>;
 using ObjectInfo = std::tuple<sdbusplus::bus::bus*, std::string, Object>;
 using RetryIO = std::tuple<size_t, std::chrono::milliseconds>;
+using ObjectStateData = std::pair<std::string, ObjectInfo>;
 
 static constexpr auto sensorID = 0;
 static constexpr auto sensorLabel = 1;
 using SensorIdentifiers = std::tuple<std::string, std::string>;
 
+namespace optional_ns = std::experimental;
+
 /** @class MainLoop
  *  @brief hwmon-readd main application loop.
  */
@@ -127,6 +131,10 @@
          * @brief Used to create and add sensor objects
          *
          * @param[in] sensor - Sensor to create/add object for
+         *
+         * @return - Optional
+         *     Object state data on success, nothing on failure
          */
-        void getObject(SensorSet::container_t::const_reference sensor);
+        optional_ns::optional<ObjectStateData> getObject(
+                SensorSet::container_t::const_reference sensor);
 };