xref: /openbmc/phosphor-hwmon/env.hpp (revision 9331ab7846750a05b90efd845935bfd3275e694c)
1 #pragma once
2 
3 #include <string>
4 
5 #include "sensorset.hpp"
6 
7 /** @brief Reads an environment variable
8  *
9  *  Reads <prefix>_<sensor.first><sensor.second>
10  *
11  *  @param[in] prefix - the variable prefix
12  *  @param[in] sensor - Sensor details
13  *
14  *  @return string - the env var value
15  */
16 std::string getEnv(
17     const char* prefix, const SensorSet::key_type& sensor);
18 
19 /** @brief Reads an environment variable, and takes type and id separately
20  *
21  *  @param[in] prefix - the variable prefix
22  *  @param[in] type - sensor type, like 'temp'
23  *  @param[in] id - sensor ID, like '5'
24  *
25  *  @return string - the env var value
26  */
27 std::string getEnv(
28     const char* prefix,
29     const std::string& type,
30     const std::string& id);
31 
32 /** @brief Gets the ID for the sensor with a level of indirection
33  *
34  *  Read the sensor number/ID from the <path>/<item><X>_label file.
35  *  <item> & <X> are populated from the sensor key.
36  *
37  *  @param[in] path - Directory path of the label file
38  *  @param[in] sensor - Sensor details
39  */
40 std::string getIndirectID(
41     std::string path,
42     const SensorSet::key_type& sensor);
43