10 #if !defined(NX_KIT_API) 70 static bool isEnabled();
72 static void setEnabled(
bool value);
80 static void setOutput(std::ostream* output);
83 static const char* iniFilesDir();
92 static void setIniFilesDir(
const char* iniFilesDir);
104 const char* iniFile()
const;
105 const char* iniFilePath()
const;
113 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 114 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 116 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 117 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 119 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 120 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 122 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 123 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 125 #define NX_INI_DOUBLE(DEFAULT, PARAM, DESCRIPTION) \ 126 const double PARAM = regDoubleParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 129 bool regBoolParam(
const bool* pValue,
bool defaultValue,
130 const char* paramName,
const char* description);
132 int regIntParam(
const int* pValue,
int defaultValue,
133 const char* paramName,
const char* description);
135 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
136 const char* paramName,
const char* description);
138 float regFloatParam(
const float* pValue,
float defaultValue,
139 const char* paramName,
const char* description);
141 double regDoubleParam(
const double* pValue,
double defaultValue,
142 const char* paramName,
const char* description);
169 const std::lock_guard<std::mutex> lock(*m_mutexHolder.mutex);
171 if (++tweaksInstanceCount != 0)
173 originalValueOfIsEnabled = isEnabled();
180 for (
const auto& guard: *m_guards)
184 const std::lock_guard<std::mutex> lock(*m_mutexHolder.mutex);
186 if (--tweaksInstanceCount == 0)
187 setEnabled(originalValueOfIsEnabled);
193 Tweaks(
const Tweaks&) =
delete;
194 Tweaks(Tweaks&&) =
delete;
195 Tweaks& operator=(
const Tweaks&) =
delete;
196 Tweaks& operator=(Tweaks&&) =
delete;
199 void set(
const T* field, T newValue)
201 const auto oldValue = *field;
202 T*
const mutableField =
const_cast<T*
>(field);
203 m_guards->push_back([=]() { *mutableField = oldValue; });
204 *mutableField = newValue;
210 std::mutex*
const mutex =
new std::mutex();
211 ~MutexHolder() {
delete mutex; }
214 static MutexHolder m_mutexHolder;
215 static int tweaksInstanceCount;
216 static bool originalValueOfIsEnabled;
218 std::vector<std::function<void()>>*
const m_guards =
219 new std::vector<std::function<void()>>();
Definition: ini_config.h:62
Definition: apple_utils.h:6
Definition: ini_config.cpp:344