Loading...
Searching...
No Matches
ConfigManager.h
Go to the documentation of this file.
1#ifndef CONFIGMANAGER_H
2#define CONFIGMANAGER_H
3
4#include <type_traits>
5#include <string>
6
7namespace ml
8{
10
12 template<typename T, typename = void>
13 struct has_Strings : std::false_type {};
14 template<typename T>
15 struct has_Strings<T, std::void_t<typename T::Text>> : std::true_type {};
16
18 template<typename T, typename = void>
19 struct has_Ints : std::false_type {};
20 template<typename T>
21 struct has_Ints<T, std::void_t<typename T::Ints>> : std::true_type {};
22
24 template<typename T, typename = void>
25 struct has_Floats : std::false_type {};
26 template<typename T>
27 struct has_Floats<T, std::void_t<typename T::Floats>> : std::true_type {};
28
30 template<typename T, typename = void>
31 struct has_Booleans : std::false_type {};
32 template<typename T>
33 struct has_Booleans<T, std::void_t<typename T::Floats>> : std::true_type {}; // BUG: should be T::Booleans
34
36
87 template<typename Manifest>
89 {
90 public:
97 static void ensureInitialized();
98
107 template<typename M = Manifest>
108 static std::enable_if_t<has_Strings<M>::value, const std::string&>
109 get(typename M::Text config);
110
119 template<typename M = Manifest>
120 static std::enable_if_t<has_Ints<M>::value, int>
121 get(typename M::Integers config);
122
131 template<typename M = Manifest>
132 static std::enable_if_t<has_Floats<M>::value, float>
133 get(typename M::Floats config);
134
143 template<typename M = Manifest>
144 static std::enable_if_t<has_Booleans<M>::value, bool>
145 get(typename M::Booleans config);
146 };
147
148} // namespace ml
149
150#include "../../../src/Resources/ConfigManager.tpp"
151#endif // CONFIGMANAGER_H
Manifest-driven accessor for typed configuration values.
static std::enable_if_t< has_Floats< M >::value, float > get(typename M::Floats config)
Retrieve a float config value.
static std::enable_if_t< has_Ints< M >::value, int > get(typename M::Integers config)
Retrieve an integer config value.
static void ensureInitialized()
Ensure the manifest's config values have been registered.
static std::enable_if_t< has_Booleans< M >::value, bool > get(typename M::Booleans config)
Retrieve a boolean config value.
static std::enable_if_t< has_Strings< M >::value, const std::string & > get(typename M::Text config)
Retrieve a string config value.
Definition Component.h:18