CASToR  2.0
Tomographic Reconstruction (PET/SPECT/CT)
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
oMemoryMapped Class Reference

Portable read-only memory mapping (Windows and Linux) More...

#include <oMemoryMapped.hh>

Collaboration diagram for oMemoryMapped:
Collaboration graph

Public Types

enum  CacheHint { Normal, SequentialScan, RandomAccess }
 tweak performance More...
 
enum  MapRange { WholeFile = 0 }
 how much should be mappend More...
 

Public Member Functions

 oMemoryMapped ()
 do nothing, must use open() More...
 
 oMemoryMapped (const std::string &filename, size_t mappedBytes=WholeFile, CacheHint hint=Normal)
 open file, mappedBytes = 0 maps the whole file More...
 
 ~oMemoryMapped ()
 close file (see close() ) More...
 
int Open (const std::string &filename, size_t mappedBytes=WholeFile, CacheHint hint=Normal)
 open file, mappedBytes = 0 maps the whole file More...
 
void Close ()
 close file More...
 
unsigned char operator[] (size_t offset) const
 access position, no range checking (faster) More...
 
unsigned char at (size_t offset) const
 access position, including range checking More...
 
const unsigned char * GetData () const
 raw access More...
 
bool IsValid () const
 true, if file successfully opened More...
 
uint64_t size () const
 get file size More...
 
size_t mappedSize () const
 get number of actually mapped bytes More...
 
int Remap (uint64_t offset, size_t mappedBytes)
 replace mapping by a new one of the same file, offset MUST be a multiple of the page size More...
 

Private Types

typedef int FileHandle
 define handle More...
 

Private Member Functions

 oMemoryMapped (const oMemoryMapped &)
 don't copy object More...
 
oMemoryMappedoperator= (const oMemoryMapped &)
 don't copy object More...
 

Static Private Member Functions

static int GetPageSize ()
 get OS page size (for remap) More...
 

Private Attributes

std::string _filename
 file name More...
 
uint64_t _filesize
 file size More...
 
CacheHint _hint
 caching strategy More...
 
size_t _mappedBytes
 mapped size More...
 
FileHandle _file
 file handle More...
 
void * _mappedView
 pointer to the file contents mapped into memory More...
 

Detailed Description

Portable read-only memory mapping (Windows and Linux)

Filesize limited by size_t, usually 2^32 or 2^64

Definition at line 52 of file oMemoryMapped.hh.

Member Typedef Documentation

typedef int oMemoryMapped::FileHandle
private

define handle

Definition at line 124 of file oMemoryMapped.hh.

Member Enumeration Documentation

tweak performance

Enumerator
Normal 

good overall performance

SequentialScan 

read file only once with few seeks

RandomAccess 

jump around

Definition at line 56 of file oMemoryMapped.hh.

how much should be mappend

Enumerator
WholeFile 

everything ... be careful when file is larger than memory

Definition at line 64 of file oMemoryMapped.hh.

Constructor & Destructor Documentation

oMemoryMapped::oMemoryMapped ( )

do nothing, must use open()

Definition at line 70 of file oMemoryMapped.cc.

oMemoryMapped::oMemoryMapped ( const std::string &  filename,
size_t  mappedBytes = WholeFile,
CacheHint  hint = Normal 
)

open file, mappedBytes = 0 maps the whole file

Definition at line 89 of file oMemoryMapped.cc.

Here is the call graph for this function:

oMemoryMapped::~oMemoryMapped ( )

close file (see close() )

Definition at line 109 of file oMemoryMapped.cc.

Here is the call graph for this function:

oMemoryMapped::oMemoryMapped ( const oMemoryMapped )
private

don't copy object

Member Function Documentation

unsigned char oMemoryMapped::at ( size_t  offset) const

access position, including range checking

Definition at line 279 of file oMemoryMapped.cc.

Here is the call graph for this function:

void oMemoryMapped::Close ( )

close file

Definition at line 227 of file oMemoryMapped.cc.

Here is the caller graph for this function:

const unsigned char * oMemoryMapped::GetData ( ) const

raw access

Definition at line 296 of file oMemoryMapped.cc.

Here is the caller graph for this function:

int oMemoryMapped::GetPageSize ( )
staticprivate

get OS page size (for remap)

Definition at line 439 of file oMemoryMapped.cc.

bool oMemoryMapped::IsValid ( ) const

true, if file successfully opened

Definition at line 307 of file oMemoryMapped.cc.

Here is the caller graph for this function:

size_t oMemoryMapped::mappedSize ( ) const

get number of actually mapped bytes

Definition at line 329 of file oMemoryMapped.cc.

int oMemoryMapped::Open ( const std::string &  filename,
size_t  mappedBytes = WholeFile,
CacheHint  hint = Normal 
)

open file, mappedBytes = 0 maps the whole file

open file

Definition at line 120 of file oMemoryMapped.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

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

don't copy object

unsigned char oMemoryMapped::operator[] ( size_t  offset) const

access position, no range checking (faster)

Definition at line 268 of file oMemoryMapped.cc.

Here is the caller graph for this function:

int oMemoryMapped::Remap ( uint64_t  offset,
size_t  mappedBytes 
)

replace mapping by a new one of the same file, offset MUST be a multiple of the page size

Definition at line 340 of file oMemoryMapped.cc.

Here is the caller graph for this function:

uint64_t oMemoryMapped::size ( ) const

get file size

Definition at line 318 of file oMemoryMapped.cc.

Member Data Documentation

FileHandle oMemoryMapped::_file
private

file handle

Definition at line 128 of file oMemoryMapped.hh.

std::string oMemoryMapped::_filename
private

file name

Definition at line 110 of file oMemoryMapped.hh.

uint64_t oMemoryMapped::_filesize
private

file size

Definition at line 112 of file oMemoryMapped.hh.

CacheHint oMemoryMapped::_hint
private

caching strategy

Definition at line 114 of file oMemoryMapped.hh.

size_t oMemoryMapped::_mappedBytes
private

mapped size

Definition at line 116 of file oMemoryMapped.hh.

void* oMemoryMapped::_mappedView
private

pointer to the file contents mapped into memory

Definition at line 130 of file oMemoryMapped.hh.


The documentation for this class was generated from the following files: