An encapsulation of a block of memory that can be mapped by one or more (not necessarily related) processes; when one process changes the data in the block, the changes are immediately visible to the other processes. More...
#include <SharedMemoryBlock.h++>


Public Member Functions | |
| SharedMemoryBlock (const String &name, size_t size, const Permissions &perm=Permissions::USER_READ_WRITE) | |
| Construct a new SharedMemoryBlock. | |
| ~SharedMemoryBlock () throw () | |
| Destructor. | |
| void | attach (bool readOnly=false) throw (SystemException) |
| Attach to the memory block, creating it if it does not yet exist. | |
| void | detach () throw () |
| Detach from the memory block, and destroy it if no other process currently has it mapped. | |
| virtual void | setBase (byte_t *base) throw () |
| Overridden to have no effect. | |
| virtual void | setSize (size_t size) throw () |
| Overridden to have no effect. | |
| String | getName () const |
| Get the name of the memory block. | |
| void | zero () throw () |
| Zero the memory block. | |
| void | fill (byte_t value) throw () |
| Fill the memory block with the given byte value. | |
| byte_t * | getBase () throw () |
| Get a pointer to the beginning of the memory block. | |
| const byte_t * | getBase () const throw () |
| Get a pointer to the beginning of the memory block. | |
| size_t | getSize () const throw () |
| Get the size of the memory block. | |
| bool | operator== (const MemoryBlock &other) const throw () |
| Equality operator. | |
| bool | operator!= (const MemoryBlock &other) const throw () |
| Inequality operator. | |
| byte_t | operator[] (uint_t index) const throw (OutOfBoundsException) |
| Bounds-checked access. | |
| byte_t & | operator[] (uint_t index) throw (OutOfBoundsException) |
| Bounds-checked access. | |
| bool | copyFrom (const MemoryBlock &other) throw () |
| Copy data from another memory block to this one. | |
| void | moveFrom (MemoryBlock &other) throw () |
| Copy data from another (possibly overlapping) memory block to this one. | |
| int | indexOf (byte_t val, uint_t startIndex=0) const throw () |
| Find the first occurrence of a given byte value in the memory block, starting at a given index. | |
| bool | operator! () const throw () |
| Test if the base of the block is NULL. | |
Protected Attributes | |
| byte_t * | _base |
| A pointer to the beginning of the memory block. | |
| size_t | _size |
| The size of the memory block, in bytes. | |
An encapsulation of a block of memory that can be mapped by one or more (not necessarily related) processes; when one process changes the data in the block, the changes are immediately visible to the other processes.
| SharedMemoryBlock | ( | const String & | name, | |
| size_t | size, | |||
| const Permissions & | perm = Permissions::USER_READ_WRITE | |||
| ) |
Construct a new SharedMemoryBlock.
The actual memory segment is not created and mapped until a call to attach() is made.
| name | The name of the memory block. For maximal portability, the name should consist of at most 14 alphanumeric characters and should not contain slashes. | |
| size | The size of the memory block, in bytes. This size will be rounded up to the nearest multiple of the system page size. | |
| perm | The permissions with which to create the memory block, if it does not exist at the time of the attach(). |
| ~SharedMemoryBlock | ( | ) | throw () |
Destructor.
Detaches from the memory block.
| void attach | ( | bool | readOnly = false |
) | throw (SystemException) |
Attach to the memory block, creating it if it does not yet exist.
| readOnly | A flag indicating whether the memory block should be mapped for read-only access or read-write access. |
| SystemException | If the operation fails. |
| bool copyFrom | ( | const MemoryBlock & | other | ) | throw () [inherited] |
Copy data from another memory block to this one.
The number of bytes copied is the minimum of the sizes of the two blocks. The blocks may not overlap.
| other | The block to copy from. |
| void detach | ( | ) | throw () |
Detach from the memory block, and destroy it if no other process currently has it mapped.
| void fill | ( | byte_t | value | ) | throw () [inherited] |
Fill the memory block with the given byte value.
| const byte_t* getBase | ( | ) | const throw () [inline, inherited] |
Get a pointer to the beginning of the memory block.
| byte_t* getBase | ( | ) | throw () [inline, inherited] |
Get a pointer to the beginning of the memory block.
| String getName | ( | ) | const [inline] |
Get the name of the memory block.
| size_t getSize | ( | ) | const throw () [inline, inherited] |
Get the size of the memory block.
Find the first occurrence of a given byte value in the memory block, starting at a given index.
| val | The value to search for. | |
| startIndex | The index to begin searching at. |
| void moveFrom | ( | MemoryBlock & | other | ) | throw () [inherited] |
Copy data from another (possibly overlapping) memory block to this one.
The number of bytes copied is the minimum of the sizes of the two blocks.
| other | The block to copy from. Note that the copy may result in both blocks being modified, if the source area overlaps the target area. |
| bool operator! | ( | ) | const throw () [inline, inherited] |
Test if the base of the block is NULL.
| bool operator!= | ( | const MemoryBlock & | other | ) | const throw () [inline, inherited] |
Inequality operator.
| bool operator== | ( | const MemoryBlock & | other | ) | const throw () [inherited] |
Equality operator.
| byte_t & operator[] | ( | uint_t | index | ) | throw (OutOfBoundsException) [inherited] |
Bounds-checked access.
| byte_t operator[] | ( | uint_t | index | ) | const throw (OutOfBoundsException) [inherited] |
Bounds-checked access.
| void setBase | ( | byte_t * | base | ) | throw () [virtual] |
Overridden to have no effect.
Reimplemented from MemoryBlock.
| void setSize | ( | size_t | size | ) | throw () [virtual] |
Overridden to have no effect.
Reimplemented from MemoryBlock.
| void zero | ( | ) | throw () [inline, inherited] |
Zero the memory block.
size_t _size [protected, inherited] |
The size of the memory block, in bytes.
1.6.3