10 #if !defined(NX_KIT_API) 78 static bool isEnabled();
80 static void setEnabled(
bool value);
88 static void setOutput(std::ostream* output);
91 static const char* iniFilesDir();
100 static void setIniFilesDir(
const char* iniFilesDir);
112 const char* iniFile()
const;
113 const char* iniFilePath()
const;
121 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 122 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 124 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 125 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 127 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 128 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 130 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 131 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 133 #define NX_INI_DOUBLE(DEFAULT, PARAM, DESCRIPTION) \ 134 const double PARAM = regDoubleParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 137 bool regBoolParam(
const bool* pValue,
bool defaultValue,
138 const char* paramName,
const char* description);
140 int regIntParam(
const int* pValue,
int defaultValue,
141 const char* paramName,
const char* description);
143 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
144 const char* paramName,
const char* description);
146 float regFloatParam(
const float* pValue,
float defaultValue,
147 const char* paramName,
const char* description);
149 double regDoubleParam(
const double* pValue,
double defaultValue,
150 const char* paramName,
const char* description);
177 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
179 if (++s_tweaksInstanceCount == 1)
181 s_originalValueOfIsEnabled = isEnabled();
188 for (
const auto& guard: *m_guards)
192 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
194 if (--s_tweaksInstanceCount == 0)
195 setEnabled(s_originalValueOfIsEnabled);
201 Tweaks(
const Tweaks&) =
delete;
202 Tweaks(Tweaks&&) =
delete;
203 Tweaks& operator=(
const Tweaks&) =
delete;
204 Tweaks& operator=(Tweaks&&) =
delete;
207 void set(
const T* field, T newValue)
209 const auto oldValue = *field;
210 T*
const mutableField =
const_cast<T*
>(field);
211 m_guards->push_back([=]() { *mutableField = oldValue; });
212 *mutableField = newValue;
218 std::mutex*
const mutex =
new std::mutex();
219 ~MutexHolder() {
delete mutex; }
222 static MutexHolder s_mutexHolder;
223 static int s_tweaksInstanceCount;
224 static bool s_originalValueOfIsEnabled;
226 std::vector<std::function<void()>>*
const m_guards =
227 new std::vector<std::function<void()>>();
Definition: ini_config.h:70
Definition: apple_utils.h:6
Definition: ini_config.cpp:326