NCBI C++ ToolKit
Public Types | Public Member Functions | Private Attributes | List of all members
CSeqDBRawFile Class Reference

Search Toolkit Book for CSeqDBRawFile

Raw file. More...

#include <objtools/blast/seqdb_reader/impl/seqdbfile.hpp>

+ Collaboration diagram for CSeqDBRawFile:

Public Types

typedef CSeqDBAtlas::TIndx TIndx
 Type which spans possible file offsets. More...
 

Public Member Functions

 CSeqDBRawFile (CSeqDBAtlas &atlas)
 Constructor. More...
 
bool Open (const CSeqDB_Path &name)
 MMap or Open a file. More...
 
const char * GetFileDataPtr (CSeqDBFileMemMap &lease, TIndx start, TIndx end) const
 Get a pointer to a section of the file. More...
 
TIndx GetFileLength () const
 Get the length of the file. More...
 
TIndx ReadSwapped (CSeqDBFileMemMap &lease, TIndx offset, Uint4 *value) const
 Read a four byte numerical object from the file. More...
 
TIndx ReadSwapped (CSeqDBFileMemMap &lease, TIndx offset, Uint8 *value) const
 Read an eight byte numerical object from the file. More...
 
TIndx ReadSwapped (CSeqDBFileMemMap &lease, TIndx offset, string *value) const
 Read a string object from the file. More...
 
void ReadBytes (CSeqDBFileMemMap &lease, char *buf, TIndx start, TIndx end) const
 Read part of the file into a buffer. More...
 

Private Attributes

CSeqDBAtlasm_Atlas
 The memory management layer object. More...
 
string m_FileName
 The name of this file. More...
 
TIndx m_Length
 The length of this file. More...
 

Detailed Description

Raw file.

This is the lowest level of SeqDB file object. It controls basic (byte data) access to the file, isolating higher levels from differences in handling mmapped vs opened files. This has mostly become a thin wrapper around the Atlas functionality.

Definition at line 64 of file seqdbfile.hpp.

Member Typedef Documentation

◆ TIndx

Type which spans possible file offsets.

Definition at line 67 of file seqdbfile.hpp.

Constructor & Destructor Documentation

◆ CSeqDBRawFile()

CSeqDBRawFile::CSeqDBRawFile ( CSeqDBAtlas atlas)
inline

Constructor.

Builds a "raw" file object, which is the lowest level of the SeqDB file objects. It provides byte swapping and reading methods, which are implemented via the atlas layer.

Parameters
atlasThe memory management layer object.

Definition at line 77 of file seqdbfile.hpp.

Member Function Documentation

◆ GetFileDataPtr()

const char* CSeqDBRawFile::GetFileDataPtr ( CSeqDBFileMemMap lease,
TIndx  start,
TIndx  end 
) const
inline

Get a pointer to a section of the file.

This method insures that the memory lease has a hold that includes the requested section of the file, and returns a pointer to the start offset.

Parameters
leaseThe memory lease object for this file.
startThe starting offset for the first byte of the region.
endThe offset for the first byte after the region.
lockedThe lock holder object for this thread.
Returns
A pointer to the file data at the start offset.

Definition at line 123 of file seqdbfile.hpp.

References _ASSERT, CSeqDBFileMemMap::GetFileDataPtr(), m_FileName, m_Length, and SEQDB_FILE_ASSERT.

Referenced by CSeqDBGiMask::GetMaskData(), CSeqDBOIDList::x_GetOidMask(), and CSeqDBGiMask::x_ReadFields().

◆ GetFileLength()

TIndx CSeqDBRawFile::GetFileLength ( ) const
inline

Get the length of the file.

The file length is returned as a four byte integer, which is the current maximum size for the blastdb component files.

Returns
The length of the file.

Definition at line 143 of file seqdbfile.hpp.

References m_Length.

Referenced by CSeqDBOIDList::x_GetOidMask(), CSeqDBColumn::x_ReadFields(), and CSeqDBGiMask::x_ReadFields().

◆ Open()

bool CSeqDBRawFile::Open ( const CSeqDB_Path name)
inline

MMap or Open a file.

This serves to verify the existence of, open, and cache the length of a file.

Parameters
nameThe filename to open.
lockedThe lock holder object for this thread.
Returns
true if the file was opened successfully.

Definition at line 93 of file seqdbfile.hpp.

References _ASSERT, CSeqDBAtlas::GetFileSizeL(), CSeqDB_Path::GetPathS(), m_Atlas, m_FileName, m_Length, and CSeqDB_Path::Valid().

Referenced by CSeqDBColumn::CSeqDBColumn(), CSeqDBExtFile::CSeqDBExtFile(), CSeqDBOIDList::x_GetOidMask(), and CSeqDBGiMask::x_Open().

◆ ReadBytes()

void CSeqDBRawFile::ReadBytes ( CSeqDBFileMemMap lease,
char *  buf,
TIndx  start,
TIndx  end 
) const
inline

Read part of the file into a buffer.

Copy the file data from offsets start to end into the array at buf, which is assumed to already have been allocated. This method assumes the atlas lock is held.

Parameters
leaseA memory lease object to use for the read.
bufThe destination for the data to be read.
startThe starting offset for the first byte to read.
endThe offset for the first byte after the area to read.

Definition at line 922 of file seqdbfile.hpp.

References buf, CSeqDBFileMemMap::GetFileDataPtr(), and m_FileName.

Referenced by CSeqDBExtFile::x_ReadBytes().

◆ ReadSwapped() [1/3]

TIndx CSeqDBRawFile::ReadSwapped ( CSeqDBFileMemMap lease,
TIndx  offset,
string value 
) const

Read a string object from the file.

Given a pointer to a string object, this reads a string value for it from the file. The data in the file is assumed to be a four byte length in network byte order, followed by the bytes of the string. The amount of data is this length + 4.

Parameters
leaseA memory lease object to use for the read.
offsetThe starting offset of the string length in the file.
valueA pointer to the returned string.
lockedThe lock holder object for this thread.
Returns
The offset of the first byte after the string.

Definition at line 91 of file seqdbfile.cpp.

References CSeqDBFileMemMap::GetFileDataPtr(), int, len, m_FileName, offset, SeqDB_GetStdOrd(), and rapidjson::value.

◆ ReadSwapped() [2/3]

TIndx CSeqDBRawFile::ReadSwapped ( CSeqDBFileMemMap lease,
TIndx  offset,
Uint4 value 
) const

Read a four byte numerical object from the file.

Given a pointer to an object in memory, this reads a numerical value for it from the file. The data in the file is assumed to be in network byte order, and the user version in the local default byte order (host order). The size of the object is taken as sizeof(Uint4).

Parameters
leaseA memory lease object to use for the read.
offsetThe starting offset of the value in the file.
valueA pointer to the object.
Thelock holder object for this thread.
Returns
The offset of the first byte after the object.

Definition at line 71 of file seqdbfile.cpp.

References CSeqDBFileMemMap::GetFileDataPtr(), m_FileName, offset, SeqDB_GetStdOrd(), and rapidjson::value.

Referenced by CSeqDBOIDList::x_GetOidMask(), and CSeqDBExtFile::x_ReadSwapped().

◆ ReadSwapped() [3/3]

TIndx CSeqDBRawFile::ReadSwapped ( CSeqDBFileMemMap lease,
TIndx  offset,
Uint8 value 
) const

Read an eight byte numerical object from the file.

Given a pointer to an object in memory, this reads a numerical value for it from the file. The data in the file is assumed to be in network byte order, and the user version in the local default byte order (host order). The size of the object is taken as sizeof(Uint8).

Parameters
leaseA memory lease object to use for the read.
offsetThe starting offset of the value in the file.
valueA pointer to the object.
lockedThe lock holder object for this thread.
Returns
The offset of the first byte after the object.

Definition at line 81 of file seqdbfile.cpp.

References CSeqDBFileMemMap::GetFileDataPtr(), m_FileName, offset, SeqDB_GetBroken(), and rapidjson::value.

Member Data Documentation

◆ m_Atlas

CSeqDBAtlas& CSeqDBRawFile::m_Atlas
private

The memory management layer object.

Definition at line 237 of file seqdbfile.hpp.

Referenced by Open().

◆ m_FileName

string CSeqDBRawFile::m_FileName
private

The name of this file.

Definition at line 240 of file seqdbfile.hpp.

Referenced by GetFileDataPtr(), Open(), ReadBytes(), and ReadSwapped().

◆ m_Length

TIndx CSeqDBRawFile::m_Length
private

The length of this file.

Definition at line 243 of file seqdbfile.hpp.

Referenced by GetFileDataPtr(), GetFileLength(), and Open().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:48 2024 by modify_doxy.py rev. 669887