ACE_Mem_Map Class Reference

C++ interface OS memory mapping system call. More...

#include <Mem_Map.h>

List of all members.

Public Member Functions

 ACE_Mem_Map (void)
 Default constructor.
 ACE_Mem_Map (ACE_HANDLE handle, size_t length=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0)
 ACE_Mem_Map (const ACE_TCHAR *filename, size_t length=static_cast< size_t >(-1), int flags=O_RDWR|O_CREAT, mode_t mode=ACE_DEFAULT_FILE_PERMS, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0)
 Map a file specified by file_name.
int map (ACE_HANDLE handle, size_t length=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0)
int map (size_t length=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0)
 Remap the file associated with <handle_>.
int map (const ACE_TCHAR *filename, size_t length=static_cast< size_t >(-1), int flags=O_RDWR|O_CREAT, mode_t mode=ACE_DEFAULT_FILE_PERMS, int prot=PROT_RDWR, int share=ACE_MAP_PRIVATE, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0)
 Map a file specified by filename.
 ~ACE_Mem_Map (void)
 Destructor.
int open (const ACE_TCHAR *filename, int flags=O_RDWR|O_CREAT, mode_t perms=ACE_DEFAULT_FILE_PERMS, LPSECURITY_ATTRIBUTES sa=0)
 Open the file without mapping it.
int close (void)
 Close down the <handle_> if necessary and unmap the mapping.
int close_handle (void)
 Close down the <handle_> if necessary.
int close_filemapping_handle (void)
int operator() (void *&addr)
void * addr (void) const
 Return the base address.
size_t size (void) const
int unmap (ssize_t len=-1)
 Unmap the region starting at <base_addr_>.
int unmap (void *addr, ssize_t len)
 Unmap the region starting at <addr_>.
int sync (size_t len, int flags=MS_SYNC)
int sync (int flags=MS_SYNC)
int sync (void *addr, size_t len, int flags=MS_SYNC)
int protect (size_t len, int prot=PROT_RDWR)
int protect (int prot=PROT_RDWR)
int protect (void *addr, size_t len, int prot=PROT_RDWR)
int remove (void)
 Close and remove the file from the file system.
int advise (int behavior, int len=-1)
 Hook into the underlying VM system.
ACE_HANDLE handle (void) const
 Return the underlying <handle_>.
const ACE_TCHARfilename (void) const
 Return the name of file that is mapped (if any).
void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Member Functions

int map_it (ACE_HANDLE handle, size_t len=static_cast< size_t >(-1), int prot=PROT_RDWR, int share=MAP_SHARED, void *addr=0, ACE_OFF_T offset=0, LPSECURITY_ATTRIBUTES sa=0)
 ACE_Mem_Map (const ACE_Mem_Map &)
void operator= (const ACE_Mem_Map &)

Private Attributes

void * base_addr_
 Base address of the memory-mapped file.
ACE_TCHAR filename_ [MAXPATHLEN+1]
 Name of the file that is mapped.
size_t length_
 Length of the mapping.
ACE_HANDLE handle_
 HANDLE for the open file.
ACE_HANDLE file_mapping_
 HANDLE for the open mapping.
bool close_handle_


Detailed Description

C++ interface OS memory mapping system call.

This class works with both the mmap(2) UNIX system and the Win32 family of memory mapping system calls.


Constructor & Destructor Documentation

ACE_Mem_Map::ACE_Mem_Map ( void   ) 

Default constructor.

ACE_Mem_Map::ACE_Mem_Map ( ACE_HANDLE  handle,
size_t  length = static_cast<size_t> (-1),
int  prot = PROT_RDWR,
int  share = ACE_MAP_PRIVATE,
void *  addr = 0,
ACE_OFF_T  offset = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Map a file from an open file descriptor handle. This function will lookup the length of the file if it is not given.

ACE_Mem_Map::ACE_Mem_Map ( const ACE_TCHAR filename,
size_t  length = static_cast<size_t> (-1),
int  flags = O_RDWR | O_CREAT,
mode_t  mode = ACE_DEFAULT_FILE_PERMS,
int  prot = PROT_RDWR,
int  share = ACE_MAP_PRIVATE,
void *  addr = 0,
ACE_OFF_T  offset = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Map a file specified by file_name.

ACE_Mem_Map::~ACE_Mem_Map ( void   ) 

Destructor.

ACE_Mem_Map::ACE_Mem_Map ( const ACE_Mem_Map  )  [private]


Member Function Documentation

void * ACE_Mem_Map::addr ( void   )  const [inline]

Return the base address.

int ACE_Mem_Map::advise ( int  behavior,
int  len = -1 
) [inline]

Hook into the underlying VM system.

int ACE_Mem_Map::close ( void   ) 

Close down the <handle_> if necessary and unmap the mapping.

int ACE_Mem_Map::close_filemapping_handle ( void   )  [inline]

Close down the internal <file_mapping_> if necessary. This is mostly necessary on Win32, which has a different handle for file-mapping kernel object.

int ACE_Mem_Map::close_handle ( void   )  [inline]

Close down the <handle_> if necessary.

void ACE_Mem_Map::dump ( void   )  const

Dump the state of an object.

const ACE_TCHAR * ACE_Mem_Map::filename ( void   )  const [inline]

Return the name of file that is mapped (if any).

ACE_HANDLE ACE_Mem_Map::handle ( void   )  const [inline]

Return the underlying <handle_>.

int ACE_Mem_Map::map ( const ACE_TCHAR filename,
size_t  length = static_cast<size_t> (-1),
int  flags = O_RDWR | O_CREAT,
mode_t  mode = ACE_DEFAULT_FILE_PERMS,
int  prot = PROT_RDWR,
int  share = ACE_MAP_PRIVATE,
void *  addr = 0,
ACE_OFF_T  offset = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Map a file specified by filename.

int ACE_Mem_Map::map ( size_t  length = static_cast<size_t> (-1),
int  prot = PROT_RDWR,
int  share = ACE_MAP_PRIVATE,
void *  addr = 0,
ACE_OFF_T  offset = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
) [inline]

Remap the file associated with <handle_>.

int ACE_Mem_Map::map ( ACE_HANDLE  handle,
size_t  length = static_cast<size_t> (-1),
int  prot = PROT_RDWR,
int  share = ACE_MAP_PRIVATE,
void *  addr = 0,
ACE_OFF_T  offset = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
) [inline]

Map a file from an open file descriptor handle. This function will lookup the length of the file if it is not given.

int ACE_Mem_Map::map_it ( ACE_HANDLE  handle,
size_t  len = static_cast<size_t> (-1),
int  prot = PROT_RDWR,
int  share = MAP_SHARED,
void *  addr = 0,
ACE_OFF_T  offset = 0,
LPSECURITY_ATTRIBUTES  sa = 0 
) [private]

This method does the dirty work of actually calling mmap to map the file into memory.

int ACE_Mem_Map::open ( const ACE_TCHAR filename,
int  flags = O_RDWR | O_CREAT,
mode_t  perms = ACE_DEFAULT_FILE_PERMS,
LPSECURITY_ATTRIBUTES  sa = 0 
)

Open the file without mapping it.

int ACE_Mem_Map::operator() ( void *&  addr  )  [inline]

This operator passes back the starting address of the mapped file.

void ACE_Mem_Map::operator= ( const ACE_Mem_Map  )  [private]

int ACE_Mem_Map::protect ( void *  addr,
size_t  len,
int  prot = PROT_RDWR 
) [inline]

Change the protection of the pages of the mapped region to prot starting at addr up to len bytes.

int ACE_Mem_Map::protect ( int  prot = PROT_RDWR  )  [inline]

Change the protection of all the pages of the mapped region to prot starting at <base_addr_>.

int ACE_Mem_Map::protect ( size_t  len,
int  prot = PROT_RDWR 
) [inline]

Change the protection of the pages of the mapped region to prot starting at <base_addr_> up to len bytes.

int ACE_Mem_Map::remove ( void   ) 

Close and remove the file from the file system.

size_t ACE_Mem_Map::size ( void   )  const [inline]

This function returns the number of bytes currently mapped in the file.

int ACE_Mem_Map::sync ( void *  addr,
size_t  len,
int  flags = MS_SYNC 
) [inline]

Sync len bytes of the memory region to the backing store starting at <addr_>.

int ACE_Mem_Map::sync ( int  flags = MS_SYNC  )  [inline]

Sync the whole memory region to the backing store starting at <base_addr_>.

int ACE_Mem_Map::sync ( size_t  len,
int  flags = MS_SYNC 
) [inline]

Sync len bytes of the memory region to the backing store starting at <base_addr_>. If len == -1 then sync the whole region.

int ACE_Mem_Map::unmap ( void *  addr,
ssize_t  len 
) [inline]

Unmap the region starting at <addr_>.

int ACE_Mem_Map::unmap ( ssize_t  len = -1  )  [inline]

Unmap the region starting at <base_addr_>.


Member Data Documentation

Declare the dynamic allocation hooks.

void* ACE_Mem_Map::base_addr_ [private]

Base address of the memory-mapped file.

Keeps track of whether we need to close the handle. This is set if we opened the file.

ACE_HANDLE ACE_Mem_Map::file_mapping_ [private]

HANDLE for the open mapping.

ACE_TCHAR ACE_Mem_Map::filename_[MAXPATHLEN+1] [private]

Name of the file that is mapped.

ACE_HANDLE ACE_Mem_Map::handle_ [private]

HANDLE for the open file.

size_t ACE_Mem_Map::length_ [private]

Length of the mapping.


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

Generated on Mon Jul 13 16:12:11 2009 for ACE by  doxygen 1.5.8