env.hpp 869 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
#ifndef MIGRAPH_GUARD_RTGLIB_ENV_HPP
#define MIGRAPH_GUARD_RTGLIB_ENV_HPP

#include <vector>
#include <string>
6
#include <migraph/config.hpp>
Paul's avatar
Paul committed
7

8
9
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
Paul's avatar
Paul committed
10
11

// Declare a cached environment variable
Paul's avatar
Paul committed
12
13
14
15
16
17
18
19
#define MIGRAPH_DECLARE_ENV_VAR(x)                \
    struct x                                      \
    {                                             \
        static const char* value() { return #x; } \
    }; // NOLINT

bool enabled(const char* name);
bool disabled(const char* name);
Paul's avatar
Paul committed
20
21
std::vector<std::string> env(const char* name);

Paul's avatar
Paul committed
22
template <class T>
Paul's avatar
Paul committed
23
24
25
26
27
28
bool enabled(T)
{
    static const bool result = enabled(T::value());
    return result;
}

Paul's avatar
Paul committed
29
template <class T>
Paul's avatar
Paul committed
30
31
32
33
34
35
bool disabled(T)
{
    static const bool result = disabled(T::value());
    return result;
}

36
} // namespace MIGRAPH_INLINE_NS
Paul's avatar
Paul committed
37
38
39
} // namespace migraph

#endif