ofstream * seqdb_logfile;
68 extern intseqdb_logclass;
70 voidseqdb_log(
const char* s);
71 voidseqdb_log(
const char* s1,
const string& s2);
73 voidseqdb_log(
intcl,
const char* s);
74 voidseqdb_log(
intcl,
const char* s1,
const string& s2);
75 voidseqdb_log(
intcl,
const char* s1,
ints2);
95 #define INT4IFY_STRING(a) \ 96 (((a[3] & 0xFF) << 24) | \ 97 ((a[2] & 0xFF) << 16) | \ 98 ((a[1] & 0xFF) << 8) | \ 101 #define CLASS_MARKER_FIELD(a) \ 102 static int x_GetClassMark() { return INT4IFY_STRING(a); } \ 103 static string x_GetMarkString() { return string((a a), 4); } \ 107 #define INIT_CLASS_MARK() m_ClassMark = x_GetClassMark() 110 #define CHECK_MARKER() \ 111 if (m_ClassMark != x_GetClassMark()) { \ 112 cout << "Marker="<< m_ClassMark << endl; \
113cout << "GetMrk=" << x_GetClassMark() << endl; \
114cout << "\n!! Broken [" << x_GetMarkString() << "] mark detected.\n" \
115<< "!! Mark is [" << hex << m_ClassMark << "], should be [" \
116<< hex << x_GetClassMark() << "]." << endl; \
117_ASSERT(m_ClassMark == x_GetClassMark()); \
121 #define BREAK_MARKER() m_ClassMark |= 0x20202020; 126 #define CLASS_MARKER_FIELD(a) 129 #define INIT_CLASS_MARK() 132 #define CHECK_MARKER() 135 #define BREAK_MARKER() 206volatile
boolm_Locked;
317 enum{e_MaxFileDescritors = 950};
337 boolDoesFileExist(
const string& fname);
351 returnDoesFileExist(fname.
GetPathS());
366 boolGetFileSize(
const string& fname,
380 boolGetFileSizeL(
const string& fname,
TIndx& length);
391 static voidRetRegion(
const char* datap);
419 static char*
Alloc(
size_tlength,
boolclear =
true);
464 if(m_UseLock && !locked.
m_Locked) {
481 if(m_UseLock && locked.
m_Locked) {
498 Uint8max_slice = e_MaxSlice64;
499 Uint8sliceSize =
min(max_slice,m_MaxFileSize);
513 #if defined(NCBI_OS_UNIX) 537 CMemoryFile* GetMemoryFile(
const string& fileName);
542eFileCounterDecrement
545 CMemoryFile* ReturnMemoryFile(
const string& fileName);
550 caseeFileCounterIncrement:
551m_OpenedFilesCount++;
554 caseeFileCounterDecrement:
555m_OpenedFilesCount--;
561m_MaxOpenedFilesCount =
max(m_MaxOpenedFilesCount,m_OpenedFilesCount);
562 returnm_OpenedFilesCount;
572 const stringexts=
"hd|hi|nd|ni|pd|pi|si|sd|ti|td";
573 stringext = filename.substr(filename.length()-2);
574 if(exts.find(ext) !=
NPOS) {
597 enum{e_MaxSlice64 = 1 << 30};
617m_Atlas.UnregisterExternal(*
this);
700 void Init(
const string& filename) {
702 if(!m_MappedFile || m_Filename != filename)
705m_MappedFile = m_Atlas.ReturnMemoryFile(m_Filename);
708m_Filename = filename;
710m_MappedFile = m_Atlas.GetMemoryFile(m_Filename);
722m_DataPtr = (
char*)(m_MappedFile->GetPtr());
732m_MappedFile = m_Atlas.ReturnMemoryFile(m_Filename);
752 return(
const char*)(m_DataPtr +
offset);
757 return(
const char*)(m_DataPtr +
offset);
static void * Alloc(size_t size)
Guard object for the SeqDBAtlas singleton.
DECLARE_CLASS_STATIC_FAST_MUTEX(m_Lock)
Lock protecting this object's fields.
static int m_Count
Count of users of the CSeqDBAtlas object.
static CSeqDBAtlas * m_Atlas
The CSeqDBAtlas object itself.
CAtlasMappedFile(const string &filename)
int ChangeOpenedFilseCount(EFilesCount fc)
const string GetSearchPath() const
Get BlastDB search path.
Uint8 m_MaxFileSize
Maxium file size.
bool DoesFileExist(const CSeqDB_Path &fname)
Check if file exists.
const string m_SearchPath
BlastDB search path.
static const string GenerateSearchPath()
Generate search path.
std::mutex m_FileMemMapMutex
int m_MaxOpenedFilesCount
Uint8 GetSliceSize()
Get the current slice size.
map< string, unique_ptr< CAtlasMappedFile > > m_FileMemMap
void Lock(CSeqDBLockHold &locked)
Lock the atlas.
CMutex m_Lock
Protects most of the critical regions of the SeqDB library.
bool m_UseLock
Use single atlas lock to protect critical regions.
map< string, pair< bool, TIndx > > m_FileSize
std::mutex m_FileSizeMutex
Cache of file existence and length.
CSeqDBAtlas(const CSeqDBAtlas &)
Private method to prevent copy construction.
CNcbiStreamoff TIndx
The type used for file offsets.
int GetOpenedFilseCount(void)
void Unlock(CSeqDBLockHold &locked)
Unlock the atlas.
CSeqDBFileMemMap(class CSeqDBAtlas &atlas, const string &filename)
Constructor.
const char * GetFileDataPtr(const string &fname, TIndx offset)
Get a pointer to the specified offset.
void Init(const string &filename)
Initializes a memory map object.
void Clear()
Clears the memory mapobject.
CMemoryFile * m_MappedFile
const char * m_DataPtr
Points to the beginning of the data area.
~CSeqDBFileMemMap()
Destructor.
CSeqDBFileMemMap(class CSeqDBAtlas &atlas)
const char * GetFileDataPtr(TIndx offset)
volatile bool m_Locked
If this is true, this thread owns the atlas lock.
CSeqDBLockHold(class CSeqDBAtlas &atlas)
Constructor.
~CSeqDBMemReg()
Destructor.
CSeqDBMemReg(class CSeqDBAtlas &atlas)
Constructor.
CSeqDBMemReg(CSeqDBMemReg &oth)
Private method to prevent copy construction.
class CSeqDBAtlas & m_Atlas
This reference allows unlock on exit.
size_t m_Bytes
This object "owns" this many bytes of the atlas memory bound.
Hold a memory region refcount, return to atlas when destroyed.
CSeqDBAtlas & m_Atlas
Reference to the memory management layer.
const char * m_Ptr
Pointer to this object.
const string & GetPathS() const
Get the path as a string.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
static CNcbiApplicationAPI * Instance(void)
Singleton method.
@ eFollowLinks
Follow symbolic links.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const string & GetMsg(void) const
Get message string.
TErrCode GetErrCode(void) const
static string NormalizePath(const string &path, EFollowLinks follow_links=eIgnoreLinks)
Normalize a path.
static string GetCwd(void)
Get the current working directory.
uint64_t Uint8
8-byte (64-bit) unsigned integer
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
virtual bool HasEntry(const string §ion, const string &name=kEmptyStr, TFlags flags=0) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::streamoff CNcbiStreamoff
Portable alias for streamoff.
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
#define NCBI_XOBJREAD_EXPORT
const TYPE & Get(const CNamedParameterList *param)
Multi-threading â atomic pointer exchange function.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Multi-threading â mutexes; rw-locks; semaphore.
#define INIT_CLASS_MARK()
Marker initializer for constructor.
string SeqDB_MakeOSPath(const string &dbs)
Return path with delimiters changed to platform preferred kind.
#define CLASS_MARKER_FIELD(a)
CSeqDBAtlas::TIndx TIndx
Index file.
This file defines several SeqDB utility functions related to byte order and file system portability.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4