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;
141 bool getParamTypeAndValue(
142 const char* paramName, ParamType* outType,
const void** outData)
const;
145 #define NX_INI_FLAG(DEFAULT, PARAM, DESCRIPTION) \ 146 const bool PARAM = regBoolParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 148 #define NX_INI_INT(DEFAULT, PARAM, DESCRIPTION) \ 149 const int PARAM = regIntParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 151 #define NX_INI_STRING(DEFAULT, PARAM, DESCRIPTION) \ 152 const char* const PARAM = regStringParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 154 #define NX_INI_FLOAT(DEFAULT, PARAM, DESCRIPTION) \ 155 const float PARAM = regFloatParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 157 #define NX_INI_DOUBLE(DEFAULT, PARAM, DESCRIPTION) \ 158 const double PARAM = regDoubleParam(&PARAM, DEFAULT, #PARAM, DESCRIPTION) 161 bool regBoolParam(
const bool* pValue,
bool defaultValue,
162 const char* paramName,
const char* description);
164 int regIntParam(
const int* pValue,
int defaultValue,
165 const char* paramName,
const char* description);
167 const char* regStringParam(
const char*
const* pValue,
const char* defaultValue,
168 const char* paramName,
const char* description);
170 float regFloatParam(
const float* pValue,
float defaultValue,
171 const char* paramName,
const char* description);
173 double regDoubleParam(
const double* pValue,
double defaultValue,
174 const char* paramName,
const char* description);
196 class NX_KIT_API IniConfig::Tweaks
201 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
203 if (++s_tweaksInstanceCount == 1)
205 s_originalValueOfIsEnabled = isEnabled();
212 for (
const auto& guard: *m_guards)
216 const std::lock_guard<std::mutex> lock(*s_mutexHolder.mutex);
218 if (--s_tweaksInstanceCount == 0)
219 setEnabled(s_originalValueOfIsEnabled);
225 Tweaks(
const Tweaks&) =
delete;
226 Tweaks(Tweaks&&) =
delete;
227 Tweaks& operator=(
const Tweaks&) =
delete;
228 Tweaks& operator=(Tweaks&&) =
delete;
231 void set(
const T* field, T newValue)
233 const auto oldValue = *field;
234 T*
const mutableField =
const_cast<T*
>(field);
235 m_guards->push_back([=]() { *mutableField = oldValue; });
236 *mutableField = newValue;
242 std::mutex*
const mutex =
new std::mutex();
243 ~MutexHolder() {
delete mutex; }
246 static MutexHolder s_mutexHolder;
247 static int s_tweaksInstanceCount;
248 static bool s_originalValueOfIsEnabled;
250 std::vector<std::function<void()>>*
const m_guards =
251 new std::vector<std::function<void()>>();
Definition: ini_config.h:78
ParamType
Definition: ini_config.h:128
Definition: apple_utils.h:6