NCBI C++ ToolKit
Classes | Public Types | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
CMetaRegistry Class Reference

Search Toolkit Book for CMetaRegistry

#include <corelib/metareg.hpp>

+ Collaboration diagram for CMetaRegistry:


struct  SEntry
struct  SKey
 Members. More...

Public Types

enum  EFlags { fPrivate = 0x1 , fReloadIfChanged = 0x2 , fAlwaysReload = 0x6 , fKeepContents = 0x8 }
 Relevant types. More...
enum  ENameStyle { eName_AsIs , eName_Ini , eName_DotRc , eName_RcOrIni = eName_Ini }
 How to treat filenames. More...
typedef int TFlags
 Binary OR of "EFlags". More...
typedef IRegistry::TFlags TRegFlags
typedef vector< stringTSearchPath
 Search path for unqualified names. More...

Static Public Member Functions

static CMetaRegistryInstance (void)
static SEntry Load (const string &name, ENameStyle style=eName_AsIs, TFlags flags=0, TRegFlags reg_flags=0, IRWRegistry *reg=0, const string &path=kEmptyStr)
 Load the configuration file "name". More...
static bool Reload (const string &path, IRWRegistry &reg, TFlags flags=0, TRegFlags reg_flags=0)
 Reload the configuration file "path". More...
static const TSearchPathGetSearchPath (void)
static TSearchPathSetSearchPath (void)
static void GetDefaultSearchPath (TSearchPath &path)
 Clears path and substitutes the default search path. More...
static string FindRegistry (const string &name, ENameStyle style=eName_AsIs)
 Yield the path to a registry with the given name if available, or the empty string otherwise. More...

Private Types

typedef map< SKey, size_t > TIndex

Private Member Functions

 CMetaRegistry ()
 Private functions, mostly non-static implementations of the public interface. More...
 ~CMetaRegistry ()
const SEntryx_Load (const string &name, ENameStyle style, TFlags flags, TRegFlags reg_flags, IRWRegistry *reg, const string &name0, ENameStyle style0, SEntry &scratch_entry, const string &path)
 name0 and style0 are the originally requested name and style More...
bool x_Reload (const string &path, IRWRegistry &reg, TFlags flags, TRegFlags reg_flags)
const TSearchPathx_GetSearchPath (void) const
TSearchPathx_SetSearchPath (void)
string x_FindRegistry (const string &name, ENameStyle style, const string &path=kEmptyStr)

Private Attributes

vector< SEntrym_Contents
TSearchPath m_SearchPath
TIndex m_Index
CMutex m_Mutex


class CSafeStatic_Allocator< CMetaRegistry >
struct SEntry

Detailed Description

Definition at line 45 of file metareg.hpp.

Member Typedef Documentation

◆ TFlags

Binary OR of "EFlags".

Definition at line 57 of file metareg.hpp.

◆ TIndex

typedef map<SKey, size_t> CMetaRegistry::TIndex

Definition at line 208 of file metareg.hpp.

◆ TRegFlags

Definition at line 72 of file metareg.hpp.

◆ TSearchPath

Search path for unqualified names.

Definition at line 144 of file metareg.hpp.

Member Enumeration Documentation

◆ EFlags

Relevant types.

General flags


Do not cache, or support automatic saving.


Reload if time or size has changed.


Reload unconditionally.


Keep existing contents when reloading.

Definition at line 51 of file metareg.hpp.

◆ ENameStyle

How to treat filenames.


Take the specified filename as is.


Add .ini, dropping existing extensions as needed.


Transform into .



C Toolkit style; mostly useful with name = "ncbi".

Definition at line 60 of file metareg.hpp.

Constructor & Destructor Documentation

◆ CMetaRegistry()

CMetaRegistry::CMetaRegistry ( )

Private functions, mostly non-static implementations of the public interface.

Definition at line 258 of file metareg.hpp.

References GetDefaultSearchPath(), and x_SetSearchPath().

◆ ~CMetaRegistry()

CMetaRegistry::~CMetaRegistry ( )

Definition at line 133 of file metareg.cpp.

Member Function Documentation

◆ FindRegistry()

string CMetaRegistry::FindRegistry ( const string name,
ENameStyle  style = eName_AsIs 

Yield the path to a registry with the given name if available, or the empty string otherwise.

Definition at line 251 of file metareg.hpp.

References Instance(), and x_FindRegistry().

Referenced by CNcbiApplicationAPI::LoadConfig().

◆ GetDefaultSearchPath()

void CMetaRegistry::GetDefaultSearchPath ( CMetaRegistry::TSearchPath path)

Clears path and substitutes the default search path.

If the environment variable NCBI_CONFIG_PATH is set, the default is to look there exclusively; otherwise, the default list contains the following directories in order:

  • The current working directory.
  • The user's home directory.
  • The directory, if any, given by the environment variable "NCBI".
  • The standard system directory (/etc on Unix, and given by the environment variable "SYSTEMROOT" on Windows).
  • The directory containing the application, if known. (Requires use of CNcbiApplication.) The first two directories are skipped if the environment variable NCBI_DONT_USE_LOCAL_CONFIG is set.
NCBI_CONFIG_PATH may contain multiple directories, delimited by semicolons on Windows and either colons or semicolons on other platforms. An empty element anywhere in the path designates the default list that would take effect in the absence of NCBI_CONFIG_PATH, as detailed above.

Definition at line 326 of file metareg.cpp.

References _T_STDSTRING, _TX, eFollowLinks, eIgnoreLinks, CNcbiApplicationAPI::GetArguments(), CDir::GetHome(), CNcbiArguments::GetProgramDirname(), CNcbiApplicationAPI::InstanceGuard(), ITERATE, kConfigPathDelim, kEmptyStr, NcbiSys_getenv, NULL, and NStr::Split().

Referenced by CMetaRegistry().

◆ GetSearchPath()

const CMetaRegistry::TSearchPath & CMetaRegistry::GetSearchPath ( void  )

Definition at line 237 of file metareg.hpp.

References Instance(), and x_GetSearchPath().

◆ Instance()

CMetaRegistry & CMetaRegistry::Instance ( void  )

Definition at line 127 of file metareg.cpp.

References s_Instance.

Referenced by FindRegistry(), GetSearchPath(), Load(), Reload(), and SetSearchPath().

◆ Load()

CMetaRegistry::SEntry CMetaRegistry::Load ( const string name,
CMetaRegistry::ENameStyle  style = eName_AsIs,
CMetaRegistry::TFlags  flags = 0,
TRegFlags  reg_flags = 0,
IRWRegistry reg = 0,
const string path = kEmptyStr 

Load the configuration file "name".

nameThe name of the configuration file to look for. If it does not contain a path, Load() searches in the default path list.
styleHow, if at all, to modify "name".
flagsAny relevant options from EFlags above.
regIf NULL, yield a new CNcbiRegistry. Otherwise, populate the supplied registry (and don't try to share it if it didn't start out empty).
pathOptional directory to search ahead of the default list.
On success, .actual_name will contain the absolute path to the file ultimately loaded, and .registry will point to an IRWRegistry object containing its contents (owned by this class unless fPrivate or fDontOwn was given). On failure, .actual_name will be empty and .registry will be NULL.

Definition at line 139 of file metareg.cpp.

References _ASSERT, CMetaRegistry::SEntry::actual_name, IRWRegistry::AssessImpact(), IRWRegistry::Clear(), IRegistry::Empty(), IRWRegistry::eRead, IRegistry::fJustCore, fKeepContents, flags, fPrivate, CRef< C, Locker >::GetPointer(), Instance(), CCompoundRWRegistry::LoadBaseRegistries(), IRegistry::Modified(), IRWRegistry::Read(), CMetaRegistry::SEntry::registry, CGuard< Resource, Lock, Unlock, ReportExceptions >::Release(), CRef< C, Locker >::Reset(), IRegistry::SetModifiedFlag(), CDirEntry::SplitPath(), str(), IRegistry::Write(), and x_Load().

Referenced by BOOST_AUTO_TEST_CASE(), CNcbiRegistry::IncludeNcbircIfAllowed(), CCompoundRWRegistry::LoadBaseRegistries(), CNcbiApplicationAPI::LoadConfig(), s_LoadConfFile(), CNcbiRegistry::x_Init(), and x_Reload().

◆ Reload()

bool CMetaRegistry::Reload ( const string path,
IRWRegistry reg,
TFlags  flags = 0,
TRegFlags  reg_flags = 0 

Reload the configuration file "path".

pathA path (ideally absolute) to the configuration file to read.
regThe registry to repopulate.
flagsAny relevant options from EFlags above.
reg_flagsFlags to use when parsing the registry; ignored if the registry was already cached.
TRUE if a reload actually occurred.

Definition at line 228 of file metareg.hpp.

References flags, Instance(), and x_Reload().

Referenced by CNcbiApplicationAPI::ReloadConfig().

◆ SetSearchPath()

CMetaRegistry::TSearchPath & CMetaRegistry::SetSearchPath ( void  )

Definition at line 244 of file metareg.hpp.

References Instance(), and x_SetSearchPath().

◆ x_FindRegistry()

string CMetaRegistry::x_FindRegistry ( const string name,
ENameStyle  style,
const string path = kEmptyStr 

◆ x_GetSearchPath()

const TSearchPath& CMetaRegistry::x_GetSearchPath ( void  ) const

Definition at line 190 of file metareg.hpp.

References m_SearchPath.

Referenced by GetSearchPath().

◆ x_Load()

const CMetaRegistry::SEntry & CMetaRegistry::x_Load ( const string name,
CMetaRegistry::ENameStyle  style,
CMetaRegistry::TFlags  flags,
TRegFlags  reg_flags,
IRWRegistry reg,
const string name0,
CMetaRegistry::ENameStyle  style0,
CMetaRegistry::SEntry scratch_entry,
const string path 

◆ x_Reload()

bool CMetaRegistry::x_Reload ( const string path,
IRWRegistry reg,
TFlags  flags,
TRegFlags  reg_flags 

◆ x_SetSearchPath()

TSearchPath& CMetaRegistry::x_SetSearchPath ( void  )

Definition at line 191 of file metareg.hpp.

References map_checker< Container >::clear(), m_Index, m_Mutex, and m_SearchPath.

Referenced by CMetaRegistry(), and SetSearchPath().

Friends And Related Function Documentation

◆ CSafeStatic_Allocator< CMetaRegistry >

friend class CSafeStatic_Allocator< CMetaRegistry >

Definition at line 214 of file metareg.hpp.

◆ SEntry

friend struct SEntry

Definition at line 217 of file metareg.hpp.

Member Data Documentation

◆ m_Contents

vector<SEntry> CMetaRegistry::m_Contents

Definition at line 210 of file metareg.hpp.

Referenced by x_Load(), and x_Reload().

◆ m_Index

TIndex CMetaRegistry::m_Index

Definition at line 212 of file metareg.hpp.

Referenced by x_Load(), and x_SetSearchPath().

◆ m_Mutex

CMutex CMetaRegistry::m_Mutex

Definition at line 214 of file metareg.hpp.

Referenced by x_Load(), and x_SetSearchPath().

◆ m_SearchPath

TSearchPath CMetaRegistry::m_SearchPath

Definition at line 211 of file metareg.hpp.

Referenced by x_FindRegistry(), x_GetSearchPath(), and x_SetSearchPath().

The documentation for this class was generated from the following files:
Modified on Sun Jul 21 04:19:30 2024 by rev. 669887