ucommon
Public Types | Public Member Functions
ucommon::keypager< T, M > Class Template Reference

A template class for a hash pager. More...

#include <memory.h>

Inheritance diagram for ucommon::keypager< T, M >:
Inheritance graph
[legend]
Collaboration diagram for ucommon::keypager< T, M >:
Collaboration graph
[legend]

Public Types

typedef linked_pointer< T > iterator
 Convenience typedef for iterative pointer.
 

Public Member Functions

T * begin (void) const
 Find first typed object in hash map to iterate. More...
 
unsigned count (void) const
 Count the number of typed objects in our hash map. More...
 
T * get (const char *name) const
 Find a typed object derived from NamedObject in the hash map by name. More...
 
T ** index (void) const
 Convert our hash map into a linear object pointer array. More...
 
 keypager (size_t size)
 Create the object cache. More...
 
T * next (T *current) const
 Find next typed object in hash map for iteration. More...
 
T * operator[] (const char *name) const
 Find a typed object derived from NamedObject in the hash map by name. More...
 
T ** sort (void) const
 Convert our hash map into an alphabetically sorted linear object pointer array. More...
 
bool test (const char *name) const
 Test if a name exists in the pool. More...
 
 ~keypager ()
 Destroy the hash pager by purging the index chains and memory pools.
 
- Public Member Functions inherited from ucommon::mempager
virtual void * _alloc (size_t size)
 Allocate memory from the pager heap. More...
 
virtual void dealloc (void *memory)
 Return memory back to pager heap. More...
 
 mempager (size_t page=0)
 Construct a memory pager. More...
 
void purge (void)
 Purge all allocated memory and heap pages immediately.
 
unsigned utilization (void)
 Determine fragmentation level of acquired heap pages. More...
 
virtual ~mempager ()
 Destroy a memory pager. More...
 
- Public Member Functions inherited from ucommon::memalloc
unsigned max (void) const
 Get the maximum number of pages that are permitted. More...
 
 memalloc (size_t page=0)
 Construct a memory pager. More...
 
unsigned pages (void) const
 Get the number of pages that have been allocated from the real heap. More...
 
void purge (void)
 Purge all allocated memory and heap pages immediately.
 
unsigned size (void) const
 Get the size of a memory page. More...
 
unsigned utilization (void) const
 Determine fragmentation level of acquired heap pages. More...
 
virtual ~memalloc ()
 Destroy a memory pager. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ucommon::mempager
virtual void _lock (void)
 Lock the memory pager mutex. More...
 
virtual void _unlock (void)
 Unlock the memory pager mutex.
 
- Protected Member Functions inherited from ucommon::memalloc
virtual void fault (void) const
 Report runtime memory exhaustion.
 
page_t * pager (void)
 Acquire a new page from the heap. More...
 
- Protected Attributes inherited from ucommon::memalloc
unsigned limit
 

Detailed Description

template<class T, unsigned M = 177>
class ucommon::keypager< T, M >

A template class for a hash pager.

This creates objects from a pager pool when they do not already exist in the hash map.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 1289 of file memory.h.

Constructor & Destructor Documentation

template<class T , unsigned M = 177>
ucommon::keypager< T, M >::keypager ( size_t  size)
inline

Create the object cache.

Parameters
sizeof allocation units.

Definition at line 1299 of file memory.h.

Member Function Documentation

template<class T , unsigned M = 177>
T* ucommon::keypager< T, M >::begin ( void  ) const
inline

Find first typed object in hash map to iterate.

Returns
first typed object or NULL if nothing in list.

Definition at line 1343 of file memory.h.

template<class T , unsigned M = 177>
unsigned ucommon::keypager< T, M >::count ( void  ) const
inline

Count the number of typed objects in our hash map.

Returns
count of typed objects.

Definition at line 1358 of file memory.h.

template<class T , unsigned M = 177>
T* ucommon::keypager< T, M >::get ( const char *  name) const
inline

Find a typed object derived from NamedObject in the hash map by name.

If the object is not found, it is created from the memory pool.

Parameters
nameto search for.
Returns
typed object if found through map or NULL.

Definition at line 1313 of file memory.h.

template<class T , unsigned M = 177>
T** ucommon::keypager< T, M >::index ( void  ) const
inline

Convert our hash map into a linear object pointer array.

The object pointer array is created from the heap and must be deleted when no longer used.

Returns
array of typed named object pointers.

Definition at line 1367 of file memory.h.

template<class T , unsigned M = 177>
T* ucommon::keypager< T, M >::next ( T *  current) const
inline

Find next typed object in hash map for iteration.

Parameters
currenttyped object we are referencing.
Returns
next iterative object or NULL if past end of map.

Definition at line 1351 of file memory.h.

template<class T , unsigned M = 177>
T* ucommon::keypager< T, M >::operator[] ( const char *  name) const
inline

Find a typed object derived from NamedObject in the hash map by name.

If the object is not found, it is created from the pager pool.

Parameters
nameto search for.
Returns
typed object if found through map or NULL.

Definition at line 1336 of file memory.h.

template<class T , unsigned M = 177>
T** ucommon::keypager< T, M >::sort ( void  ) const
inline

Convert our hash map into an alphabetically sorted linear object pointer array.

The object pointer array is created from the heap and must be deleted when no longer used.

Returns
sorted array of typed named object pointers.

Definition at line 1376 of file memory.h.

template<class T , unsigned M = 177>
bool ucommon::keypager< T, M >::test ( const char *  name) const
inline

Test if a name exists in the pool.

Parameters
nameto test.
Returns
true if found.

Definition at line 1327 of file memory.h.


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