ucc::keyassoc Class Reference

A class to hold memory pointers referenced by string names. More...

#include <memory.h>

Inheritance diagram for ucc::keyassoc:
Inheritance graph
[legend]
Collaboration diagram for ucc::keyassoc:
Collaboration graph
[legend]

Public Member Functions

bool assign (char *name, void *pointer)
 Assign a name to a data pointer.
bool create (char *name, void *pointer)
 Create a new name in the association table and assign it's value.
unsigned getCount (void)
 Get the number of associations we have in our object.
 keyassoc (unsigned indexing=177, size_t max=0, size_t page=0)
 Create a key associated memory pointer table.
void * locate (char *name)
 Lookup the data pointer by the string name given.
void * operator() (char *name)
 Lookup the data pointer of a string by direct operation.
void purge (void)
 Purge all associations and return allocated pages to heap.
void * remove (char *name)
 Remove a name and pointer association.
 ~keyassoc ()
 Destroy association object.

Friends

class keydata

Detailed Description

A class to hold memory pointers referenced by string names.

This is used to form a typeless data pointer that can be associated and referenced by string/logical name. The memory used for forming the string names can itself be managed in reusable memory pools and the entire structure uses it's own private pager heap. This allows new string named pointers to be added and deleted at runtime in a thread- safe manner. This might typically be used as a session id manager or for symbol tables.

Author:
David Sugar <dyfet@gnutelephony.org>

Definition at line 385 of file memory.h.


Constructor & Destructor Documentation

ucc::keyassoc::keyassoc ( unsigned  indexing = 177,
size_t  max = 0,
size_t  page = 0 
)

Create a key associated memory pointer table.

Parameters:
indexing size for hash map.
max size of a string name if names are in reusable managed memory.
page size of memory pager.
ucc::keyassoc::~keyassoc (  ) 

Destroy association object.

Release all pages back to the heap.


Member Function Documentation

bool ucc::keyassoc::assign ( char *  name,
void *  pointer 
)

Assign a name to a data pointer.

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

Parameters:
name to assign.
pointer value to assign with name.
Returns:
false if failed because name is too long for managed table.
bool ucc::keyassoc::create ( char *  name,
void *  pointer 
)

Create a new name in the association table and assign it's value.

Parameters:
name to create.
pointer value to assign with name.
Returns:
false if already exists or name is too long for managed table.
unsigned ucc::keyassoc::getCount ( void   )  [inline]

Get the number of associations we have in our object.

Returns:
number of associations stored.

Reimplemented in ucc::assoc_pointer< T, I, M, P >.

Definition at line 426 of file memory.h.

void* ucc::keyassoc::locate ( char *  name  ) 

Lookup the data pointer by the string name given.

Parameters:
name to lookup.
Returns:
pointer to data or NULL if not found.

Reimplemented in ucc::assoc_pointer< T, I, M, P >.

void* ucc::keyassoc::operator() ( char *  name  )  [inline]

Lookup the data pointer of a string by direct operation.

Parameters:
name to lookup.
Returns:
pointer to data or NULL if not found.

Reimplemented in ucc::assoc_pointer< T, I, M, P >.

Definition at line 434 of file memory.h.

void* ucc::keyassoc::remove ( char *  name  ) 

Remove a name and pointer association.

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

Parameters:
name to remove.
Returns:
pointer value of the name or NULL if not found.

Reimplemented in ucc::assoc_pointer< T, I, M, P >.


The documentation for this class was generated from the following file:
Generated by  doxygen 1.6.2-20100208