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

Search Toolkit Book for CBDB_CacheIReader

+ Inheritance diagram for CBDB_CacheIReader:
+ Collaboration diagram for CBDB_CacheIReader:

Public Member Functions

 CBDB_CacheIReader (CBDB_Cache &bdb_cache, CNcbiIfstream *overflow_file, CBDB_Cache::TBlobLock &blob_lock)
 
 CBDB_CacheIReader (CBDB_Cache &bdb_cache, CBDB_RawFile::TBuffer *raw_buffer, CBDB_Cache::TBlobLock &blob_lock)
 
virtual ~CBDB_CacheIReader ()
 
virtual ERW_Result Read (void *buf, size_t count, size_t *bytes_read)
 Read as many as "count" bytes into a buffer pointed to by the "buf" argument. More...
 
virtual ERW_Result PendingCount (size_t *count)
 Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that are ready to be read from the input device without blocking. More...
 
- Public Member Functions inherited from IReader
virtual ERW_Result Pushback (const void *buf, size_t count, void *del_ptr=0)
 This method gets called by RStream buffer destructor to return buffered yet still unread (from the stream) portion of data back to the device. More...
 
virtual ~IReader ()
 

Private Member Functions

 CBDB_CacheIReader (const CBDB_CacheIReader &)
 
CBDB_CacheIReaderoperator= (const CBDB_CacheIReader &)
 

Private Attributes

CBDB_Cachem_Cache
 
CNcbiIfstreamm_OverflowFile
 
CBDB_RawFile::TBufferm_RawBuffer
 
unsigned char * m_BufferPtr
 
size_t m_BufferSize
 
CBDB_Cache::TBlobLock m_BlobLock
 

Detailed Description

Definition at line 121 of file bdb_blobcache.cpp.

Constructor & Destructor Documentation

◆ CBDB_CacheIReader() [1/3]

CBDB_CacheIReader::CBDB_CacheIReader ( CBDB_Cache bdb_cache,
CNcbiIfstream overflow_file,
CBDB_Cache::TBlobLock blob_lock 
)
inline

Definition at line 124 of file bdb_blobcache.cpp.

References m_BlobLock, and CLockVectorGuard< TLockVect >::TakeFrom().

◆ CBDB_CacheIReader() [2/3]

CBDB_CacheIReader::CBDB_CacheIReader ( CBDB_Cache bdb_cache,
CBDB_RawFile::TBuffer raw_buffer,
CBDB_Cache::TBlobLock blob_lock 
)
inline

Definition at line 136 of file bdb_blobcache.cpp.

References m_BlobLock, and CLockVectorGuard< TLockVect >::TakeFrom().

◆ ~CBDB_CacheIReader()

virtual CBDB_CacheIReader::~CBDB_CacheIReader ( )
inlinevirtual

Definition at line 149 of file bdb_blobcache.cpp.

References ERR_POST, m_BufferSize, m_OverflowFile, and m_RawBuffer.

◆ CBDB_CacheIReader() [3/3]

CBDB_CacheIReader::CBDB_CacheIReader ( const CBDB_CacheIReader )
private

Member Function Documentation

◆ operator=()

CBDB_CacheIReader& CBDB_CacheIReader::operator= ( const CBDB_CacheIReader )
private

◆ PendingCount()

virtual ERW_Result CBDB_CacheIReader::PendingCount ( size_t *  count)
inlinevirtual

Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that are ready to be read from the input device without blocking.

Return eRW_Success if the number of pending bytes has been stored at the location pointed to by "count". Return eRW_NotImplemented if the number cannot be determined. Otherwise, return other eRW_... condition to reflect the problem ("*count" does not need to be updated in the case of non-eRW_Success). Note that if reporting 0 bytes ready, the method may return either both eRW_Success and zero "*count", or return eRW_NotImplemented alone.

Implements IReader.

Definition at line 204 of file bdb_blobcache.cpp.

References eRW_Error, eRW_Success, m_BufferSize, m_OverflowFile, and m_RawBuffer.

◆ Read()

virtual ERW_Result CBDB_CacheIReader::Read ( void *  buf,
size_t  count,
size_t *  bytes_read 
)
inlinevirtual

Read as many as "count" bytes into a buffer pointed to by the "buf" argument.

Always store the number of bytes actually read (0 if read none) via the pointer "bytes_read", if provided non-NULL. Return non-eRW_Success code if EOF / error condition has been encountered during the operation (some data may have been read, nevertheless, and reflected in "*bytes_read"). Special case: if "count" is passed as 0, then the value of "buf" must be ignored, and no change should be made to the state of the input device (but may return non-eRW_Success to indicate that the input device has already been in an error condition).

Note
Apparently, may not return eRW_Success if hasn't been able to read "count" bytes as requested, and "bytes_read" was provided as NULL.
When returning "*bytes_read" as zero for a non-zero "count" requested, the return status should not indicate eRW_Success.
Warning
"*bytes_read" may never be returned greater than "count".
Attention
It is implementation-dependent whether the call blocks until the entire buffer is read or the call returns when at least some data are available. In general, it is advised that this call is made within a loop that checks for EOF condition and proceeds with the reading until the required amount of data has been retrieved.

Implements IReader.

Definition at line 171 of file bdb_blobcache.cpp.

References buf, eRW_Eof, eRW_Success, m_BufferPtr, m_BufferSize, m_OverflowFile, m_RawBuffer, and min().

Member Data Documentation

◆ m_BlobLock

CBDB_Cache::TBlobLock CBDB_CacheIReader::m_BlobLock
private

Definition at line 229 of file bdb_blobcache.cpp.

Referenced by CBDB_CacheIReader().

◆ m_BufferPtr

unsigned char* CBDB_CacheIReader::m_BufferPtr
private

Definition at line 227 of file bdb_blobcache.cpp.

Referenced by Read().

◆ m_BufferSize

size_t CBDB_CacheIReader::m_BufferSize
private

Definition at line 228 of file bdb_blobcache.cpp.

Referenced by PendingCount(), Read(), and ~CBDB_CacheIReader().

◆ m_Cache

CBDB_Cache& CBDB_CacheIReader::m_Cache
private

Definition at line 224 of file bdb_blobcache.cpp.

◆ m_OverflowFile

CNcbiIfstream* CBDB_CacheIReader::m_OverflowFile
private

Definition at line 225 of file bdb_blobcache.cpp.

Referenced by PendingCount(), Read(), and ~CBDB_CacheIReader().

◆ m_RawBuffer

CBDB_RawFile::TBuffer* CBDB_CacheIReader::m_RawBuffer
private

Definition at line 226 of file bdb_blobcache.cpp.

Referenced by PendingCount(), Read(), and ~CBDB_CacheIReader().


The documentation for this class was generated from the following file:
Modified on Fri Apr 12 17:15:27 2024 by modify_doxy.py rev. 669887