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