xref: /openbmc/phosphor-hwmon/env.hpp (revision a24c8808d5c3b13b849e79115a6969b5a8faf8b0)
1f3df6b4fSBrad Bishop #pragma once
2f3df6b4fSBrad Bishop 
39331ab78SPatrick Venture #include <string>
49331ab78SPatrick Venture 
59331ab78SPatrick Venture #include "sensorset.hpp"
6f3df6b4fSBrad Bishop 
77a5285deSPatrick Venture namespace env {
87a5285deSPatrick Venture 
9049e0dd2SMatt Spinler /** @brief Reads an environment variable
10049e0dd2SMatt Spinler  *
11*a24c8808SPatrick Venture  *  Reads the environment for that key
12*a24c8808SPatrick Venture  *
13*a24c8808SPatrick Venture  *  @param[in] key - the key
14*a24c8808SPatrick Venture  *
15*a24c8808SPatrick Venture  *  @return string - the env var value
16*a24c8808SPatrick Venture  */
17*a24c8808SPatrick Venture std::string getEnv(const char* key);
18*a24c8808SPatrick Venture 
19*a24c8808SPatrick Venture /** @brief Reads an environment variable
20*a24c8808SPatrick Venture  *
21049e0dd2SMatt Spinler  *  Reads <prefix>_<sensor.first><sensor.second>
22049e0dd2SMatt Spinler  *
23049e0dd2SMatt Spinler  *  @param[in] prefix - the variable prefix
24049e0dd2SMatt Spinler  *  @param[in] sensor - Sensor details
25049e0dd2SMatt Spinler  *
26049e0dd2SMatt Spinler  *  @return string - the env var value
27049e0dd2SMatt Spinler  */
28f3df6b4fSBrad Bishop std::string getEnv(
29f3df6b4fSBrad Bishop     const char* prefix, const SensorSet::key_type& sensor);
301f8a9586STom Joseph 
31049e0dd2SMatt Spinler /** @brief Reads an environment variable, and takes type and id separately
32049e0dd2SMatt Spinler  *
33049e0dd2SMatt Spinler  *  @param[in] prefix - the variable prefix
34049e0dd2SMatt Spinler  *  @param[in] type - sensor type, like 'temp'
35049e0dd2SMatt Spinler  *  @param[in] id - sensor ID, like '5'
36049e0dd2SMatt Spinler  *
37049e0dd2SMatt Spinler  *  @return string - the env var value
38049e0dd2SMatt Spinler  */
39049e0dd2SMatt Spinler std::string getEnv(
40049e0dd2SMatt Spinler     const char* prefix,
41049e0dd2SMatt Spinler     const std::string& type,
42049e0dd2SMatt Spinler     const std::string& id);
43049e0dd2SMatt Spinler 
4482d507d0SMatt Spinler /** @brief Gets the ID for the sensor with a level of indirection
4582d507d0SMatt Spinler  *
4682d507d0SMatt Spinler  *  Read the sensor number/ID from the <path>/<item><X>_label file.
4782d507d0SMatt Spinler  *  <item> & <X> are populated from the sensor key.
4882d507d0SMatt Spinler  *
4982d507d0SMatt Spinler  *  @param[in] path - Directory path of the label file
5082d507d0SMatt Spinler  *  @param[in] sensor - Sensor details
5182d507d0SMatt Spinler  */
5282d507d0SMatt Spinler std::string getIndirectID(
5382d507d0SMatt Spinler     std::string path,
5482d507d0SMatt Spinler     const SensorSet::key_type& sensor);
557a5285deSPatrick Venture 
567a5285deSPatrick Venture }  // namespace env
57