Public Types | Public Member Functions

base::SharedMemory Class Reference

A class for operation on a (one) shared memory segment. More...

#include <libppbase/base/SharedMemory.h>

Inheritance diagram for base::SharedMemory:
base::SynchronizedSharedMemory

List of all members.

Public Types

enum  openFlags { ofCreate = 0x01, ofExclusive = 0x02 }
 

Open flags for open().

More...

Public Member Functions

 SharedMemory ()
 Creates an empty object.
 ~SharedMemory ()
 Unmaps the shared memory segment if it is still mapped.
void close ()
 Closes the shared memory segment.
void destroy ()
 Destroys the shared memory segment.
void * getAddr () const
 Gets the start address of the shared memory segment in this process.
void * map (bool rw=true, void *addr=NULL)
 Maps the shared memory segment into the address space of this process.
void open (const char *name, unsigned size, int flags=0)
 Opens or creates a shared memory segment.
void unmap ()
 Unmaps the shared memory segment.

Detailed Description

A class for operation on a (one) shared memory segment.

Author:
Christoph Schwarz
Version:
$Id: SharedMemory.h 21 2010-09-05 04:18:17Z cschwarz1 $

Member Enumeration Documentation

Open flags for open().

Enumerator:
ofCreate 

create segment (if it does not exist)

ofExclusive 

when specified with ofCreate, force creation and fail if segment already exists


Member Function Documentation

void base::SharedMemory::destroy (  ) 

Destroys the shared memory segment.

Under Linux you must explicitly destroy a shared memory segment with this method. Windows destroys a shared memory segment when there are no more open handles to it, so this method does nothing.

Reimplemented in base::SynchronizedSharedMemory.

void* base::SharedMemory::getAddr (  )  const

Gets the start address of the shared memory segment in this process.

Returns:
NULL if the segment has not been mapped
void* base::SharedMemory::map ( bool  rw = true,
void *  addr = NULL 
)

Maps the shared memory segment into the address space of this process.

Parameters:
rw true to map read-write, false to map read-only
addr hint address
Returns:
start address of the shared memory segment in this process
void base::SharedMemory::open ( const char *  name,
unsigned  size,
int  flags = 0 
)

Opens or creates a shared memory segment.

Parameters:
name the segment name, must be an integer in string form under Linux
size size of the segment in bytes
flags open flags

Reimplemented in base::SynchronizedSharedMemory.


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