Add a level of indirection when naming the DBUS objects
The current design ignores the itemX_label sysfs attribute, if the
environment variable is populated with the MODE_itemX="label", then
fetch the label from itemX_label file.The actual label for the dbus
object is fetched from the environment variable LABEL_item<label>.
Resolves openbmc/openbmc#1633
Change-Id: I0d4baaa91073dd5db75ac62277d78ad9b3065e64
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/env.hpp b/env.hpp
index 20db257..6442468 100644
--- a/env.hpp
+++ b/env.hpp
@@ -4,3 +4,19 @@
std::string getEnv(
const char* prefix, const SensorSet::key_type& sensor);
+
+/** @brief Get the label for the sensor with a level of indirection.
+ *
+ * Read the sensor number from the <path>/<item><X>_label file.<item> & <X> is
+ * populated from the sensor key. The sensor label is read from the environment
+ * variable <prefix>_<item><sensorNum>.
+ *
+ * @param[in] prefix - Prefix of the environment variable.
+ * @param[in] path - Directory path of the label file.
+ * @param[in] sensor - Sensor details.
+ *
+ * @return On success return the sensor label, in case of failure return empty
+ * string.
+ */
+std::string getIndirectLabelEnv(
+ const char* prefix, std::string path, const SensorSet::key_type& sensor);