oasys::MmapFile Class Reference

#include <MmapFile.h>

Inheritance diagram for oasys::MmapFile:

oasys::Logger

List of all members.


Detailed Description

Simple wrapper class for a memory-mapped file that encapsulates the file descriptor and the memory mapping.

Definition at line 30 of file MmapFile.h.


Public Member Functions

 MmapFile (const char *logpath)
 Constructor initializes the object to empty.
virtual ~MmapFile ()
 Destructor unmaps and closes the file.
void * map (const char *filename, int prot, int flags, size_t len=0, off_t offset=0)
 Sets up a file-based mmap.
bool unmap ()
 Unmaps the current mapping (if any).
void * ptr ()
 Accessors.
size_t len ()
 Accessors.

Private Attributes

void * ptr_
 The mmap pointer.
size_t len_
 The length of the mapping.

Constructor & Destructor Documentation

oasys::MmapFile::MmapFile ( const char *  logpath  ) 

Constructor initializes the object to empty.

Definition at line 27 of file MmapFile.cc.

oasys::MmapFile::~MmapFile (  )  [virtual]

Destructor unmaps and closes the file.

Definition at line 35 of file MmapFile.cc.

References ptr_, and unmap().


Member Function Documentation

void * oasys::MmapFile::map ( const char *  filename,
int  prot,
int  flags,
size_t  len = 0,
off_t  offset = 0 
)

Sets up a file-based mmap.

Returns:
the mapping pointer or NULL if there's an error

Definition at line 43 of file MmapFile.cc.

References ASSERT, errno, ExamineDump::f, fd, len_, log_err, oasys::Logger::logpath_, oasys::Logger::logpathf(), oasys::FileIOClient::open(), ptr_, and oasys::FileUtils::size().

Referenced by main().

bool oasys::MmapFile::unmap (  ) 

Unmaps the current mapping (if any).

Returns:
true if successful

Definition at line 89 of file MmapFile.cc.

References ASSERT, errno, len_, log_err, and ptr_.

Referenced by ~MmapFile().

void* oasys::MmapFile::ptr (  )  [inline]

Accessors.

Definition at line 58 of file MmapFile.h.

References ptr_.

size_t oasys::MmapFile::len (  )  [inline]

Accessors.

Definition at line 59 of file MmapFile.h.

References len_.


Member Data Documentation

void* oasys::MmapFile::ptr_ [private]

The mmap pointer.

Definition at line 64 of file MmapFile.h.

Referenced by map(), ptr(), unmap(), and ~MmapFile().

size_t oasys::MmapFile::len_ [private]

The length of the mapping.

Definition at line 67 of file MmapFile.h.

Referenced by len(), map(), and unmap().


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 08:43:52 2007 for DTN Reference Implementation by  doxygen 1.5.3