10 #if !defined(NX_KIT_API) 84 static bool isEnabled();
86 static void setEnabled(
bool value);
94 static void setOutput(std::ostream* output);
97 static const char* iniFilesDir();
106 static void setIniFilesDir(
const char* iniFilesDir);
118 const char* iniFile()
const;
119 const char* iniFilePath()
const;
127 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 128 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 130 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 131 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 133 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 134 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 136 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 137 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 139 #define NX_INI_DOUBLE(DEFAULT, PARAM, DESCRIPTION) \ 140 const double PARAM = regDoubleParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 143 bool regBoolParam(
const bool* pValue,
bool defaultValue,
144 const char* paramName,
const char* description);
146 int regIntParam(
const int* pValue,
int defaultValue,
147 const char* paramName,
const char* description);
149 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
150 const char* paramName,
const char* description);
152 float regFloatParam(
const float* pValue,
float defaultValue,
153 const char* paramName,
const char* description);
155 double regDoubleParam(
const double* pValue,
double defaultValue,
156 const char* paramName,
const char* description);
183 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
185 if (++s_tweaksInstanceCount == 1)
187 s_originalValueOfIsEnabled = isEnabled();
194 for (
const auto& guard: *m_guards)
198 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
200 if (--s_tweaksInstanceCount == 0)
201 setEnabled(s_originalValueOfIsEnabled);
207 Tweaks(
const Tweaks&) =
delete;
208 Tweaks(Tweaks&&) =
delete;
209 Tweaks& operator=(
const Tweaks&) =
delete;
210 Tweaks& operator=(Tweaks&&) =
delete;
213 void set(
const T* field, T newValue)
215 const auto oldValue = *field;
216 T*
const mutableField =
const_cast<T*
>(field);
217 m_guards->push_back([=]() { *mutableField = oldValue; });
218 *mutableField = newValue;
224 std::mutex*
const mutex =
new std::mutex();
225 ~MutexHolder() {
delete mutex; }
228 static MutexHolder s_mutexHolder;
229 static int s_tweaksInstanceCount;
230 static bool s_originalValueOfIsEnabled;
232 std::vector<std::function<void()>>*
const m_guards =
233 new std::vector<std::function<void()>>();
Definition: ini_config.h:76
Definition: apple_utils.h:6
Definition: ini_config.cpp:326