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

Search Toolkit Book for CMemoryFile

CMemoryFile –. More...

#include <corelib/ncbifile.hpp>

+ Inheritance diagram for CMemoryFile:
+ Collaboration diagram for CMemoryFile:

Public Member Functions

 CMemoryFile (const string &file_name, EMemMapProtect protect_attr=eMMP_Read, EMemMapShare share_attr=eMMS_Shared, TOffsetType offset=0, size_t lendth=0, EOpenMode mode=eDefault, Uint8 max_file_len=0)
 Constructor. More...
 
void * Map (TOffsetType offset=0, size_t length=0)
 Map file. More...
 
bool Unmap (void)
 Unmap file if mapped. More...
 
void * Extend (size_t new_lendth=0)
 Extend length of the mapped region. More...
 
void * GetPtr (void) const
 Get pointer to beginning of data. More...
 
TOffsetType GetOffset (void) const
 Get offset of the mapped area from beginning of the file. More...
 
size_t GetSize (void) const
 Get length of the mapped region. More...
 
bool Flush (void) const
 Flush by writing all modified copies of memory pages to the underlying file. More...
 
bool MemMapAdvise (EMemMapAdvise advise) const
 Advise on memory map usage. More...
 
- Public Member Functions inherited from CMemoryFileMap
 CMemoryFileMap (const string &file_name, EMemMapProtect protect_attr=eMMP_Read, EMemMapShare share_attr=eMMS_Shared, EOpenMode mode=eDefault, Uint8 max_file_len=0)
 Constructor. More...
 
 ~CMemoryFileMap (void)
 Destructor. More...
 
void * Map (TOffsetType offset, size_t length)
 Map file segment. More...
 
bool Unmap (void *ptr)
 Unmap file segment. More...
 
bool UnmapAll (void)
 Unmap all mapped segment. More...
 
TOffsetType GetOffset (void *ptr) const
 Get offset of the mapped segment from beginning of the file. More...
 
size_t GetSize (void *ptr) const
 Get length of the mapped segment. More...
 
Int8 GetFileSize (void) const
 Get length of the mapped file. More...
 
bool Flush (void *ptr) const
 Flush memory mapped file segment. More...
 
const CMemoryFileSegmentGetMemoryFileSegment (void *ptr) const
 Get pointer to memory mapped file segment by pointer to data. More...
 
bool MemMapAdvise (void *ptr, EMemMapAdvise advise) const
 Advise on mapped memory map usage. More...
 
const stringGetFileName () const noexcept
 Shows filename of memory mapped file. More...
 
- Public Member Functions inherited from CMemoryFile_Base
 CMemoryFile_Base (void)
 Constructor. More...
 

Private Member Functions

void x_Verify (void) const
 
 CMemoryFile (const CMemoryFile &)
 
void operator= (const CMemoryFile &)
 

Private Attributes

void * m_Ptr
 Pointer to mapped view of file. More...
 

Additional Inherited Members

- Public Types inherited from CMemoryFile_Base
enum  EMemMapProtect { eMMP_Read , eMMP_Write , eMMP_ReadWrite }
 Which operations are permitted in memory map file. More...
 
enum  EMemMapShare { eMMS_Shared , eMMS_Private }
 Whether to share changes or not. More...
 
enum  EOpenMode { eCreate , eOpen , eExtend , eDefault = eOpen }
 Memory file open mode. More...
 
enum  EMemMapAdvise {
  eMMA_Normal = eMADV_Normal , eMMA_Random = eMADV_Random , eMMA_Sequential = eMADV_Sequential , eMMA_WillNeed = eMADV_WillNeed ,
  eMMA_DontNeed = eMADV_DontNeed , eMMA_DoFork = eMADV_DoFork , eMMA_DontFork = eMADV_DontFork , eMMA_Mergeable = eMADV_Mergeable ,
  eMMA_Unmergeable = eMADV_Unmergeable
}
 What type of data access pattern will be used for mapped region. More...
 
typedef Int8 TOffsetType
 
- Static Public Member Functions inherited from CMemoryFile_Base
static bool IsSupported (void)
 Check if memory-mapping is supported by the C++ Toolkit on this platform. More...
 
static bool MemMapAdviseAddr (void *addr, size_t len, EMemMapAdvise advise)
 Advise on memory map usage for specified region. More...
 
- Protected Types inherited from CMemoryFileMap
typedef map< void *, CMemoryFileSegment * > TSegments
 
- Protected Member Functions inherited from CMemoryFileMap
void x_Open (void)
 Open file mapping for file with name m_FileName. More...
 
void x_Close (void)
 Unmap mapped memory and close mapped file. More...
 
void x_Create (Uint8 size)
 Create new file or rewrite existent with zeros. More...
 
void x_Extend (Uint8 size, Uint8 new_size)
 Extend file size from 'size' to 'new_size' with zero bytes. More...
 
CMemoryFileSegmentx_GetMemoryFileSegment (void *ptr) const
 Get pointer to memory mapped file segment by pointer to data. More...
 
- Protected Attributes inherited from CMemoryFileMap
string m_FileName
 File name. More...
 
SMemoryFileHandlem_Handle
 Memory file handle. More...
 
SMemoryFileAttrsm_Attrs
 Specify operations permitted on memory mapped file and mapping mode. More...
 
TSegments m_Segments
 Map of pointers to mapped segments. More...
 

Detailed Description

CMemoryFile –.

Define class to support file memory mapping.

This is a simple version of the CMemoryFileMap class supporting one mapped segment only.

Note that the file being mapped must exist or can be created/extended. If file size changes after mapping, the effect of references to portions of the mapped region that correspond to added or removed portions of the file is unspecified.

Throws exceptions on errors.

Definition at line 2859 of file ncbifile.hpp.


The documentation for this class was generated from the following files:
Modified on Thu Feb 22 17:10:55 2024 by modify_doxy.py rev. 669887