xref: /openbmc/phosphor-hwmon/env.hpp (revision c635e860)
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 sensor number/ID from the <path>/<item><X>_label file.
47  *  <item> & <X> are populated from the sensor key.
48  *
49  *  @param[in] path - Directory path of the label file
50  *  @param[in] sensor - Sensor details
51  */
52 std::string getIndirectID(
53     std::string path,
54     const SensorSet::key_type& sensor);
55 
56 }  // namespace env
57