ace::ContinuousMemoryBlock< _Type > Class Template Reference

ContinuousMemoryBlock is basic MemoryBlock with added functionality to help the concept of "continuous memory" by holding pointers to neighbour blocks. More...

#include <pool.h>

Inherits ace::MemoryBlock< _Type >< _Type >.

List of all members.

Public Member Functions

 ContinuousMemoryBlock (size_t block_size, ContinuousMemoryBlock< _Type > *prev=NULL)
 Constructor creates new block and allocate desired memory for it.
virtual ~ContinuousMemoryBlock (void) throw ()
 Destructor unlinks current block from "continuous memory" and deletes assigned memory.
_Type * shift (const _Type *pointer, intptr_t offset) throw ()
 Returns `pointer` shifted by `offset`.

Private Member Functions

ContinuousMemoryBlock< _Type > * next (void) const throw ()
ContinuousMemoryBlock< _Type > * prev (void) const throw ()
void set_next (ContinuousMemoryBlock< _Type > *next) throw ()
 Sets next block in "continuous memory".
void set_prev (ContinuousMemoryBlock< _Type > *prev) throw ()
 Sets previous block in "continuous memory".

Private Attributes

ContinuousMemoryBlock< _Type > * _prev
 Pointer to previous block in "continuous memory" (NULL for first block within pool).
ContinuousMemoryBlock< _Type > * _next
 Pointer to next block in "continuous memory" (NULL for last block within pool).


Detailed Description

template<class _Type>
class ace::ContinuousMemoryBlock< _Type >

ContinuousMemoryBlock is basic MemoryBlock with added functionality to help the concept of "continuous memory" by holding pointers to neighbour blocks.

The concept of "continuous memory" is simple. Particular blocks are linked together in double-linked list and for the outside world performs as one continuous piece of memory.

Parameters:
_Type Type to be stored within the block.
See also:
ContinuousPool

Definition at line 127 of file pool.h.


Constructor & Destructor Documentation

template<class _Type>
ace::ContinuousMemoryBlock< _Type >::ContinuousMemoryBlock ( size_t  block_size,
ContinuousMemoryBlock< _Type > *  prev = NULL 
) [inline]

Constructor creates new block and allocate desired memory for it.

If predecessor block is given (`prev`), constructor automatically sets this block as `prev`'s successor.

Parameters:
block_size Size of newly allocated memory (in template type units).
prev Pointer to predecessor (default is NULL).
Exceptions:
std::bad_alloc When the memory for block cannot be allocated.

Definition at line 157 of file pool.h.


Member Function Documentation

template<class _Type>
ContinuousMemoryBlock<_Type>* ace::ContinuousMemoryBlock< _Type >::next ( void   )  const throw () [inline, private]

Returns:
Block successor in "continuous memory" or NULL, if block is the last one.

Definition at line 137 of file pool.h.

template<class _Type>
ContinuousMemoryBlock<_Type>* ace::ContinuousMemoryBlock< _Type >::prev ( void   )  const throw () [inline, private]

Returns:
Block predecessor in "continuous memory" or NULL, if block is the first one.

Definition at line 140 of file pool.h.

template<class _Type>
void ace::ContinuousMemoryBlock< _Type >::set_next ( ContinuousMemoryBlock< _Type > *  next  )  throw () [inline, private]

Sets next block in "continuous memory".

Parameters:
next Pointer to successor.

Definition at line 144 of file pool.h.

template<class _Type>
void ace::ContinuousMemoryBlock< _Type >::set_prev ( ContinuousMemoryBlock< _Type > *  prev  )  throw () [inline, private]

Sets previous block in "continuous memory".

Parameters:
prev Pointer to predecessor.

Definition at line 148 of file pool.h.

template<class _Type>
_Type* ace::ContinuousMemoryBlock< _Type >::shift ( const _Type *  pointer,
intptr_t  offset 
) throw () [inline]

Returns `pointer` shifted by `offset`.

The `pointer` must point at already transfered memory of current block, but the offset may shift the `pointer` to point to another block.

Parameters:
pointer Pointer which should be shifted.
offset Shift offset (in stored units).
Returns:
Pointer shifted by offset if it's a valid pointer to "continuous memory", otherwise NULL.

Definition at line 180 of file pool.h.


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

Generated on Mon May 5 00:50:54 2008 for ACE by  doxygen 1.5.5