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