10 #if !defined(NX_KIT_API) 85 static bool isEnabled();
87 static void setEnabled(
bool value);
95 static void setOutput(std::ostream* output);
98 static const char* iniFilesDir();
107 static void setIniFilesDir(
const char* iniFilesDir);
119 const char* iniFile()
const;
120 const char* iniFilePath()
const;
145 bool getParamTypeAndValue(
146 const char* paramName, ParamType* outType,
const void** outData)
const;
149 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 150 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 152 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 153 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 155 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 156 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 158 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 159 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 162 bool regBoolParam(
const bool* pValue,
bool defaultValue,
163 const char* paramName,
const char* description);
165 int regIntParam(
const int* pValue,
int defaultValue,
166 const char* paramName,
const char* description);
168 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
169 const char* paramName,
const char* description);
171 float regFloatParam(
const float* pValue,
float defaultValue,
172 const char* paramName,
const char* description);
194 class NX_KIT_API IniConfig::Tweaks
199 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
201 if (++s_tweaksInstanceCount == 1)
203 s_originalValueOfIsEnabled = isEnabled();
210 for (
const auto& guard: *m_guards)
214 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
216 if (--s_tweaksInstanceCount == 0)
217 setEnabled(s_originalValueOfIsEnabled);
223 Tweaks(
const Tweaks&) =
delete;
224 Tweaks(Tweaks&&) =
delete;
225 Tweaks& operator=(
const Tweaks&) =
delete;
226 Tweaks& operator=(Tweaks&&) =
delete;
229 void set(
const T* field, T newValue)
231 const auto oldValue = *field;
232 T*
const mutableField =
const_cast<T*
>(field);
233 m_guards->push_back([=]() { *mutableField = oldValue; });
234 *mutableField = newValue;
240 std::mutex*
const mutex =
new std::mutex();
241 ~MutexHolder() {
delete mutex; }
244 static MutexHolder s_mutexHolder;
245 static int s_tweaksInstanceCount;
246 static bool s_originalValueOfIsEnabled;
248 std::vector<std::function<void()>>*
const m_guards =
249 new std::vector<std::function<void()>>();
Definition: ini_config.h:77
ParamType
Definition: ini_config.h:133
Definition: apple_utils.h:6