UCommon
Public Member Functions
ucc::assoc_pointer< T, I, M, P > Class Template Reference

A typed template for using a key association with typed objects. More...

#include <memory.h>

Inheritance diagram for ucc::assoc_pointer< T, I, M, P >:
Inheritance graph
[legend]
Collaboration diagram for ucc::assoc_pointer< T, I, M, P >:
Collaboration graph
[legend]

Public Member Functions

bool assign (char *name, T *pointer)
 Assign a name for a pointer to a typed object.
 assoc_pointer ()
 Construct an associated pointer hash map based on the class template.
bool create (char *name, T *pointer)
 Create a new name in the association table and assign typed object.
unsigned getCount (void)
 Get the count of typed objects stored in our hash map.
unsigned getPages (void)
 Access to number of pages allocated from heap for our associated index pointer.
T * locate (const char *name)
 Lookup a typed object by name.
T * operator() (const char *name)
 Reference a typed object directly by name.
void purge (void)
 Purge the hash map of typed objects.
void remove (char *name)
 Remove a name and typed pointer association.
unsigned utilization (void)
 Access to pager utilization stats.

Detailed Description

template<class T, unsigned I = 177, size_t M = 0, size_t P = 0>
class ucc::assoc_pointer< T, I, M, P >

A typed template for using a key association with typed objects.

This essentially forms a form of "smart pointer" that is a reference to specific typed objects by symbolic name. This is commonly used as for associated indexing of typed objects.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 529 of file memory.h.


Member Function Documentation

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
bool ucc::assoc_pointer< T, I, M, P >::assign ( char *  name,
T *  pointer 
) [inline]

Assign a name for a pointer to a typed object.

If the name exists, it is re-assigned with the new pointer value, otherwise it is created.

Parameters:
nameto assign.
pointerof typed object to assign with name.
Returns:
false if failed because name is too long for managed table.

Definition at line 573 of file memory.h.

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
bool ucc::assoc_pointer< T, I, M, P >::create ( char *  name,
T *  pointer 
) [inline]

Create a new name in the association table and assign typed object.

Parameters:
nameto create.
pointerof typed object to assign with name.
Returns:
false if already exists or name is too long for managed table.

Definition at line 582 of file memory.h.

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
unsigned ucc::assoc_pointer< T, I, M, P >::getCount ( void  ) [inline]

Get the count of typed objects stored in our hash map.

Returns:
typed objects in map.

Reimplemented from ucc::keyassoc.

Definition at line 541 of file memory.h.

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
unsigned ucc::assoc_pointer< T, I, M, P >::getPages ( void  ) [inline]

Access to number of pages allocated from heap for our associated index pointer.

This is needed because we inherit keyassoc privately.

Returns:
count of heap pages used.

Reimplemented from ucc::memalloc.

Definition at line 607 of file memory.h.

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
T* ucc::assoc_pointer< T, I, M, P >::locate ( const char *  name) [inline]

Lookup a typed object by name.

Parameters:
nameof typed object to locate.
Returns:
typed object pointer or NULL if not found.

Reimplemented from ucc::keyassoc.

Definition at line 555 of file memory.h.

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
T* ucc::assoc_pointer< T, I, M, P >::operator() ( const char *  name) [inline]

Reference a typed object directly by name.

Parameters:
nameof typed object to locate.
Returns:
typed object pointer or NULL if not found.

Reimplemented from ucc::keyassoc.

Definition at line 563 of file memory.h.

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
void ucc::assoc_pointer< T, I, M, P >::remove ( char *  name) [inline]

Remove a name and typed pointer association.

If managed key names are used then the memory allocated for the name will be re-used.

Parameters:
nameto remove.

Definition at line 590 of file memory.h.

Here is the call graph for this function:

template<class T , unsigned I = 177, size_t M = 0, size_t P = 0>
unsigned ucc::assoc_pointer< T, I, M, P >::utilization ( void  ) [inline]

Access to pager utilization stats.

This is needed because we inherit keyassoc privately.

Returns:
pager utilization, 0-100.

Reimplemented from ucc::mempager.

Definition at line 598 of file memory.h.


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