NCBI C++ ToolKit
Classes | Typedefs | Enumerations | Enumerator | Functions | Variables
Configuration Utilities
+ Collaboration diagram for Configuration Utilities:

Classes

class  CConfigException
 CConfigException –. More...
 
class  CConfig
 

Typedefs

typedef CTreePair< string, string, PEqualNocase_ConditionalCConfig::TParamValue
 Instantiation parameters tree. More...
 
typedef TParamValue::TPairTreeNode CConfig::TParamTree
 

Enumerations

enum  CConfigException::EErrCode { CConfigException::eParameterMissing , CConfigException::eSynonymDuplicate , CConfigException::eInvalidParameter }
 
enum  CConfig::EErrAction { CConfig::eErr_Throw , CConfig::eErr_NoThrow }
 Defines how to behave when parameter is missing. More...
 

Functions

virtual const char * CConfigException::GetErrCodeString (void) const override
 Translate from the error code value to its string representation. More...
 
 CConfigException::NCBI_EXCEPTION_DEFAULT (CConfigException, CCoreException)
 
 CConfig::CConfig (TParamTree *param_tree, EOwnership own=eTakeOwnership, NStr::ECase use_case=NStr::eNocase)
 Optionally takes ownership on passed param_tree. More...
 
 CConfig::CConfig (const TParamTree *param_tree, NStr::ECase use_case=NStr::eNocase)
 Construct, take no tree ownership. More...
 
 CConfig::CConfig (const IRegistry &reg, NStr::ECase use_case=NStr::eNocase)
 Take registry and create a config tree out of it. More...
 
 CConfig::~CConfig ()
 
string CConfig::GetString (const string &driver_name, const string &param_name, EErrAction on_error, const string &default_value, const list< string > *synonyms=NULL)
 Utility function to get an element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value) More...
 
const stringCConfig::GetString (const string &driver_name, const string &param_name, EErrAction on_error, const list< string > *synonyms=NULL)
 This version always defaults to the empty string so that it can safely return a reference. More...
 
int CConfig::GetInt (const string &driver_name, const string &param_name, EErrAction on_error, int default_value, const list< string > *synonyms=NULL)
 Utility function to get an integer element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value) More...
 
Uint8 CConfig::GetDataSize (const string &driver_name, const string &param_name, EErrAction on_error, unsigned int default_value, const list< string > *synonyms=NULL)
 Utility function to get an integer element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value) This function understands KB, MB, GB qualifiers at the end of the string. More...
 
bool CConfig::GetBool (const string &driver_name, const string &param_name, EErrAction on_error, bool default_value, const list< string > *synonyms=NULL)
 Utility function to get an integer element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value) More...
 
double CConfig::GetDouble (const string &driver_name, const string &param_name, EErrAction on_error, double default_value, const list< string > *synonyms=NULL)
 Utility function to get a double element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value) More...
 
const TParamTreeCConfig::GetTree () const
 
static TParamTreeCConfig::ConvertRegToTree (const IRegistry &reg, NStr::ECase use_case=NStr::eNocase)
 Reconstruct param tree from the application registry. More...
 
string CConfig::Get (const string &d, const string &p, EErrAction e, const string &v, const list< string > *s=NULL)
 Overloading of getters for generic programming. More...
 
int CConfig::Get (const string &d, const string &p, EErrAction e, int v, const list< string > *s=NULL)
 
bool CConfig::Get (const string &d, const string &p, EErrAction e, bool v, const list< string > *s=NULL)
 
double CConfig::Get (const string &d, const string &p, EErrAction e, double v, const list< string > *s=NULL)
 
 CConfig::CConfig (const CConfig &)
 
CConfigCConfig::operator= (const CConfig &)
 
const stringCConfig::x_GetString (const string &driver_name, const string &param_name, EErrAction on_error, const string &default_value, const list< string > *synonyms)
 

Variables

AutoPtr< TParamTreeCConfig::m_ParamTree
 

Detailed Description

Typedef Documentation

◆ TParamTree

Definition at line 82 of file ncbi_config.hpp.

◆ TParamValue

Instantiation parameters tree.

Plug-in instantiation model is based on class factories. Recursive class factory calls are modeled as tree, where specific subtree is responsible for CF parameters

Definition at line 81 of file ncbi_config.hpp.

Enumeration Type Documentation

◆ EErrAction

Defines how to behave when parameter is missing.

Enumerator
eErr_Throw 

Throw an exception on error.

eErr_NoThrow 

Return default value on error.

Definition at line 103 of file ncbi_config.hpp.

◆ EErrCode

Enumerator
eParameterMissing 

Missing mandatory parameter.

eSynonymDuplicate 
eInvalidParameter 

Invalid parameter value.

Definition at line 55 of file ncbi_config.hpp.

Function Documentation

◆ CConfig() [1/4]

CConfig::CConfig ( const CConfig )
private

◆ CConfig() [2/4]

CConfig::CConfig ( const IRegistry reg,
NStr::ECase  use_case = NStr::eNocase 
)
explicit

Take registry and create a config tree out of it.

Definition at line 449 of file ncbi_config.cpp.

References _ASSERT, CConfig::ConvertRegToTree(), eTakeOwnership, and CConfig::m_ParamTree.

◆ CConfig() [3/4]

CConfig::CConfig ( const TParamTree param_tree,
NStr::ECase  use_case = NStr::eNocase 
)
explicit

Construct, take no tree ownership.

Definition at line 456 of file ncbi_config.cpp.

References eNoOwnership, eTakeOwnership, and CConfig::m_ParamTree.

◆ CConfig() [4/4]

CConfig::CConfig ( TParamTree param_tree,
EOwnership  own = eTakeOwnership,
NStr::ECase  use_case = NStr::eNocase 
)
explicit

Optionally takes ownership on passed param_tree.

Definition at line 440 of file ncbi_config.cpp.

References eTakeOwnership, and CConfig::m_ParamTree.

◆ ConvertRegToTree()

CConfig::TParamTree * CConfig::ConvertRegToTree ( const IRegistry reg,
NStr::ECase  use_case = NStr::eNocase 
)
static

◆ Get() [1/4]

bool CConfig::Get ( const string d,
const string p,
EErrAction  e,
bool  v,
const list< string > *  s = NULL 
)
inline

Definition at line 240 of file ncbi_config.hpp.

References CConfig::GetBool().

◆ Get() [2/4]

string CConfig::Get ( const string d,
const string p,
EErrAction  e,
const string v,
const list< string > *  s = NULL 
)
inline

Overloading of getters for generic programming.

Definition at line 232 of file ncbi_config.hpp.

References CConfig::GetString().

◆ Get() [3/4]

double CConfig::Get ( const string d,
const string p,
EErrAction  e,
double  v,
const list< string > *  s = NULL 
)
inline

Definition at line 244 of file ncbi_config.hpp.

References CConfig::GetDouble().

◆ Get() [4/4]

int CConfig::Get ( const string d,
const string p,
EErrAction  e,
int  v,
const list< string > *  s = NULL 
)
inline

Definition at line 236 of file ncbi_config.hpp.

References CConfig::GetInt().

◆ GetBool()

bool CConfig::GetBool ( const string driver_name,
const string param_name,
EErrAction  on_error,
bool  default_value,
const list< string > *  synonyms = NULL 
)

Utility function to get an integer element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value)

Parameters
driver_nameName of the module requesting parameter (used in diagnostics)
paramsParameters tree
param_nameName of the parameter
mandatoryError action
default_valueDefault value for missing parameters
See also
ParamTree_GetString

Definition at line 627 of file ncbi_config.cpp.

References CConfig::eErr_Throw, ERR_POST_X_ONCE, CConfig::GetString(), NCBI_THROW, and NStr::StringToBool().

Referenced by CCacheReader::CCacheReader(), CPubseq2Reader::CPubseq2Reader(), CPubseqReader::CPubseqReader(), CConfig::Get(), CSimpleClassFactoryImpl< CReader, CCacheReader >::GetParamBool(), CReader::InitParams(), and CCDDDataLoader::SLoaderParams::SLoaderParams().

◆ GetDataSize()

Uint8 CConfig::GetDataSize ( const string driver_name,
const string param_name,
EErrAction  on_error,
unsigned int  default_value,
const list< string > *  synonyms = NULL 
)

Utility function to get an integer element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value) This function understands KB, MB, GB qualifiers at the end of the string.

Parameters
driver_nameName of the module requesting parameter (used in diagnostics)
paramsParameters tree
param_nameName of the parameter
mandatoryError action
default_valueDefault value for missing parameters
See also
ParamTree_GetString

Definition at line 586 of file ncbi_config.cpp.

References CConfig::eErr_Throw, ERR_POST_X_ONCE, CConfig::GetString(), NCBI_THROW, and NStr::StringToUInt8_DataSize().

Referenced by CSimpleClassFactoryImpl< CReader, CCacheReader >::GetParamDataSize(), NS_GetDataSize(), NS_ValidateDataSize(), and SPubseqGatewaySettings::x_GetDataSize().

◆ GetDouble()

double CConfig::GetDouble ( const string driver_name,
const string param_name,
EErrAction  on_error,
double  default_value,
const list< string > *  synonyms = NULL 
)

Utility function to get a double element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value)

Parameters
driver_nameName of the module requesting parameter (used in diagnostics)
paramsParameters tree
param_nameName of the parameter
mandatoryError action
default_valueDefault value for missing parameters
See also
ParamTree_GetString

Definition at line 667 of file ncbi_config.cpp.

References CConfig::eErr_Throw, ERR_POST_X_ONCE, NStr::fDecimalPosixOrLocal, CConfig::GetString(), NCBI_THROW, and NStr::StringToDouble().

Referenced by CConfig::Get(), and CSimpleClassFactoryImpl< CReader, CCacheReader >::GetParamDouble().

◆ GetErrCodeString()

const char * CConfigException::GetErrCodeString ( void  ) const
overridevirtual

Translate from the error code value to its string representation.

Reimplemented from CCoreException.

Definition at line 707 of file ncbi_config.cpp.

References CConfigException::eInvalidParameter, CConfigException::eParameterMissing, CConfigException::eSynonymDuplicate, CCoreException::GetErrCode(), and CException::GetErrCodeString().

◆ GetInt()

int CConfig::GetInt ( const string driver_name,
const string param_name,
EErrAction  on_error,
int  default_value,
const list< string > *  synonyms = NULL 
)

Utility function to get an integer element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value)

Parameters
driver_nameName of the module requesting parameter (used in diagnostics)
paramsParameters tree
param_nameName of the parameter
mandatoryError action
default_valueDefault value for missing parameters
See also
ParamTree_GetString

Definition at line 546 of file ncbi_config.cpp.

References CConfig::eErr_Throw, ERR_POST_X_ONCE, CConfig::GetString(), NCBI_THROW, and NStr::StringToInt().

Referenced by CID2SNPProcessor_Impl::CID2SNPProcessor_Impl(), CPubseq2Reader::CPubseq2Reader(), CConfig::Get(), CSimpleClassFactoryImpl< CReader, CCacheReader >::GetParamInt(), CReader::InitParams(), CReaderServiceConnector::InitTimeouts(), and CCDDDataLoader::SLoaderParams::SLoaderParams().

◆ GetString() [1/2]

const string & CConfig::GetString ( const string driver_name,
const string param_name,
EErrAction  on_error,
const list< string > *  synonyms = NULL 
)

This version always defaults to the empty string so that it can safely return a reference.

(default_value may be temporary in some cases.)

Definition at line 483 of file ncbi_config.cpp.

References kEmptyStr, and CConfig::x_GetString().

◆ GetString() [2/2]

string CConfig::GetString ( const string driver_name,
const string param_name,
EErrAction  on_error,
const string default_value,
const list< string > *  synonyms = NULL 
)

Utility function to get an element of parameter tree Throws an exception when mandatory parameter is missing (or returns the default value)

Parameters
driver_nameName of the module requesting parameter (used in diagnostics)
paramsParameters tree
param_nameName of the parameter
mandatoryError action
default_valueDefault value for missing parameters

Definition at line 472 of file ncbi_config.cpp.

References CConfig::x_GetString().

Referenced by CGICacheReader::CGICacheReader(), CId1Reader::CId1Reader(), CId2Reader::CId2Reader(), CPubseq2Reader::CPubseq2Reader(), CPubseqReader::CPubseqReader(), CConfig::Get(), CConfig::GetBool(), CConfig::GetDataSize(), CConfig::GetDouble(), CConfig::GetInt(), IClassFactory< TClass >::GetParam(), CCDDDataLoader::SLoaderParams::SLoaderParams(), and CIncreasingTime::x_GetDoubleParam().

◆ GetTree()

const TParamTree* CConfig::GetTree ( void  ) const
inline

◆ NCBI_EXCEPTION_DEFAULT()

CConfigException::NCBI_EXCEPTION_DEFAULT ( CConfigException  ,
CCoreException   
)

◆ operator=()

CConfig& CConfig::operator= ( const CConfig )
private

◆ x_GetString()

const string & CConfig::x_GetString ( const string driver_name,
const string param_name,
EErrAction  on_error,
const string default_value,
const list< string > *  synonyms 
)
protected

◆ ~CConfig()

CConfig::~CConfig ( )

Definition at line 467 of file ncbi_config.cpp.

Variable Documentation

◆ m_ParamTree

AutoPtr<TParamTree> CConfig::m_ParamTree
protected

Definition at line 260 of file ncbi_config.hpp.

Referenced by CConfig::CConfig(), CConfig::GetTree(), and CConfig::x_GetString().

Modified on Tue Apr 23 07:39:36 2024 by modify_doxy.py rev. 669887