Get sensor identifiers function
To minimize handling the return cases when getting a sensor object,
retrieve the sensor identifiers from a function. The identifiers
returned are then checked to be valid before proceeding in creating the
sensor object.
Tested:
Sensor objects created the same
Empty id or label cause sensor object to not be created
Change-Id: I7c2f0df3fee99448af5365e0a40c4282f9a235fa
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/mainloop.hpp b/mainloop.hpp
index 9a51580..0453d8e 100644
--- a/mainloop.hpp
+++ b/mainloop.hpp
@@ -16,6 +16,10 @@
using ObjectInfo = std::tuple<sdbusplus::bus::bus*, std::string, Object>;
using RetryIO = std::tuple<size_t, std::chrono::milliseconds>;
+static constexpr auto sensorID = 0;
+static constexpr auto sensorLabel = 1;
+using SensorIdentifiers = std::tuple<std::string, std::string>;
+
/** @class MainLoop
* @brief hwmon-readd main application loop.
*/
@@ -104,6 +108,21 @@
std::map<SensorSet::key_type, SensorSet::mapped_type> rmSensors;
/**
+ * @brief Get the ID of the sensor
+ *
+ * @param[in] sensor - Sensor to get the ID of
+ */
+ std::string getID(SensorSet::container_t::const_reference sensor);
+
+ /**
+ * @brief Get the sensor identifiers
+ *
+ * @param[in] sensor - Sensor to get the identifiers of
+ */
+ SensorIdentifiers getIdentifiers(
+ SensorSet::container_t::const_reference sensor);
+
+ /**
* @brief Used to create and add sensor objects
*
* @param[in] sensor - Sensor to create/add object for