env.hpp 876 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
namespace migraph { inline namespace MIGRAPH_INLINE_NS {
Paul's avatar
Paul committed
9
10

// Declare a cached environment variable
Paul's avatar
Paul committed
11
12
13
14
15
16
17
18
#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
19
20
std::vector<std::string> env(const char* name);

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

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

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

#endif