IRegistry Class Reference
[Application Registry]

Search Toolkit Book for IRegistry

#include <ncbireg.hpp>

Inheritance diagram for IRegistry:

Inheritance graph
[legend]
Collaboration diagram for IRegistry:

Collaboration graph
[legend]
List of all members.

Detailed Description

IRegistry --.

Base class for organized configuration data.

Does not define a specific in-memory representation, just a read-only API and some convenience methods.

Definition at line 75 of file ncbireg.hpp.

Public Types

typedef int TFlags
 Binary OR of "EFlags".
enum  EFlags {
  fTransient = 0x1, fPersistent = 0x100, fOverride = 0x2, fNoOverride = 0x200,
  fTruncate = 0x4, fNoTruncate = 0x400, fJustCore = 0x8, fNotJustCore = 0x800,
  fIgnoreErrors = 0x10, fInternalSpaces = 0x20, fWithNcbirc = 0x40, fCountCleared = 0x80,
  fSectionCase = 0x1000, fEntryCase = 0x2000, fCoreLayers = fTransient | fPersistent | fJustCore, fAllLayers = fTransient | fPersistent | fNotJustCore,
  fCaseFlags = fSectionCase | fEntryCase
}
 Flags controlling the behavior of registry methods. More...
enum  EErrAction { eThrow, eErrPost, eReturn }
 What to do if parameter value is present but cannot be converted into the requested type. More...

Public Member Functions

bool Empty (TFlags flags=fAllLayers) const
 Verify if Registry is empty.
bool Modified (TFlags flags=fPersistent) const
 Verify if persistent values have been modified.
void SetModifiedFlag (bool modified, TFlags flags=fPersistent)
 Indicate whether any relevant values are out of sync with some external resource (typically a configuration file).
bool Write (CNcbiOstream &os, TFlags flags=0) const
 Write the registry content to output stream.
const string & Get (const string &section, const string &name, TFlags flags=0) const
 Get the parameter value.
bool HasEntry (const string &section, const string &name=kEmptyStr, TFlags flags=0) const
string GetString (const string &section, const string &name, const string &default_value, TFlags flags=0) const
 Get the parameter string value.
int GetInt (const string &section, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
 Get integer value of specified parameter name.
bool GetBool (const string &section, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
 Get boolean value of specified parameter name.
double GetDouble (const string &section, const string &name, double default_value, TFlags flags=0, EErrAction err_action=eThrow) const
 Get double value of specified parameter name.
const string & GetComment (const string &section=kEmptyStr, const string &name=kEmptyStr, TFlags flags=0) const
 Get comment of the registry entry "section:name".
void EnumerateSections (list< string > *sections, TFlags flags=fAllLayers) const
 Enumerate section names.
void EnumerateEntries (const string &section, list< string > *entries, TFlags flags=fAllLayers) const
 Enumerate parameter names for a specified section.
void ReadLock (void)
 Support for locking.
void WriteLock (void)
void Unlock (void)

Protected Types

typedef void(IRegistry::* FLockAction )(void)
enum  EMasks { fLayerFlags = fAllLayers | fJustCore, fTPFlags = fTransient | fPersistent }

Protected Member Functions

virtual bool x_Empty (TFlags flags) const =0
 Implementations of the fundamental operations above, to be run with the lock already acquired and some basic sanity checks performed.
virtual bool x_Modified (TFlags) const
virtual void x_SetModifiedFlag (bool, TFlags)
virtual const string & x_Get (const string &section, const string &name, TFlags flags) const =0
virtual bool x_HasEntry (const string &section, const string &name, TFlags flags) const =0
virtual const string & x_GetComment (const string &section, const string &name, TFlags flags) const =0
virtual void x_Enumerate (const string &section, list< string > &entries, TFlags flags) const =0
virtual void x_ChildLockAction (FLockAction)

Static Protected Member Functions

static void x_CheckFlags (const string &func, TFlags &flags, TFlags allowed)

Private Attributes

CRWLock m_Lock


Member Typedef Documentation

typedef void(IRegistry::* IRegistry::FLockAction)(void) [protected]
 

Definition at line 297 of file ncbireg.hpp.

typedef int IRegistry::TFlags
 

Binary OR of "EFlags".

Definition at line 104 of file ncbireg.hpp.


Member Enumeration Documentation

enum IRegistry::EErrAction
 

What to do if parameter value is present but cannot be converted into the requested type.

Enumerator:
eThrow  Throw an exception if an error occurs.
eErrPost  Log the error message and return default value.
eReturn  Return default value.

Definition at line 179 of file ncbireg.hpp.

enum IRegistry::EFlags
 

Flags controlling the behavior of registry methods.

Please note:

  • Although CNcbiRegistry supports a full complement of layers, other derived classes may ignore some or all level-related flags.
  • Most read-only operations consider all layers; the only exception is Write, which defaults to fPersistent and fJustCore.
  • The presence or absence of fSectionCase and fEntryCase is relevant ONLY when constructing new registry objects.
Enumerator:
fTransient  Transient -- not saved by default.
fPersistent  Persistent -- saved when file is written.
fOverride  Existing value can be overriden.
fNoOverride  Cannot change existing value.
fTruncate  Leading, trailing blanks can be truncated.
fNoTruncate  Cannot truncate parameter value.
fJustCore  Ignore auxiliary subregistries.
fNotJustCore  Include auxiliary subregistries.
fIgnoreErrors  Continue Read()ing after parse errors.
fInternalSpaces  Allow internal whitespace in names.
fWithNcbirc  Include .ncbirc (used only by CNcbiReg.).
fCountCleared  Let explicitly cleared entries stand.
fSectionCase  Create with case-sensitive section names.
fEntryCase  Create with case-sensitive entry names.
fCoreLayers 
fAllLayers 
fCaseFlags 

Definition at line 85 of file ncbireg.hpp.

enum IRegistry::EMasks [protected]
 

Enumerator:
fLayerFlags 
fTPFlags 

Definition at line 274 of file ncbireg.hpp.


Member Function Documentation

bool IRegistry::Empty TFlags  flags = fAllLayers  )  const
 

Verify if Registry is empty.

Parameters:
flags Layer(s) to check.
Returns:
TRUE if the registry contains no entries.

Definition at line 152 of file ncbireg.cpp.

References fLayerFlags, fTPFlags, x_CheckFlags(), and x_Empty().

Referenced by CPtbRegistry::CPtbRegistry(), CCompoundRWRegistry::x_Read(), and IRWRegistry::x_Read().

void IRegistry::EnumerateEntries const string &  section,
list< string > *  entries,
TFlags  flags = fAllLayers
const
 

Enumerate parameter names for a specified section.

Write all parameter names for specified "section" to the "entries" list in order. Previous contents of the list are erased. Enumerates sections rather than entries if section is empty.

Parameters:
flags To control search.

Definition at line 422 of file ncbireg.cpp.

References _ASSERT, _TRACE, fCountCleared, fInternalSpaces, fLayerFlags, fTPFlags, NStr::PrintableString(), s_IsNameSection(), NStr::TruncateSpaces(), and x_CheckFlags().

Referenced by CDBUDPriorityMapper::ConfigureFromRegistry(), CDBUDRandomMapper::ConfigureFromRegistry(), CConfig::ConvertRegToTree(), CPluginManager< TClass >::CPluginManager(), CDriverManager::CreateDsFrom(), CRegistryFile::FromConfigFile(), GetDefaultLogLocation(), CCgiApplication::GetDefaultLogPath(), CColumnScoringMethod::Load(), CColorTableMethod::Load(), Write(), CNcbiTestApplication::x_ReadConfiguration(), and CGBenchApplication::x_TestGuiRegistry().

void IRegistry::EnumerateSections list< string > *  sections,
TFlags  flags = fAllLayers
const
 

Enumerate section names.

Write all section names to the "sections" list in (case-insensitive) order. Previous contents of the list are erased.

Parameters:
flags To control search.

Definition at line 408 of file ncbireg.cpp.

References _ASSERT, fCountCleared, fInternalSpaces, fLayerFlags, fTPFlags, kEmptyStr, x_CheckFlags(), and x_Enumerate().

Referenced by CConfig::ConvertRegToTree(), CIdMapperConfig::DescribeContexts(), CRegistryFile::FromConfigFile(), Write(), CNetCacheServer::x_CreateStorages(), and CGBenchApplication::x_TestGuiRegistry().

const string & IRegistry::Get const string &  section,
const string &  name,
TFlags  flags = 0
const
 

Get the parameter value.

Get the parameter with the specified "name" from the specified "section". First, search for the transient parameter value, and if cannot find in there, then continue the search in the non-transient parameters. If "fPersistent" flag is set in "flags", then don't search in the transient parameters at all.

Parameters:
section Section name to search under (case-insensitive).
name Parameter name to search for (case-insensitive).
flags To control search.
Returns:
The parameter value, or empty string if the parameter is not found.
See also:
GetString()

Definition at line 240 of file ncbireg.cpp.

References _TRACE, fInternalSpaces, fLayerFlags, fTPFlags, kEmptyStr, NStr::PrintableString(), s_IsNameSection(), NStr::TruncateSpaces(), x_CheckFlags(), and x_Get().

Referenced by CClientPseudoDataType::CClientPseudoDataType(), CCgiStatistics::Compose_Entries(), CGBenchSampleCgi::ConfigureDiagDestination(), CGBenchIndexCgi::ConfigureDiagDestination(), CConfig::ConvertRegToTree(), CProjectsLstFileFilter::CProjectsLstFileFilter(), CDriverManager::CreateDsFrom(), CHelloBasicCommand::CreateView(), CIdMapperConfig::DescribeContexts(), EnabledDelayBuffers(), CHelloCommand::Execute(), CRegistryFile::FromConfigFile(), g_GetConfigFlag(), g_GetConfigInt(), g_GetConfigString(), CCodeGenerator::GenerateClientCode(), CDataTool::GenerateCode(), CFileCode::GenerateHPP(), GetBool(), CProjBulderApp::GetBuildConfigs(), CProjBulderApp::GetDatatoolCommandLine(), GetDouble(), GetInt(), CCgiApplication::GetLogOpt(), CCodeGenerator::GetOpt(), GetOpt(), CProjBulderApp::GetRegSettings(), GetString(), CAlignFormatUtil::GetURLFromRegistry(), CSysLog::HonorRegistrySettings(), CCgiRedirectApplication::Init(), CGlCgiImageApplication::Init(), CMatrixScoringMethod::Load(), CTemplateScoringMethod::LoadInfo(), oligofar::COligoFarApp::ParseConfig(), CGetOpt::ParseIni(), CCgiRedirectApplication::ProcessRequest(), RegistryGetBoolean(), RegistryGetDouble(), RegistryGetInteger(), RegistryGetString(), RegistryIsValidBoolean(), RegistryIsValidDouble(), RegistryIsValidInteger(), RegistryIsValidString(), CCgiRedirectApplication::RemapEntries(), CLDSIndexerApplication::Run(), CUpdateOmssaModApplication::Run(), CBrowserUtils::SendToBrowser(), CWindowMaskerPanel::TransferDataToWindow(), CNetworkOptionsPage::TransferDataToWindow(), Write(), CCgiApplication::x_AddLBCookie(), CNcbiTestApplication::x_CalcConfigValue(), CDebugDumpViewer::x_CheckLocation(), CBlastHitMatrixCGIApplication::x_GetSeqAnnot(), CDataTypeModule::x_GetVar(), CNcbiApplication::x_HonorStandardSettings(), CSampleLdsApplication::x_InitLDS(), CNCBlobStorage::x_ReadStorageParams(), CCompoundRWRegistry::x_Set(), CGBenchApplication::x_TestGuiRegistry(), CSequenceSearchForm::x_UpdateFileList(), and COrfSearchForm::x_UpdateKozak().

bool IRegistry::GetBool const string &  section,
const string &  name,
bool  default_value,
TFlags  flags = 0,
EErrAction  err_action = eThrow
const
 

Get boolean value of specified parameter name.

Like "GetString()", plus convert the value into boolean.

Parameters:
err_action What to do if error encountered in converting parameter value.
See also:
GetString()

Definition at line 327 of file ncbireg.cpp.

References Get().

Referenced by BDB_CreateEnv(), CNCBlobStorage::CNCBlobStorage(), CQueueDataBase::Configure(), CGridWorkerNode::Init(), CGridCgiApplication::InitGridClient(), SQueueParameters::Read(), CGridWorkerNode::Run(), CCgiApplication::Run(), CLDSIndexerApplication::Run(), CBDBEnvKeeperApp::Run(), CNetworkOptionsPage::TransferDataToWindow(), CSampleLdsApplication::x_InitLDS(), and CNetCacheServer::x_RegReadBool().

const string & IRegistry::GetComment const string &  section = kEmptyStr,
const string &  name = kEmptyStr,
TFlags  flags = 0
const
 

Get comment of the registry entry "section:name".

Parameters:
section Section name. If passed empty string, then get the registry comment.
name Parameter name. If empty string, then get the "section" comment.
flags To control search.
Returns:
Comment string. If not found, return an empty string.

Definition at line 386 of file ncbireg.cpp.

References _TRACE, fInternalSpaces, fLayerFlags, kEmptyStr, NStr::PrintableString(), s_IsNameSection(), NStr::TruncateSpaces(), and x_CheckFlags().

Referenced by Write(), and IRWRegistry::x_Read().

double IRegistry::GetDouble const string &  section,
const string &  name,
double  default_value,
TFlags  flags = 0,
EErrAction  err_action = eThrow
const
 

Get double value of specified parameter name.

Like "GetString()", plus convert the value into double.

Parameters:
err_action What to do if error encountered in converting parameter value.
See also:
GetString()

Definition at line 356 of file ncbireg.cpp.

References Get().

Referenced by CMatrixScoringMethod::Load(), and CColumnScoringMethod::Load().

int IRegistry::GetInt const string &  section,
const string &  name,
int  default_value,
TFlags  flags = 0,
EErrAction  err_action = eThrow
const
 

Get integer value of specified parameter name.

Like "GetString()", plus convert the value into integer.

Parameters:
err_action What to do if error encountered in converting parameter value.
See also:
GetString()

Definition at line 298 of file ncbireg.cpp.

References Get().

Referenced by CCgiStatistics::Compose(), CDBConnectionFactory::ConfigureFromRegistry(), CSampleJob::CSampleJob(), CProjBulderApp::EnumOpt(), CGridCgiApplication::InitGridClient(), CRemoteAppParams::Load(), CGridWorkerNode::Run(), CBDBEnvKeeperApp::Run(), CNetworkOptionsPage::TransferDataToWindow(), CCgiApplication::x_AddLBCookie(), CCgiTunnel2Grid::x_Init(), CCgi2RCgiApp::x_Init(), and CNetCacheServer::x_RegReadInt().

string IRegistry::GetString const string &  section,
const string &  name,
const string &  default_value,
TFlags  flags = 0
const
 

Get the parameter string value.

Similar to the "Get()", but if the configuration parameter is not found, then return 'default_value' rather than empty string.

See also:
Get()

Definition at line 290 of file ncbireg.cpp.

References Get().

Referenced by BDB_CreateEnv(), CDBUniversalMapper::ConfigureFromRegistry(), CDBUDPriorityMapper::ConfigureFromRegistry(), CDBUDRandomMapper::ConfigureFromRegistry(), CPluginManager< TClass >::CPluginManager(), CRemoteAppIdleTask::CRemoteAppIdleTask(), CSampleJob::CSampleJob(), CProjBulderApp::GetDatatoolCommandLine(), CProjBulderApp::GetDatatoolId(), CProjBulderApp::GetDatatoolPathForApp(), CProjBulderApp::GetDatatoolPathForLib(), GetDllsList(), GetHostedLibs(), CProjBulderApp::GetRegSettings(), CSeqTextDemoDlg::Init(), CColorTableMethod::Load(), CRemoteAppParams::Load(), LoadConfigInfoByNames(), CTemplateScoringMethod::LoadInfo(), CProjBulderApp::ProcessLocationMacros(), SQueueParameters::Read(), SNS_Parameters::Read(), CGridWorkerNode::Run(), CSplitCacheApp::SetupCache(), CCgiApplication::x_AddLBCookie(), CTemplateScoringMethod::x_GetColor(), CODBC_Connection::x_GetDriverName(), CCgiTunnel2Grid::x_Init(), CCgi2RCgiApp::x_Init(), CUIToolRegistry::x_ReadToolInfo(), and CNetCacheServer::x_RegReadString().

bool IRegistry::HasEntry const string &  section,
const string &  name = kEmptyStr,
TFlags  flags = 0
const
 

Definition at line 265 of file ncbireg.cpp.

References _TRACE, fCountCleared, fInternalSpaces, fLayerFlags, fTPFlags, NStr::PrintableString(), s_IsNameSection(), NStr::TruncateSpaces(), and x_CheckFlags().

Referenced by CCodeGenerator::GetOpt(), CNcbiRegistry::IncludeNcbircIfAllowed(), CMatrixScoringMethod::Load(), CColorTableMethod::Load(), CRemoteAppParams::Load(), oligofar::COligoFarApp::ParseConfig(), CGetOpt::ParseIni(), CRemoteAppDispatcher::ProcessRequest(), CGridWorkerNode::Run(), CMemoryRegistry::x_Enumerate(), and CCompoundRWRegistry::x_Set().

bool IRegistry::Modified TFlags  flags = fPersistent  )  const
 

Verify if persistent values have been modified.

Parameters:
flags Layer(s) to check.
Returns:
TRUE if the relevant part(s) of the registry were modified since the last call to SetModifiedFlag(false).

Definition at line 163 of file ncbireg.cpp.

References fLayerFlags, fPersistent, fTransient, x_CheckFlags(), and x_Modified().

Referenced by Write(), and IRWRegistry::x_Read().

void IRegistry::ReadLock void   ) 
 

Support for locking.

Individual operations already use these to ensure atomicity, but the locking mechanism is recursive, so users can also make entire sequences of operations atomic.

Definition at line 443 of file ncbireg.cpp.

References m_Lock, CRWLock::ReadLock(), and x_ChildLockAction().

void IRegistry::SetModifiedFlag bool  modified,
TFlags  flags = fPersistent
 

Indicate whether any relevant values are out of sync with some external resource (typically a configuration file).

You should normally not need to call this explicitly.

Parameters:
flags Relevant layer(s).

Definition at line 174 of file ncbireg.cpp.

References fLayerFlags, fPersistent, fTransient, x_CheckFlags(), and x_SetModifiedFlag().

Referenced by Write().

void IRegistry::Unlock void   ) 
 

Definition at line 457 of file ncbireg.cpp.

References m_Lock, CRWLock::Unlock(), and x_ChildLockAction().

bool IRegistry::Write CNcbiOstream os,
TFlags  flags = 0
const
 

Write the registry content to output stream.

Parameters:
os Output stream to write the registry to. NOTE: if the stream is a file, it must be opened in binary mode!
flags Layer(s) to write. By default, only persistent entries are written, and only entries from the core layer(s) are written.
Returns:
TRUE if operation is successful.
See also:
IRWRegistry::Read()

Definition at line 186 of file ncbireg.cpp.

References Endl(), entries, EnumerateEntries(), EnumerateSections(), fCountCleared, fInternalSpaces, fJustCore, fLayerFlags, fNotJustCore, fPersistent, fTransient, Get(), GetComment(), ITERATE, kEmptyStr, Modified(), Printable(), s_WriteComment(), SetModifiedFlag(), and x_CheckFlags().

Referenced by SaveRegistry(), CRegistryFile::ToConfigFile(), CNCMessageHandler::x_DoCmd_GetConfig(), and CGBenchApplication::x_SaveConfig().

void IRegistry::WriteLock void   ) 
 

Definition at line 450 of file ncbireg.cpp.

References m_Lock, CRWLock::WriteLock(), and x_ChildLockAction().

static void IRegistry::x_CheckFlags const string &  func,
TFlags flags,
TFlags  allowed
[static, protected]
 

Referenced by IRWRegistry::Clear(), CNcbiRegistry::CNcbiRegistry(), Empty(), EnumerateEntries(), EnumerateSections(), Get(), GetComment(), HasEntry(), Modified(), IRWRegistry::Read(), IRWRegistry::Set(), IRWRegistry::SetComment(), SetModifiedFlag(), and Write().

virtual void IRegistry::x_ChildLockAction FLockAction   )  [inline, protected, virtual]
 

Definition at line 298 of file ncbireg.hpp.

Referenced by ReadLock(), Unlock(), and WriteLock().

virtual bool IRegistry::x_Empty TFlags  flags  )  const [protected, pure virtual]
 

Implementations of the fundamental operations above, to be run with the lock already acquired and some basic sanity checks performed.

Referenced by IRWRegistry::Clear(), and Empty().

virtual void IRegistry::x_Enumerate const string &  section,
list< string > &  entries,
TFlags  flags
const [protected, pure virtual]
 

Referenced by EnumerateSections().

virtual const string& IRegistry::x_Get const string &  section,
const string &  name,
TFlags  flags
const [protected, pure virtual]
 

Referenced by Get().

virtual const string& IRegistry::x_GetComment const string &  section,
const string &  name,
TFlags  flags
const [protected, pure virtual]
 

virtual bool IRegistry::x_HasEntry const string &  section,
const string &  name,
TFlags  flags
const [protected, pure virtual]
 

virtual bool IRegistry::x_Modified TFlags   )  const [inline, protected, virtual]
 

Definition at line 284 of file ncbireg.hpp.

Referenced by Modified().

virtual void IRegistry::x_SetModifiedFlag bool  ,
TFlags 
[inline, protected, virtual]
 

Definition at line 285 of file ncbireg.hpp.

Referenced by IRWRegistry::Clear(), IRWRegistry::Set(), and SetModifiedFlag().


Member Data Documentation

CRWLock IRegistry::m_Lock [mutable, private]
 

Definition at line 301 of file ncbireg.hpp.

Referenced by ReadLock(), Unlock(), and WriteLock().


The documentation for this class was generated from the following files:
Generated on Mon Dec 7 15:38:39 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:24:26 2009 by modify_doxy.py rev. 173732