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

Search Toolkit Book for CMemStore

#include "memory_store.hpp"
(Private to src/dbapi/driver.)

+ Inheritance diagram for CMemStore:
+ Collaboration diagram for CMemStore:

Classes

struct  SMemBlock
 

Public Types

typedef long TSize
 
- Public Types inherited from C_RA_Storage
enum  EWhence { eCurr , eHead , eTail }
 
- 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< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CMemStore ()
 
 CMemStore (size_t block_size)
 
 CMemStore (C_SA_Storage &storage, size_t block_size=2048)
 
 ~CMemStore ()
 
size_t Read (void *buff, size_t nof_bytes)
 
size_t Peek (void *buff, size_t nof_bytes) const
 
size_t PeekAt (void *buff, size_t start, size_t n) const
 
size_t Append (const void *buff, size_t nof_bytes)
 
size_t Write (const void *buff, size_t nof_bytes)
 
size_t Insert (const void *buff, size_t nof_bytes)
 
size_t Delete (size_t nof_bytes=kMax_BlobSize)
 
size_t Truncate (size_t nof_bytes=kMax_BlobSize)
 
void Flush (void)
 
long Seek (long offset, EWhence whence)
 
size_t Tell () const
 
size_t GetDataSize () const
 
- Public Member Functions inherited from C_FA_Storage
virtual ~C_FA_Storage ()
 
- Public Member Functions inherited from C_RA_Storage
virtual ~C_RA_Storage ()
 
- Public Member Functions inherited from C_SA_Storage
virtual ~C_SA_Storage ()
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (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 Member Functions

SMemBlockx_InsertBlock (void)
 
SMemBlockx_AddBlock (void)
 
TSize x_SeekHEAD (TSize offset)
 
TSize x_SeekCURR (TSize offset)
 
TSize x_SeekTAIL (TSize offset)
 
void x_Init (TSize block_size=2048)
 

Private Attributes

TSize m_BlockSize
 
SMemBlockm_First
 
SMemBlockm_Last
 
SMemBlockm_Current
 
TSize m_Pos
 
TSize m_BlockPos
 
TSize m_Size
 

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...
 

Detailed Description

Definition at line 90 of file memory_store.hpp.

Member Typedef Documentation

◆ TSize

typedef long CMemStore::TSize

Definition at line 114 of file memory_store.hpp.

Constructor & Destructor Documentation

◆ CMemStore() [1/3]

CMemStore::CMemStore ( )
inline

Definition at line 93 of file memory_store.hpp.

References x_Init().

◆ CMemStore() [2/3]

CMemStore::CMemStore ( size_t  block_size)
inline

Definition at line 94 of file memory_store.hpp.

References x_Init().

◆ CMemStore() [3/3]

CMemStore::CMemStore ( C_SA_Storage storage,
size_t  block_size = 2048 
)

Definition at line 552 of file memory_store.cpp.

References Append(), kMax_BlobSize, m_BlockSize, n, C_SA_Storage::Read(), and x_Init().

◆ ~CMemStore()

CMemStore::~CMemStore ( )

Member Function Documentation

◆ Append()

size_t CMemStore::Append ( const void *  buff,
size_t  nof_bytes 
)
virtual

◆ Delete()

size_t CMemStore::Delete ( size_t  nof_bytes = kMax_BlobSize)
virtual

◆ Flush()

void CMemStore::Flush ( void  )
inlinevirtual

Implements C_SA_Storage.

Definition at line 109 of file memory_store.hpp.

◆ GetDataSize()

size_t CMemStore::GetDataSize ( void  ) const
inline

Definition at line 112 of file memory_store.hpp.

References m_Size.

Referenced by CDB_Stream::Size(), and CDB_Stream::Truncate().

◆ Insert()

size_t CMemStore::Insert ( const void *  buff,
size_t  nof_bytes 
)
virtual

◆ Peek()

size_t CMemStore::Peek ( void *  buff,
size_t  nof_bytes 
) const

◆ PeekAt()

size_t CMemStore::PeekAt ( void *  buff,
size_t  start,
size_t  n 
) const

◆ Read()

size_t CMemStore::Read ( void *  buff,
size_t  nof_bytes 
)
virtual

◆ Seek()

long CMemStore::Seek ( long  offset,
EWhence  whence 
)
virtual

◆ Tell()

size_t CMemStore::Tell ( void  ) const
inlinevirtual

Implements C_RA_Storage.

Definition at line 111 of file memory_store.hpp.

References m_Pos.

Referenced by CDB_Stream::Assign().

◆ Truncate()

size_t CMemStore::Truncate ( size_t  nof_bytes = kMax_BlobSize)
virtual

◆ Write()

size_t CMemStore::Write ( const void *  buff,
size_t  nof_bytes 
)
virtual

◆ x_AddBlock()

CMemStore::SMemBlock * CMemStore::x_AddBlock ( void  )
private

◆ x_Init()

void CMemStore::x_Init ( TSize  block_size = 2048)
inlineprivate

Definition at line 139 of file memory_store.hpp.

References m_BlockPos, m_BlockSize, m_Current, m_First, m_Last, m_Pos, and m_Size.

Referenced by CMemStore().

◆ x_InsertBlock()

SMemBlock* CMemStore::x_InsertBlock ( void  )
private

◆ x_SeekCURR()

CMemStore::TSize CMemStore::x_SeekCURR ( CMemStore::TSize  offset)
private

◆ x_SeekHEAD()

CMemStore::TSize CMemStore::x_SeekHEAD ( CMemStore::TSize  offset)
private

Definition at line 245 of file memory_store.cpp.

References m_BlockPos, m_Current, m_First, m_Pos, offset, and x_SeekCURR().

Referenced by Seek(), x_SeekCURR(), and x_SeekTAIL().

◆ x_SeekTAIL()

CMemStore::TSize CMemStore::x_SeekTAIL ( CMemStore::TSize  offset)
private

Definition at line 266 of file memory_store.cpp.

References m_BlockPos, m_Current, m_Pos, m_Size, offset, and x_SeekHEAD().

Referenced by Seek(), Write(), and x_SeekCURR().

Member Data Documentation

◆ m_BlockPos

TSize CMemStore::m_BlockPos
private

◆ m_BlockSize

TSize CMemStore::m_BlockSize
private

◆ m_Current

SMemBlock* CMemStore::m_Current
private

◆ m_First

SMemBlock* CMemStore::m_First
private

Definition at line 126 of file memory_store.hpp.

Referenced by Delete(), PeekAt(), Truncate(), x_AddBlock(), x_Init(), and x_SeekHEAD().

◆ m_Last

SMemBlock* CMemStore::m_Last
private

Definition at line 127 of file memory_store.hpp.

Referenced by Append(), Delete(), Insert(), PeekAt(), Seek(), Truncate(), x_AddBlock(), x_Init(), and ~CMemStore().

◆ m_Pos

TSize CMemStore::m_Pos
private

◆ m_Size

TSize CMemStore::m_Size
private

Definition at line 131 of file memory_store.hpp.

Referenced by Append(), Delete(), GetDataSize(), Insert(), PeekAt(), Truncate(), x_Init(), and x_SeekTAIL().


The documentation for this class was generated from the following files:
Modified on Tue Apr 23 07:39:39 2024 by modify_doxy.py rev. 669887