UCommon
|
A class to hold memory pointers referenced by string names. More...
#include <memory.h>
Public Member Functions | |
bool | assign (const char *name, void *pointer) |
Assign a name to a data pointer. | |
unsigned | count (void) const |
Get the number of associations we have in our object. | |
bool | create (const char *name, void *pointer) |
Create a new name in the association table and assign it's value. | |
keyassoc (unsigned indexing=177, size_t max=0, size_t page=0) | |
Create a key associated memory pointer table. | |
void * | locate (const char *name) |
Lookup the data pointer by the string name given. | |
void * | operator() (const 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 (const char *name) |
Remove a name and pointer association. | |
~keyassoc () | |
Destroy association object. | |
Protected Member Functions | |
void * | allocate (const char *name, size_t size) |
Allocate object stored in pager also. | |
Friends | |
class | keydata |
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.
ucommon::keyassoc::keyassoc | ( | unsigned | indexing = 177 , |
size_t | max = 0 , |
||
size_t | page = 0 |
||
) |
Create a key associated memory pointer table.
indexing | size for hash map. |
max | size of a string name if names are in reusable managed memory. |
page | size of memory pager. |
Destroy association object.
Release all pages back to the heap.
void* ucommon::keyassoc::allocate | ( | const char * | name, |
size_t | size | ||
) | [protected] |
Allocate object stored in pager also.
name | of object entry. |
size | of object to allocate. |
bool ucommon::keyassoc::assign | ( | const 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.
name | to assign. |
pointer | value to assign with name. |
unsigned ucommon::keyassoc::count | ( | void | ) | const [inline] |
Get the number of associations we have in our object.
Reimplemented in ucommon::assoc_pointer< T, I, M, P >.
bool ucommon::keyassoc::create | ( | const char * | name, |
void * | pointer | ||
) |
Create a new name in the association table and assign it's value.
name | to create. |
pointer | value to assign with name. |
void* ucommon::keyassoc::locate | ( | const char * | name | ) |
Lookup the data pointer by the string name given.
name | to lookup. |
Reimplemented in ucommon::assoc_pointer< T, I, M, P >.
void* ucommon::keyassoc::operator() | ( | const char * | name | ) | [inline] |
Lookup the data pointer of a string by direct operation.
name | to lookup. |
Reimplemented in ucommon::assoc_pointer< T, I, M, P >.
void* ucommon::keyassoc::remove | ( | const 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.
name | to remove. |