10 #if !defined(NX_KIT_API) 75 static bool isEnabled();
77 static void setEnabled(
bool value);
85 static void setOutput(std::ostream* output);
88 static const char* iniFilesDir();
97 static void setIniFilesDir(
const char* iniFilesDir);
109 const char* iniFile()
const;
110 const char* iniFilePath()
const;
118 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 119 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 121 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 122 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 124 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 125 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 127 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 128 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 130 #define NX_INI_DOUBLE(DEFAULT, PARAM, DESCRIPTION) \ 131 const double PARAM = regDoubleParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 134 bool regBoolParam(
const bool* pValue,
bool defaultValue,
135 const char* paramName,
const char* description);
137 int regIntParam(
const int* pValue,
int defaultValue,
138 const char* paramName,
const char* description);
140 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
141 const char* paramName,
const char* description);
143 float regFloatParam(
const float* pValue,
float defaultValue,
144 const char* paramName,
const char* description);
146 double regDoubleParam(
const double* pValue,
double defaultValue,
147 const char* paramName,
const char* description);
174 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
176 if (++s_tweaksInstanceCount == 1)
178 s_originalValueOfIsEnabled = isEnabled();
185 for (
const auto& guard: *m_guards)
189 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
191 if (--s_tweaksInstanceCount == 0)
192 setEnabled(s_originalValueOfIsEnabled);
198 Tweaks(
const Tweaks&) =
delete;
199 Tweaks(Tweaks&&) =
delete;
200 Tweaks& operator=(
const Tweaks&) =
delete;
201 Tweaks& operator=(Tweaks&&) =
delete;
204 void set(
const T* field, T newValue)
206 const auto oldValue = *field;
207 T*
const mutableField =
const_cast<T*
>(field);
208 m_guards->push_back([=]() { *mutableField = oldValue; });
209 *mutableField = newValue;
215 std::mutex*
const mutex =
new std::mutex();
216 ~MutexHolder() {
delete mutex; }
219 static MutexHolder s_mutexHolder;
220 static int s_tweaksInstanceCount;
221 static bool s_originalValueOfIsEnabled;
223 std::vector<std::function<void()>>*
const m_guards =
224 new std::vector<std::function<void()>>();
Definition: ini_config.h:67
Definition: apple_utils.h:6
Definition: ini_config.cpp:341