Add another version of getEnv
The new version takes the type and ID parameters
separately as opposed to together in a key_type.
Change-Id: I7796e8e6d680ffb640028e91eb3dcc8e7d99bc2e
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/env.cpp b/env.cpp
index 5745e16..efd081b 100644
--- a/env.cpp
+++ b/env.cpp
@@ -39,6 +39,15 @@
return value;
}
+std::string getEnv(
+ const char* prefix,
+ const std::string& type,
+ const std::string& id)
+{
+ SensorSet::key_type sensor{type, id};
+ return getEnv(prefix, sensor);
+}
+
std::string getIndirectLabelEnv(
const char* prefix, std::string path, const SensorSet::key_type& sensor)
{
diff --git a/env.hpp b/env.hpp
index 6442468..6342e25 100644
--- a/env.hpp
+++ b/env.hpp
@@ -2,9 +2,31 @@
class SensorSet;
+/** @brief Reads an environment variable
+ *
+ * Reads <prefix>_<sensor.first><sensor.second>
+ *
+ * @param[in] prefix - the variable prefix
+ * @param[in] sensor - Sensor details
+ *
+ * @return string - the env var value
+ */
std::string getEnv(
const char* prefix, const SensorSet::key_type& sensor);
+/** @brief Reads an environment variable, and takes type and id separately
+ *
+ * @param[in] prefix - the variable prefix
+ * @param[in] type - sensor type, like 'temp'
+ * @param[in] id - sensor ID, like '5'
+ *
+ * @return string - the env var value
+ */
+std::string getEnv(
+ const char* prefix,
+ const std::string& type,
+ const std::string& id);
+
/** @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