CASToR  3.2
Tomographic Reconstruction (PET/SPECT/CT)
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, Normal,
  SequentialScan, RandomAccess
}
 tweak performance More...
 
enum  MapRange { WholeFile = 0, WholeFile = 0 }
 how much should be mappend More...
 
enum  CacheHint {
  Normal, SequentialScan, RandomAccess, Normal,
  SequentialScan, RandomAccess
}
 tweak performance More...
 
enum  MapRange { WholeFile = 0, 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...
 
 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...
 
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...
 
 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...
 
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 29 of file code/include/datafile/oMemoryMapped.hh.

Member Typedef Documentation

◆ FileHandle [1/2]

typedef int oMemoryMapped::FileHandle
private

define handle

Definition at line 101 of file code/include/datafile/oMemoryMapped.hh.

◆ FileHandle [2/2]

typedef int oMemoryMapped::FileHandle
private

define handle

Definition at line 101 of file include/datafile/oMemoryMapped.hh.

Member Enumeration Documentation

◆ CacheHint [1/2]

tweak performance

Enumerator
Normal 

good overall performance

SequentialScan 

read file only once with few seeks

RandomAccess 

jump around

Normal 

good overall performance

SequentialScan 

read file only once with few seeks

RandomAccess 

jump around

Definition at line 33 of file code/include/datafile/oMemoryMapped.hh.

◆ CacheHint [2/2]

tweak performance

Enumerator
Normal 

good overall performance

SequentialScan 

read file only once with few seeks

RandomAccess 

jump around

Normal 

good overall performance

SequentialScan 

read file only once with few seeks

RandomAccess 

jump around

Definition at line 33 of file include/datafile/oMemoryMapped.hh.

◆ MapRange [1/2]

how much should be mappend

Enumerator
WholeFile 

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

WholeFile 

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

Definition at line 41 of file include/datafile/oMemoryMapped.hh.

◆ MapRange [2/2]

how much should be mappend

Enumerator
WholeFile 

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

WholeFile 

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

Definition at line 41 of file code/include/datafile/oMemoryMapped.hh.

Constructor & Destructor Documentation

◆ oMemoryMapped() [1/6]

oMemoryMapped::oMemoryMapped ( )

do nothing, must use open()

Definition at line 47 of file code/src/datafile/oMemoryMapped.cc.

◆ oMemoryMapped() [2/6]

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

open file, mappedBytes = 0 maps the whole file

Definition at line 66 of file code/src/datafile/oMemoryMapped.cc.

Here is the call graph for this function:

◆ ~oMemoryMapped() [1/2]

oMemoryMapped::~oMemoryMapped ( )

close file (see close() )

Definition at line 86 of file code/src/datafile/oMemoryMapped.cc.

Here is the call graph for this function:

◆ oMemoryMapped() [3/6]

oMemoryMapped::oMemoryMapped ( const oMemoryMapped )
private

don't copy object

◆ oMemoryMapped() [4/6]

oMemoryMapped::oMemoryMapped ( )

do nothing, must use open()

◆ oMemoryMapped() [5/6]

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

open file, mappedBytes = 0 maps the whole file

◆ ~oMemoryMapped() [2/2]

oMemoryMapped::~oMemoryMapped ( )

close file (see close() )

◆ oMemoryMapped() [6/6]

oMemoryMapped::oMemoryMapped ( const oMemoryMapped )
private

don't copy object

Member Function Documentation

◆ at() [1/2]

unsigned char oMemoryMapped::at ( size_t  offset) const

access position, including range checking

Definition at line 258 of file code/src/datafile/oMemoryMapped.cc.

Here is the call graph for this function:

◆ at() [2/2]

unsigned char oMemoryMapped::at ( size_t  offset) const

access position, including range checking

◆ Close() [1/2]

void oMemoryMapped::Close ( )

close file

Definition at line 206 of file code/src/datafile/oMemoryMapped.cc.

Here is the caller graph for this function:

◆ Close() [2/2]

void oMemoryMapped::Close ( )

close file

◆ GetData() [1/2]

const unsigned char* oMemoryMapped::GetData ( ) const

raw access

◆ GetData() [2/2]

const unsigned char * oMemoryMapped::GetData ( ) const

raw access

Definition at line 275 of file code/src/datafile/oMemoryMapped.cc.

Here is the caller graph for this function:

◆ GetPageSize() [1/2]

int oMemoryMapped::GetPageSize ( )
staticprivate

get OS page size (for remap)

Definition at line 420 of file code/src/datafile/oMemoryMapped.cc.

◆ GetPageSize() [2/2]

static int oMemoryMapped::GetPageSize ( )
staticprivate

get OS page size (for remap)

◆ IsValid() [1/2]

bool oMemoryMapped::IsValid ( ) const

true, if file successfully opened

◆ IsValid() [2/2]

bool oMemoryMapped::IsValid ( ) const

true, if file successfully opened

Definition at line 286 of file code/src/datafile/oMemoryMapped.cc.

Here is the caller graph for this function:

◆ mappedSize() [1/2]

size_t oMemoryMapped::mappedSize ( ) const

get number of actually mapped bytes

Definition at line 308 of file code/src/datafile/oMemoryMapped.cc.

◆ mappedSize() [2/2]

size_t oMemoryMapped::mappedSize ( ) const

get number of actually mapped bytes

◆ Open() [1/2]

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 97 of file code/src/datafile/oMemoryMapped.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Open() [2/2]

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

open file, mappedBytes = 0 maps the whole file

◆ operator=() [1/2]

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

don't copy object

◆ operator=() [2/2]

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

don't copy object

◆ operator[]() [1/2]

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

access position, no range checking (faster)

Definition at line 247 of file code/src/datafile/oMemoryMapped.cc.

Here is the caller graph for this function:

◆ operator[]() [2/2]

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

access position, no range checking (faster)

◆ Remap() [1/2]

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 319 of file code/src/datafile/oMemoryMapped.cc.

Here is the caller graph for this function:

◆ Remap() [2/2]

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

◆ size() [1/2]

uint64_t oMemoryMapped::size ( ) const

get file size

◆ size() [2/2]

uint64_t oMemoryMapped::size ( ) const

get file size

Definition at line 297 of file code/src/datafile/oMemoryMapped.cc.

Member Data Documentation

◆ _file

FileHandle oMemoryMapped::_file
private

file handle

Definition at line 105 of file code/include/datafile/oMemoryMapped.hh.

◆ _filename

std::string oMemoryMapped::_filename
private

file name

Definition at line 87 of file code/include/datafile/oMemoryMapped.hh.

◆ _filesize

uint64_t oMemoryMapped::_filesize
private

file size

Definition at line 89 of file code/include/datafile/oMemoryMapped.hh.

◆ _hint

CacheHint oMemoryMapped::_hint
private

caching strategy

Definition at line 91 of file code/include/datafile/oMemoryMapped.hh.

◆ _mappedBytes

size_t oMemoryMapped::_mappedBytes
private

mapped size

Definition at line 93 of file code/include/datafile/oMemoryMapped.hh.

◆ _mappedView

void * oMemoryMapped::_mappedView
private

pointer to the file contents mapped into memory

Definition at line 107 of file code/include/datafile/oMemoryMapped.hh.


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