#define X_NCBI_PARAM_DESC_DECL(type, desctype, tagtype)
#define X_NCBI_PARAM_DECLNAME(section, name)
Usage of the parameters:
Parameter declaration.
Generates struct for storing the parameter. Section and name may be used to set default value through a registry or environment variable section_name.
Definition at line 157 of file ncbi_param.hpp.
◆ NCBI_PARAM_DECL_EXPORT #define NCBI_PARAM_DECL_EXPORT ( expname, type, section, name ) ◆ NCBI_PARAM_DEF #define NCBI_PARAM_DEF ( type, section, name, default_value ) Value:default_value)
@ eParam_Default
Default flags.
Parameter definition.
"default_value" is used to set the initial parameter value, which may be overriden by registry or environment. The default value must be a scalar literal for the default value to be initialized statically.
Definition at line 206 of file ncbi_param.hpp.
◆ NCBI_PARAM_DEF_EX #define NCBI_PARAM_DEF_EX ( type, section, name, default_value, flags, env ) ◆ NCBI_PARAM_DEF_EX_WITH_INIT #define NCBI_PARAM_DEF_EX_WITH_INIT ( type, section, name, def_value, init, flags, env ) ◆ NCBI_PARAM_DEF_IN_SCOPE #define NCBI_PARAM_DEF_IN_SCOPE ( type, section, name, default_value, scope ) Value:X_NCBI_PARAM_STATIC_DEF( \
default_value)
#define X_NCBI_PARAM_DECLNAME_SCOPE(scope, section, name)
Similar to NCBI_PARAM_DEF except it adds "scope" (class name or namespace) to the parameter's type.
Definition at line 251 of file ncbi_param.hpp.
◆ NCBI_PARAM_DEF_WITH_INIT #define NCBI_PARAM_DEF_WITH_INIT ( type, section, name, default_value, init ) Value:Parameter definition.
The same as NCBI_PARAM_DEF, but with a callback used to initialize the default value.
Definition at line 217 of file ncbi_param.hpp.
◆ NCBI_PARAM_ENUM_ARRAY ◆ NCBI_PARAM_ENUM_DECL #define NCBI_PARAM_ENUM_DECL ( type, section, name ) Value:Enum parameter declaration.
In addition to NCBI_PARAM_DECL also specializes CParamParser<type, ptype> to convert between strings and enum values.
Definition at line 179 of file ncbi_param.hpp.
◆ NCBI_PARAM_ENUM_DECL_EXPORT #define NCBI_PARAM_ENUM_DECL_EXPORT ( expname, type, section, name ) Value:Same as NCBI_PARAM_ENUM_DECL but with export specifier (e.g.
NCBI_XNCBI_EXPORT)
Definition at line 194 of file ncbi_param.hpp.
◆ NCBI_PARAM_ENUM_DEF #define NCBI_PARAM_ENUM_DEF ( type, section, name, default_value ) Value:X_NCBI_PARAM_ENUMNAME(section, name), \
default_value)
#define X_NCBI_PARAM_ENUMNAME(section, name)
Enum parameter definition.
Additional 'enums' argument should provide static array of SEnumDescription<type>.
Definition at line 267 of file ncbi_param.hpp.
◆ NCBI_PARAM_ENUM_DEF_EX #define NCBI_PARAM_ENUM_DEF_EX ( type, section, name, default_value, flags, env ) ◆ NCBI_PARAM_STATIC_PROXY #define NCBI_PARAM_STATIC_PROXY ( user_type, pod_type ) Value:public: \
typedef user_type TValue; \
CSafeStatic_Proxy(void) {} \
return *this; \
} \
return *this; \
} \
operator TValue& (void) {
return m_Value; } \
private: \
}
enable_if< std::is_scalar< TValue >::value, TValue >::type TStaticInit
CSafeStatic_Proxy & operator=(TValue value)
const GenericPointer< typename T::ValueType > T2 value
Define CSafeStatic_Proxy for a non-POD type using the provided POD type to store the default value.
NOTE: The proxy specialization must be defined in 'ncbi' namespace.
Definition at line 294 of file ncbi_param.hpp.
◆ NCBI_PARAM_TYPEGenerate typename for a parameter from its {section, name} attributes.
Definition at line 149 of file ncbi_param.hpp.
◆ X_NCBI_PARAM_DECLNAME #define X_NCBI_PARAM_DECLNAME ( section, name ) SNcbiParamDesc_##section##_##nameUsage of the parameters:
For enum parameters define mappings between strings and values before defining the parameter: NCBI_PARAM_ENUM_ARRAY(EMyEnum, MySection, MyEnumParam) { {"My_A", eMyEnum_A}, {"My_B", eMyEnum_B}, {"My_C", eMyEnum_C} };
NCBI_PARAM_ENUM_DEF(EMyEnum, MySection, MyEnumParam, eMyEnum_B);
Parameter declaration and definition macros
Each parameter must be declared and defined using the macros
Definition at line 96 of file ncbi_param.hpp.
◆ X_NCBI_PARAM_DECLNAME_SCOPE #define X_NCBI_PARAM_DECLNAME_SCOPE ( scope, section, name ) scope::SNcbiParamDesc_##section##_##nameDefinition at line 99 of file ncbi_param.hpp.
◆ X_NCBI_PARAM_DESC_DECL #define X_NCBI_PARAM_DESC_DECL ( type, desctype, tagtype ) Value:{ \
typedef tagtype TTagType; \
typedef
typeTValueType; \
typedef desctype<TValueType> TDescription; \
typedef TDescription::TStaticValue TStaticValue; \
static TDescription sm_ParamDescription; \
static TStaticValue sm_Default; \
static bool sm_DefaultInitialized; \
static TTls sm_ValueTls; \
}
EParamState
Current param state flag - indicates which possible sources for the param have been checked.
EParamSource
Source of the value returned by CParam::GetDefault().
Definition at line 107 of file ncbi_param.hpp.
◆ X_NCBI_PARAM_ENUM_PARSER_DECL #define X_NCBI_PARAM_ENUM_PARSER_DECL ( type, ptype ) Value:CParamParser< SParamEnumDescription< type >, ptype >::TValueType \
CParamParser< SParamEnumDescription< type >, ptype >:: \
StringToValue(
const string&
str, \
const TParamDesc& descr) \
EMPTY_TEMPLATE inline string \
CParamParser< SParamEnumDescription< type >, ptype >:: \
ValueToString(const TValueType& val, \
const TParamDesc& descr) \
static TEnumType StringToEnum(const string &str, const TParamDesc &descr)
static string EnumToString(const TEnumType &val, const TParamDesc &descr)
static const char * str(char *buf, int n)
Definition at line 125 of file ncbi_param.hpp.
◆ X_NCBI_PARAM_ENUMNAME #define X_NCBI_PARAM_ENUMNAME ( section, name ) s_EnumData_##section##_##nameDefinition at line 102 of file ncbi_param.hpp.
◆ X_NCBI_PARAM_STATIC_DEF #define X_NCBI_PARAM_STATIC_DEF ( descname, defval ) Value:descname::TStaticValue descname::sm_Default = defval; \
bool descname::sm_DefaultInitialized = false; \
descname::TTls descname::sm_ValueTls;
\@ eState_NotSet
The param's value has not been set yet.
@ eSource_NotSet
Not fully initialized.
Definition at line 140 of file ncbi_param.hpp.
◆ TNcbiParamFlags ◆ TParam ◆ TParamDesctemplate<class TDescription , class TParam >
Definition at line 358 of file ncbi_param.hpp.
◆ TParamDescription ◆ TParamParser ◆ TTagType ◆ TTls ◆ TValueType [1/2]template<class TDescription , class TParam >
Definition at line 359 of file ncbi_param.hpp.
◆ TValueType [2/2] ◆ EErrCode Enumerator eParserErrorCan not convert string to value.
eBadValueUnexpected parameter value.
eNoThreadValuePer-thread value is prohibited by flags.
eRecursionRecursion while initializing param.
Definition at line 325 of file ncbi_param.hpp.
◆ ENcbiParamFlagsENcbiParamFlags.
CParam flags
Enumerator eParam_DefaultDefault flags.
eParam_NoLoadDo not load from registry or environment.
eParam_NoThreadDo not use per-thread values.
Definition at line 415 of file ncbi_param.hpp.
◆ EParamCacheFlagCaching default value on construction of a param.
Enumerator eParamCache_ForceForce caching currently set default value.
eParamCache_TryCache the default value if the application registry is already initialized.
eParamCache_DeferDo not try to cache the default value.
Definition at line 424 of file ncbi_param.hpp.
◆ EParamSourceSource of the value returned by CParam::GetDefault().
Not fully initialized.
eSource_DefaultHardcoded default.
eSource_FuncInitialization function.
eSource_UserUser code.
eSource_EnvVarEnvironment.
eSource_ConfigThe app. config file.
Definition at line 395 of file ncbi_param.hpp.
◆ EParamStateCurrent param state flag - indicates which possible sources for the param have been checked.
This flag does not indicate where does the current value originate from. It just shows the stage of parameter loading process.
The param's value has not been set yet.
eState_InFuncThe initialization function is being executed.
eState_FuncInitialized using FParamInit function.
eState_UserValue has been set by user.
eState_EnvVarThe environment variable has been checked.
eState_ConfigThe app. config file has been checked.
eState_ErrorError reading param value, do not try to re-read.
Definition at line 383 of file ncbi_param.hpp.
◆ CParam() [1/3]template<class TDescription >
Load parameter value from registry or environment.
Overrides section and name set in the parameter description. Does not affect the existing default values.
◆ CParam() [2/3]template<class TDescription >
Create parameter with a given value, ignore defaults.
Definition at line 461 of file ncbi_param.hpp.
◆ CParam() [3/3]template<class TDescription >
◆ EnableConfigDump() void CParamBase::EnableConfigDump ( bool enable ) static ◆ g_GetConfigDouble() double g_GetConfigDouble ( const char * section, const char * variable, const char * env_var_name, double default_value )Get double configuration value.
Definition at line 311 of file ncbi_param.cpp.
References _T_CSTRING, DUMP_CONFIG, NStr::fAllowLeadingSpaces, NStr::fAllowTrailingSpaces, NStr::fDecimalPosixOrLocal, CNcbiApplicationAPI::FinishedLoadingConfig(), IRegistry::Get(), CNcbiApplicationAPI::GetConfig(), CNcbiApplicationAPI::InstanceGuard(), str(), NStr::StringToDouble(), and rapidjson::value.
Referenced by CSnpPtisClient_Impl::CSnpPtisClient_Impl().
◆ g_GetConfigFlag() bool g_GetConfigFlag ( const char * section, const char * variable, const char * env_var_name, bool default_value )Get boolean configuration value.
Definition at line 133 of file ncbi_param.cpp.
References _T_CSTRING, DUMP_CONFIG, NStr::Equal(), CNcbiApplicationAPI::FinishedLoadingConfig(), IRegistry::Get(), CNcbiApplicationAPI::GetConfig(), CNcbiApplicationAPI::InstanceGuard(), str(), and rapidjson::value.
Referenced by CMsvcSite::IsProvided().
◆ g_GetConfigInt() int g_GetConfigInt ( const char * section, const char * variable, const char * env_var_name, int default_value )Get integer configuration value.
Definition at line 229 of file ncbi_param.cpp.
References _T_CSTRING, DUMP_CONFIG, CNcbiApplicationAPI::FinishedLoadingConfig(), IRegistry::Get(), CNcbiApplicationAPI::GetConfig(), CNcbiApplicationAPI::InstanceGuard(), str(), NStr::StringToInt(), and rapidjson::value.
Referenced by CSnpPtisClient_Impl::CSnpPtisClient_Impl().
◆ g_GetConfigString()Helper functions for getting values from registry/environment.
Get string configuration value.
Definition at line 397 of file ncbi_param.cpp.
References _T_STDSTRING, DUMP_CONFIG, CParamBase::eSource_Config, CParamBase::eSource_Default, CParamBase::eSource_EnvVar, CParamBase::eSource_NotSet, CNcbiApplicationAPI::FinishedLoadingConfig(), IRegistry::Get(), CNcbiApplicationAPI::GetConfig(), CNcbiApplicationAPI::InstanceGuard(), and rapidjson::value.
Referenced by CMsvcSite::CMsvcSite(), g_NCBI_GRPC_GetAddress(), and CParam< TDescription >::sx_GetDefault().
◆ Get()template<class TDescription >
◆ GetDefault()template<class TDescription >
Get global default value.
If not yet set, attempts to load the value from application registry or environment.
Definition at line 526 of file ncbi_param_impl.hpp.
Referenced by operator<<().
◆ GetErrCodeString() const char * CParamException::GetErrCodeString ( void ) const overridevirtual ◆ GetState()template<class TDescription >
◆ GetThreadDefault()template<class TDescription >
◆ NCBI_EXCEPTION_DEFAULT() ◆ Reset()template<class TDescription >
void CParam< TDescription >::Reset ( void ) inlinevirtualReset value as if it has not been initialized yet.
Next call to Get() will cache the thread default (or global default) value.
Reimplemented from CParam_Base.
Definition at line 637 of file ncbi_param_impl.hpp.
◆ ResetDefault()template<class TDescription >
void CParam< TDescription >::ResetDefault ( void ) inlinestaticReload the global default value from the environment/registry or reset it to the initial value specified in NCBI_PARAM_DEF.
Definition at line 549 of file ncbi_param_impl.hpp.
◆ ResetThreadDefault()template<class TDescription >
void CParam< TDescription >::ResetThreadDefault ( void ) inlinestatic ◆ s_GetLock()template<class TDescription >
SSystemMutex & CParam< TDescription >::s_GetLock ( void ) staticprivate ◆ Set()template<class TDescription >
Set new parameter value (this instance only).
Definition at line 628 of file ncbi_param_impl.hpp.
References val.
◆ SetDefault()template<class TDescription >
Set new global default value.
Does not affect values of existing CParam<> objects or thread-local default values.
Definition at line 535 of file ncbi_param_impl.hpp.
References val.
◆ SetThreadDefault()template<class TDescription >
◆ StringToValue()template<class TDescription , class TParam >
◆ sx_CanGetDefault()template<class TDescription >
bool CParam< TDescription >::sx_CanGetDefault ( void ) inlinestaticprivate ◆ sx_GetDefault()template<class TDescription >
◆ sx_GetSource() ◆ sx_GetState() ◆ sx_GetTls() ◆ sx_IsSetFlag()template<class TDescription >
◆ ValueToString()template<class TDescription , class TParam >
◆ ~CParam() ◆ m_Value ◆ m_ValueSetRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4