summaryrefslogtreecommitdiffstats
path: root/env.hpp
blob: 56dd2aa71f3ec7cfe0b6d690540c79c1fc06c937 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once

#include <string>

#include "sensorset.hpp"

namespace env {

/** @brief Reads an environment variable
 *
 *  Reads the environment for that key
 *
 *  @param[in] key - the key
 *
 *  @return string - the env var value
 */
std::string getEnv(const char* key);

/** @brief Reads an environment variable
 *
 *  Reads <prefix>_<sensor.first><sensor.second>
 *
 *  @param[in] prefix - the variable prefix
 *  @param[in] sensor - Sensor details
 *
 *  @return string - the env var value
 */
std::string getEnv(
    const char* prefix, const SensorSet::key_type& sensor);

/** @brief Reads an environment variable, and takes type and id separately
 *
 *  @param[in] prefix - the variable prefix
 *  @param[in] type - sensor type, like 'temp'
 *  @param[in] id - sensor ID, like '5'
 *
 *  @return string - the env var value
 */
std::string getEnv(
    const char* prefix,
    const std::string& type,
    const std::string& id);

/** @brief Gets the ID for the sensor with a level of indirection
 *
 *  Read the ID from the <path>/<item><X>_<suffix> file.
 *  <item> & <X> are populated from the sensor key.
 *
 *  @param[in] path - Directory path of the label file
 *  @param[in] fileSuffix - The file suffix
 *  @param[in] sensor - Sensor details
 */
std::string getIndirectID(
    std::string path,
    const std::string& fileSuffix,
    const SensorSet::key_type& sensor);

}  // namespace env
OpenPOWER on IntegriCloud