xref: /openbmc/phosphor-hwmon/env.hpp (revision 7a5285de708b2f46d47f37920c784314b4ad55aa)
1f3df6b4fSBrad Bishop #pragma once
2f3df6b4fSBrad Bishop 
39331ab78SPatrick Venture #include <string>
49331ab78SPatrick Venture 
59331ab78SPatrick Venture #include "sensorset.hpp"
6f3df6b4fSBrad Bishop 
7*7a5285deSPatrick Venture namespace env {
8*7a5285deSPatrick Venture 
9049e0dd2SMatt Spinler /** @brief Reads an environment variable
10049e0dd2SMatt Spinler  *
11049e0dd2SMatt Spinler  *  Reads <prefix>_<sensor.first><sensor.second>
12049e0dd2SMatt Spinler  *
13049e0dd2SMatt Spinler  *  @param[in] prefix - the variable prefix
14049e0dd2SMatt Spinler  *  @param[in] sensor - Sensor details
15049e0dd2SMatt Spinler  *
16049e0dd2SMatt Spinler  *  @return string - the env var value
17049e0dd2SMatt Spinler  */
18f3df6b4fSBrad Bishop std::string getEnv(
19f3df6b4fSBrad Bishop     const char* prefix, const SensorSet::key_type& sensor);
201f8a9586STom Joseph 
21049e0dd2SMatt Spinler /** @brief Reads an environment variable, and takes type and id separately
22049e0dd2SMatt Spinler  *
23049e0dd2SMatt Spinler  *  @param[in] prefix - the variable prefix
24049e0dd2SMatt Spinler  *  @param[in] type - sensor type, like 'temp'
25049e0dd2SMatt Spinler  *  @param[in] id - sensor ID, like '5'
26049e0dd2SMatt Spinler  *
27049e0dd2SMatt Spinler  *  @return string - the env var value
28049e0dd2SMatt Spinler  */
29049e0dd2SMatt Spinler std::string getEnv(
30049e0dd2SMatt Spinler     const char* prefix,
31049e0dd2SMatt Spinler     const std::string& type,
32049e0dd2SMatt Spinler     const std::string& id);
33049e0dd2SMatt Spinler 
3482d507d0SMatt Spinler /** @brief Gets the ID for the sensor with a level of indirection
3582d507d0SMatt Spinler  *
3682d507d0SMatt Spinler  *  Read the sensor number/ID from the <path>/<item><X>_label file.
3782d507d0SMatt Spinler  *  <item> & <X> are populated from the sensor key.
3882d507d0SMatt Spinler  *
3982d507d0SMatt Spinler  *  @param[in] path - Directory path of the label file
4082d507d0SMatt Spinler  *  @param[in] sensor - Sensor details
4182d507d0SMatt Spinler  */
4282d507d0SMatt Spinler std::string getIndirectID(
4382d507d0SMatt Spinler     std::string path,
4482d507d0SMatt Spinler     const SensorSet::key_type& sensor);
45*7a5285deSPatrick Venture 
46*7a5285deSPatrick Venture }  // namespace env
47