NCBI C++ ToolKit
|
Search Toolkit Book for CLDS2_Manager
Class for managing LDS2 database and related data files. More...
#include <objtools/lds2/lds2.hpp>
Public Types | |
enum | EDirMode { eDir_NoRecurse , eDir_Recurse } |
Directory parsing mode while indexing files. More... | |
enum | EGBReleaseMode { eGB_Ignore , eGB_Guess , eGB_Force } |
Control indexing of GB releases (bioseq-sets). More... | |
enum | EDuplicateIdMode { eDuplicate_Skip , eDuplicate_Store , eDuplicate_Throw } |
Control seq-id conflict resolving during file parsing. More... | |
enum | EErrorMode { eError_Silent , eError_Report , eError_Throw } |
Error handling while indexing files. More... | |
Public Types inherited from CObject | |
enum | EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern } |
Control filling of newly allocated memory. More... | |
typedef CObjectCounterLocker | TLockerType |
Default locker type for CRef. More... | |
typedef atomic< Uint8 > | TCounter |
Counter type is CAtomiCounter. More... | |
typedef Uint8 | TCount |
Alias for value type of counter. More... | |
Public Member Functions | |
CLDS2_Manager (const string &db_file) | |
Create LDS2 manager for the specified db file. More... | |
virtual | ~CLDS2_Manager (void) |
const string & | GetDbFile (void) const |
Get currently selected database name. More... | |
CLDS2_Database * | GetDatabase (void) |
Get the current database object. More... | |
void | SetDbFile (const string &db_file) |
Select new database. More... | |
void | AddDataFile (const string &data_file) |
Add new data file to the list. More... | |
void | AddDataDir (const string &data_dir, EDirMode mode=eDir_Recurse) |
Add data directory. More... | |
void | RegisterUrlHandler (CLDS2_UrlHandler_Base *handler) |
Register a URL handler. More... | |
void | AddDataUrl (const string &url, const string &handler_name) |
Add a URL. More... | |
void | ResetData (void) |
Remove all data from the database. More... | |
void | UpdateData (void) |
Rescan all indexed files, check for modifications, update the database. More... | |
EGBReleaseMode | GetGBReleaseMode (void) const |
void | SetGBReleaseMode (EGBReleaseMode mode) |
EDuplicateIdMode | GetDuplicateIdMode (void) const |
void | SetDuplicateIdMode (EDuplicateIdMode mode) |
int | GetSeqAlignGroupSize (void) const |
Control grouping of standalone seq-aligns into bigger blobs. More... | |
void | SetSeqAlignGroupSize (int sz) |
EErrorMode | GetErrorMode (void) const |
void | SetErrorMode (EErrorMode mode) |
CFastaReader::TFlags | GetFastaFlags (void) const |
Fasta reader settings. More... | |
void | SetFastaFlags (CFastaReader::TFlags flags) |
Public Member Functions inherited from CObject | |
CObject (void) | |
Constructor. More... | |
CObject (const CObject &src) | |
Copy constructor. More... | |
virtual | ~CObject (void) |
Destructor. More... | |
CObject & | operator= (const CObject &src) THROWS_NONE |
Assignment operator. More... | |
bool | CanBeDeleted (void) const THROWS_NONE |
Check if object can be deleted. More... | |
bool | IsAllocatedInPool (void) const THROWS_NONE |
Check if object is allocated in memory pool (not system heap) More... | |
bool | Referenced (void) const THROWS_NONE |
Check if object is referenced. More... | |
bool | ReferencedOnlyOnce (void) const THROWS_NONE |
Check if object is referenced only once. More... | |
void | AddReference (void) const |
Add reference to object. More... | |
void | RemoveReference (void) const |
Remove reference to object. More... | |
void | ReleaseReference (void) const |
Remove reference without deleting object. More... | |
virtual void | DoNotDeleteThisObject (void) |
Mark this object as not allocated in heap – do not delete this object. More... | |
virtual void | DoDeleteThisObject (void) |
Mark this object as allocated in heap – object can be deleted. More... | |
void * | operator new (size_t size) |
Define new operator for memory allocation. More... | |
void * | operator new[] (size_t size) |
Define new[] operator for 'array' memory allocation. More... | |
void | operator delete (void *ptr) |
Define delete operator for memory deallocation. More... | |
void | operator delete[] (void *ptr) |
Define delete[] operator for memory deallocation. More... | |
void * | operator new (size_t size, void *place) |
Define new operator. More... | |
void | operator delete (void *ptr, void *place) |
Define delete operator. More... | |
void * | operator new (size_t size, CObjectMemoryPool *place) |
Define new operator using memory pool. More... | |
void | operator delete (void *ptr, CObjectMemoryPool *place) |
Define delete operator. More... | |
virtual void | DebugDump (CDebugDumpContext ddc, unsigned int depth) const |
Define method for dumping debug information. More... | |
Public Member Functions inherited from CDebugDumpable | |
CDebugDumpable (void) | |
virtual | ~CDebugDumpable (void) |
void | DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const |
void | DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const |
void | DumpToConsole (void) const |
Private Types | |
typedef CLDS2_Database::TStringSet | TFiles |
typedef map< string, CRef< CLDS2_UrlHandler_Base > > | THandlers |
typedef map< string, string > | THandlersByUrl |
Private Member Functions | |
bool | x_IsGZipFile (const SLDS2_File &file_info) |
CLDS2_UrlHandler_Base * | x_GetUrlHandler (const SLDS2_File &file_info) |
SLDS2_File | x_GetFileInfo (const string &file_name, CRef< CLDS2_UrlHandler_Base > &handler) |
void | x_ParseFile (const SLDS2_File &info, CLDS2_UrlHandler_Base &handler) |
Additional Inherited Members | |
Static Public Member Functions inherited from CObject | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (void) |
Define method to throw null pointer exception. More... | |
static NCBI_XNCBI_EXPORT void | ThrowNullPointerException (const type_info &type) |
static EAllocFillMode | GetAllocFillMode (void) |
static void | SetAllocFillMode (EAllocFillMode mode) |
static void | SetAllocFillMode (const string &value) |
Set mode from configuration parameter value. More... | |
Static Public Member Functions inherited from CDebugDumpable | |
static void | EnableDebugDump (bool on) |
Static Public Attributes inherited from CObject | |
static const TCount | eCounterBitsCanBeDeleted = 1 << 0 |
Define possible object states. More... | |
static const TCount | eCounterBitsInPlainHeap = 1 << 1 |
Heap signature was found. More... | |
static const TCount | eCounterBitsPlaceMask |
Mask for 'in heap' state flags. More... | |
static const int | eCounterStep = 1 << 2 |
Skip over the "in heap" bits. More... | |
static const TCount | eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2) |
Minimal value for valid objects (reference counter is zero) Must be a single bit value. More... | |
static const TCount | eCounterStateMask |
Valid object, and object in heap. More... | |
Protected Member Functions inherited from CObject | |
virtual void | DeleteThis (void) |
Virtual method "deleting" this object. More... | |
|
private |
|
private |
|
private |
Control seq-id conflict resolving during file parsing.
Error handling while indexing files.
NOTE: Only a few kinds of errors can be ignored (unsupported file format or object type, broken data file etc.).
Enumerator | |
---|---|
eError_Silent | Try to ignore errors, continue indexing. |
eError_Report | Print error messages, but do not fail (default). |
eError_Throw | Throw exceptions on errors. |
Create LDS2 manager for the specified db file.
If the file does not exist, it will be created only after adding at least one data file and indexing it.
Definition at line 879 of file lds2.cpp.
References RegisterUrlHandler(), and SetDbFile().
void CLDS2_Manager::AddDataDir | ( | const string & | data_dir, |
EDirMode | mode = eDir_Recurse |
||
) |
Add data directory.
All files in the directory are added to the list. If the mode is eDir_Recurse, also adds all subdirectories. Call UpdateData to parse and index the files.
Definition at line 930 of file lds2.cpp.
References AddDataFile(), eDir_Recurse, CDir::fIgnoreRecursive, CDir::GetEntries(), CDirEntry::GetPath(), CDirEntry::IsDir(), CDirEntry::IsFile(), and ITERATE.
Referenced by CSplignApp::Run(), CLDS2IndexerApplication::Run(), and CDemoApp::Run().
Add new data file to the list.
This will not parse and index the new file - call UpdateData().
Definition at line 923 of file lds2.cpp.
References CDirEntry::CreateAbsolutePath(), set< Key, Compare >::insert(), and m_Files.
Referenced by AddDataDir().
Add a URL.
The handler is used to access the URL and must be registered in the manager before adding the URL.
Definition at line 1192 of file lds2.cpp.
References set< Key, Compare >::insert(), m_Files, and m_HandlersByUrl.
|
inline |
Get the current database object.
Definition at line 59 of file lds2.hpp.
Referenced by CLDS2IndexerApplication::Run().
Get currently selected database name.
Definition at line 176 of file lds2.hpp.
References _ASSERT, CLDS2_Database::GetDbFile(), and m_Db.
|
inline |
Definition at line 119 of file lds2.hpp.
Referenced by CLDS2_ObjectParser::EndBlob().
|
inline |
|
inline |
|
inline |
|
inline |
void CLDS2_Manager::RegisterUrlHandler | ( | CLDS2_UrlHandler_Base * | handler | ) |
Register a URL handler.
Using handlers allows to use special storage types like compressed files, ftp or http locations etc. The same handler must be registered in the data loader when using LDS2 to fetch data. The default handlers "file" and "gzipfile" for local files are registered automatically.
Definition at line 902 of file lds2.cpp.
References _ASSERT, m_Handlers, and Ref().
Referenced by CLDS2_Manager().
void CLDS2_Manager::ResetData | ( | void | ) |
Remove all data from the database.
Definition at line 916 of file lds2.cpp.
References set< Key, Compare >::clear(), CLDS2_Database::Create(), m_Db, and m_Files.
Select new database.
If the database does not yet exist, it is not created immediately. The list of data files is cleared.
Definition at line 909 of file lds2.cpp.
References set< Key, Compare >::clear(), m_Db, m_Files, and CRef< C, Locker >::Reset().
Referenced by CLDS2_Manager().
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 106 of file lds2.hpp.
Referenced by CLDS2IndexerApplication::Run().
|
inline |
Definition at line 126 of file lds2.hpp.
Referenced by CLDS2IndexerApplication::Run().
void CLDS2_Manager::UpdateData | ( | void | ) |
Rescan all indexed files, check for modifications, update the database.
Definition at line 1016 of file lds2.cpp.
References _ASSERT, CLDS2_Database::AddFile(), CLDS2_Database::BeginUpdate(), CLDS2_Database::Create(), CLDS2_Database::DeleteFile(), eError_Report, eError_Throw, CLDS2_Database::EndUpdate(), ERR_POST_X, Error(), CDirEntry::Exists(), SLDS2_File::exists(), SLDS2_File::format, CLDS2_Database::GetDbFile(), CLDS2_Database::GetFileInfo(), CLDS2_Database::GetFileNames(), SLDS2_File::id, IsSupportedFormat(), ITERATE, LDS2_THROW, m_Db, m_ErrorMode, m_Files, CLDS2_Database::Open(), CLDS2_Database::UpdateFile(), x_GetFileInfo(), and x_ParseFile().
Referenced by CSplignApp::Run(), CLDS2IndexerApplication::Run(), and CDemoApp::Run().
|
private |
Definition at line 985 of file lds2.cpp.
References file_name, info, and x_GetUrlHandler().
Referenced by UpdateData().
|
private |
Definition at line 954 of file lds2.cpp.
References eError_Report, eError_Throw, map_checker< Container >::end(), ERR_POST_X, Error(), map_checker< Container >::find(), LDS2_THROW, m_ErrorMode, m_Handlers, m_HandlersByUrl, SLDS2_File::name, NULL, CLDS2_UrlHandler_File::s_GetHandlerName(), CLDS2_UrlHandler_GZipFile::s_GetHandlerName(), and x_IsGZipFile().
Referenced by x_GetFileInfo().
|
private |
Definition at line 946 of file lds2.cpp.
References CFormatGuess::eGZip, CFormatGuess::Format(), in(), and SLDS2_File::name.
Referenced by x_GetUrlHandler().
|
private |
Definition at line 1074 of file lds2.cpp.
References CLDS2_Database::AddBioseq(), CLDS2_Database::AddBlob(), CLDS2_Database::DeleteFile(), CFormatGuess::eBinaryASN, eError_Report, eError_Throw, CFormatGuess::eFasta, ERR_POST_X, SLDS2_Blob::eSeq_entry, CFormatGuess::eTextASN, CFormatGuess::eXml, CSeq_id_Handle::GetHandle(), CBioseq_Base::GetId(), CSeq_entry_Base::GetSeq(), in(), info, set< Key, Compare >::insert(), CSeq_entry_Base::IsSeq(), ITERATE, LDS2_THROW, lr(), m_Db, m_ErrorMode, m_FastaFlags, NcbiStreamposToInt8(), CLDS2_ObjectParser::ParseNext(), CFastaReader::ReadOneSeq(), and Warning().
Referenced by UpdateData().
|
private |
Definition at line 163 of file lds2.hpp.
Referenced by GetDbFile(), ResetData(), SetDbFile(), UpdateData(), and x_ParseFile().
|
private |
|
private |
Definition at line 168 of file lds2.hpp.
Referenced by UpdateData(), x_GetUrlHandler(), and x_ParseFile().
|
private |
Definition at line 169 of file lds2.hpp.
Referenced by x_ParseFile().
|
private |
Definition at line 164 of file lds2.hpp.
Referenced by AddDataFile(), AddDataUrl(), ResetData(), SetDbFile(), and UpdateData().
|
private |
|
private |
Definition at line 170 of file lds2.hpp.
Referenced by RegisterUrlHandler(), and x_GetUrlHandler().
|
private |
Definition at line 165 of file lds2.hpp.
Referenced by AddDataUrl(), and x_GetUrlHandler().