CMetaRegistry Class Reference

Search Toolkit Book for CMetaRegistry

#include <metareg.hpp>

Collaboration diagram for CMetaRegistry:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 47 of file metareg.hpp.

Public Types

typedef int TFlags
 Binary OR of "EFlags".
typedef IRegistry::TFlags TRegFlags
typedef vector< string > TSearchPath
 Search path for unqualified names.
enum  EFlags { fPrivate = 0x1, fReloadIfChanged = 0x2, fAlwaysReload = 0x6, fKeepContents = 0x8 }
 General flags. More...
enum  ENameStyle { eName_AsIs, eName_Ini, eName_DotRc, eName_RcOrIni = eName_DotRc }
 How to treat filenames. 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)
 Load the configuration file "name".
static bool Reload (const string &path, IRWRegistry &reg, TFlags flags=0, TRegFlags reg_flags=0)
 Reload the configuration file "path".
static const TSearchPathGetSearchPath (void)
static TSearchPathSetSearchPath (void)
static void GetDefaultSearchPath (TSearchPath &path)
 Clears path and substitutes the default search path.

Private Types

typedef map< SKey, size_t > TIndex

Private Member Functions

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

Private Attributes

vector< SEntrym_Contents
TSearchPath m_SearchPath
TIndex m_Index
CMutex m_Mutex

Friends

class CSafeStaticPtr< CMetaRegistry >
struct SEntry

Classes

struct  SEntry
struct  SKey
 Members. More...


Member Typedef Documentation

typedef int CMetaRegistry::TFlags
 

Binary OR of "EFlags".

Definition at line 59 of file metareg.hpp.

typedef map<SKey, size_t> CMetaRegistry::TIndex [private]
 

Definition at line 193 of file metareg.hpp.

typedef IRegistry::TFlags CMetaRegistry::TRegFlags
 

Definition at line 74 of file metareg.hpp.

typedef vector<string> CMetaRegistry::TSearchPath
 

Search path for unqualified names.

Definition at line 143 of file metareg.hpp.


Member Enumeration Documentation

enum CMetaRegistry::EFlags
 

General flags.

Enumerator:
fPrivate  Do not cache, or support automatic saving.
fReloadIfChanged  Reload if time or size has changed.
fAlwaysReload  Reload unconditionally.
fKeepContents  Keep existing contents when reloading.

Definition at line 53 of file metareg.hpp.

enum CMetaRegistry::ENameStyle
 

How to treat filenames.

Enumerator:
eName_AsIs  Take the specified filename as is.
eName_Ini  Add .ini, dropping existing extensions as needed.
eName_DotRc  Transform into .

*rc

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

Definition at line 62 of file metareg.hpp.


Constructor & Destructor Documentation

CMetaRegistry::CMetaRegistry  )  [inline, private]
 

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

Definition at line 236 of file metareg.hpp.

References GetDefaultSearchPath(), and x_SetSearchPath().

CMetaRegistry::~CMetaRegistry  )  [private]
 

Definition at line 127 of file metareg.cpp.


Member Function Documentation

void CMetaRegistry::GetDefaultSearchPath TSearchPath path  )  [static]
 

Clears path and substitutes the default search path.

If the environment 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.

Definition at line 308 of file metareg.cpp.

References CDir::GetHome().

Referenced by CMetaRegistry().

const CMetaRegistry::TSearchPath & CMetaRegistry::GetSearchPath void   )  [inline, static]
 

Definition at line 222 of file metareg.hpp.

References Instance(), and x_GetSearchPath().

Referenced by BOOST_AUTO_TEST_CASE().

CMetaRegistry & CMetaRegistry::Instance void   )  [static]
 

Definition at line 121 of file metareg.cpp.

References s_Instance.

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

static SEntry CMetaRegistry::Load const string &  name,
ENameStyle  style = eName_AsIs,
TFlags  flags = 0,
TRegFlags  reg_flags = 0,
IRWRegistry reg = 0
[static]
 

Load the configuration file "name".

Parameters:
name The name of the configuration file to look for. If it does not contain a path, Load() searches in the default path list.
style How, if at all, to modify "name".
flags Any relevant options from EFlags above.
reg If NULL, yield a new CNcbiRegistry. Otherwise, populate the supplied registry (and don't try to share it if it didn't start out empty).
Returns:
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.

Referenced by BlastFindMatrixPath(), CAutoNcbiConfigFile::CAutoNcbiConfigFile(), FindBlastDbPath(), CSeqDBAtlas::GenerateSearchPath(), CNcbiRegistry::IncludeNcbircIfAllowed(), CNcbiApplication::LoadConfig(), CNcbiRegistry::x_Init(), and x_Reload().

bool CMetaRegistry::Reload const string &  path,
IRWRegistry reg,
TFlags  flags = 0,
TRegFlags  reg_flags = 0
[inline, static]
 

Reload the configuration file "path".

Parameters:
path A path (ideally absolute) to the configuration file to read.
reg The registry to repopulate.
flags Any relevant options from EFlags above.
reg_flags Flags to use when parsing the registry; ignored if the registry was already cached.
Returns:
TRUE if a reload actually occurred.

Definition at line 213 of file metareg.hpp.

References Instance(), and x_Reload().

Referenced by CNcbiApplication::ReloadConfig().

CMetaRegistry::TSearchPath & CMetaRegistry::SetSearchPath void   )  [inline, static]
 

Definition at line 229 of file metareg.hpp.

References Instance(), and x_SetSearchPath().

Referenced by BOOST_AUTO_TEST_CASE().

const TSearchPath& CMetaRegistry::x_GetSearchPath void   )  const [inline, private]
 

Definition at line 178 of file metareg.hpp.

References m_SearchPath.

Referenced by GetSearchPath().

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

name0 and style0 are the originally requested name and style

bool CMetaRegistry::x_Reload const string &  path,
IRWRegistry reg,
TFlags  flags,
TRegFlags  reg_flags
[private]
 

Definition at line 288 of file metareg.cpp.

References _ASSERT, eName_AsIs, CRef< C, Locker >::IsNull(), Load(), m_Contents, NON_CONST_ITERATE, CMetaRegistry::SEntry::registry, and CMetaRegistry::SEntry::Reload().

Referenced by Reload().

TSearchPath& CMetaRegistry::x_SetSearchPath void   )  [inline, private]
 

Definition at line 179 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

friend class CSafeStaticPtr< CMetaRegistry > [friend]
 

Definition at line 201 of file metareg.hpp.

friend struct SEntry [friend]
 

Definition at line 202 of file metareg.hpp.


Member Data Documentation

vector<SEntry> CMetaRegistry::m_Contents [private]
 

Definition at line 195 of file metareg.hpp.

Referenced by x_Reload().

TIndex CMetaRegistry::m_Index [private]
 

Definition at line 197 of file metareg.hpp.

Referenced by x_SetSearchPath().

CMutex CMetaRegistry::m_Mutex [private]
 

Definition at line 199 of file metareg.hpp.

Referenced by x_SetSearchPath().

TSearchPath CMetaRegistry::m_SearchPath [private]
 

Definition at line 196 of file metareg.hpp.

Referenced by x_GetSearchPath(), and x_SetSearchPath().


The documentation for this class was generated from the following files:
Generated on Wed Dec 9 08:02:30 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Wed Dec 09 08:19:28 2009 by modify_doxy.py rev. 173732