Loading...
Searching...
No Matches
ConfigManager.h
Go to the documentation of this file.
1// Copyright (c) 2025 Dave R. Smith. All rights reserved.
2// Malena Framework — Proprietary Software. See LICENSE for terms.
3
4#ifndef MALENA_CONFIGMANAGER_H
5#define MALENA_CONFIGMANAGER_H
6
8#include <type_traits>
9#include <string>
10
11namespace ml
12{
14
16 template<typename T, typename = void>
17 struct has_Strings : std::false_type {};
18 template<typename T>
19 struct has_Strings<T, std::void_t<typename T::Text>> : std::true_type {};
20
22 template<typename T, typename = void>
23 struct has_Ints : std::false_type {};
24 template<typename T>
25 struct has_Ints<T, std::void_t<typename T::Ints>> : std::true_type {};
26
28 template<typename T, typename = void>
29 struct has_Floats : std::false_type {};
30 template<typename T>
31 struct has_Floats<T, std::void_t<typename T::Floats>> : std::true_type {};
32
34 template<typename T, typename = void>
35 struct has_Booleans : std::false_type {};
36 template<typename T>
37 struct has_Booleans<T, std::void_t<typename T::Floats>> : std::true_type {}; // BUG: should be T::Booleans
38
40
91 template<typename Manifest>
93 {
94 public:
101 static void ensureInitialized();
102
111 template<typename M = Manifest>
112 static std::enable_if_t<has_Strings<M>::value, const std::string&>
113 get(typename M::Text config);
114
123 template<typename M = Manifest>
124 static std::enable_if_t<has_Ints<M>::value, int>
125 get(typename M::Integers config);
126
135 template<typename M = Manifest>
136 static std::enable_if_t<has_Floats<M>::value, float>
137 get(typename M::Floats config);
138
147 template<typename M = Manifest>
148 static std::enable_if_t<has_Booleans<M>::value, bool>
149 get(typename M::Booleans config);
150 };
151
152} // namespace ml
153
154#include "../../../src/Resources/ConfigManager.tpp"
155#endif // MALENA_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:22