10 #if !defined(NX_KIT_API) 86 static bool isEnabled();
88 static void setEnabled(
bool value);
96 static void setOutput(std::ostream* output);
99 static const char* iniFilesDir();
108 static void setIniFilesDir(
const char* iniFilesDir);
120 const char* iniFile()
const;
121 const char* iniFilePath()
const;
129 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 130 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 132 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 133 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 135 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 136 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 138 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 139 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 141 #define NX_INI_DOUBLE(DEFAULT, PARAM, DESCRIPTION) \ 142 const double PARAM = regDoubleParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 145 bool regBoolParam(
const bool* pValue,
bool defaultValue,
146 const char* paramName,
const char* description);
148 int regIntParam(
const int* pValue,
int defaultValue,
149 const char* paramName,
const char* description);
151 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
152 const char* paramName,
const char* description);
154 float regFloatParam(
const float* pValue,
float defaultValue,
155 const char* paramName,
const char* description);
157 double regDoubleParam(
const double* pValue,
double defaultValue,
158 const char* paramName,
const char* description);
185 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
187 if (++s_tweaksInstanceCount == 1)
189 s_originalValueOfIsEnabled = isEnabled();
196 for (
const auto& guard: *m_guards)
200 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
202 if (--s_tweaksInstanceCount == 0)
203 setEnabled(s_originalValueOfIsEnabled);
209 Tweaks(
const Tweaks&) =
delete;
210 Tweaks(Tweaks&&) =
delete;
211 Tweaks& operator=(
const Tweaks&) =
delete;
212 Tweaks& operator=(Tweaks&&) =
delete;
215 void set(
const T* field, T newValue)
217 const auto oldValue = *field;
218 T*
const mutableField =
const_cast<T*
>(field);
219 m_guards->push_back([=]() { *mutableField = oldValue; });
220 *mutableField = newValue;
226 std::mutex*
const mutex =
new std::mutex();
227 ~MutexHolder() {
delete mutex; }
230 static MutexHolder s_mutexHolder;
231 static int s_tweaksInstanceCount;
232 static bool s_originalValueOfIsEnabled;
234 std::vector<std::function<void()>>*
const m_guards =
235 new std::vector<std::function<void()>>();
Definition: ini_config.h:78
Definition: apple_utils.h:6
Definition: ini_config.cpp:326