ucc::NamedObject Class Reference
A linked object base class with members found by name.
More...
#include <linked.h>
Public Member Functions |
NamedObject * | getNext (void) const |
| Get next effective object when iterating.
|
char * | getId (void) const |
| Get the named id string of this object.
|
virtual bool | compare (const char *name) const |
| Compare the name of our object to see if equal.
|
bool | operator== (const char *name) const |
| Comparison operator between our name and a string.
|
bool | operator!= (const char *name) const |
| Comparison operator between our name and a string.
|
Static Public Member Functions |
static void | purge (NamedObject **hash, unsigned size) |
| Purge a hash indexed table of named objects.
|
static NamedObject ** | index (NamedObject **hash, unsigned size) |
| Convert a hash index into a linear object pointer array.
|
static unsigned | count (NamedObject **hash, unsigned size) |
| Count the total named objects in a hash table.
|
static NamedObject * | find (NamedObject *root, const char *name) |
| Find a named object from a simple list.
|
static NamedObject * | map (NamedObject **hash, const char *name, unsigned size) |
| Find a named object through a hash map table.
|
static NamedObject * | skip (NamedObject **hash, NamedObject *current, unsigned size) |
| Iterate through a hash map table.
|
static unsigned | keyindex (const char *name, unsigned size) |
| Internal function to convert a name to a hash index number.
|
static NamedObject ** | sort (NamedObject **list, size_t count=0) |
| Sort an array of named objects in alphabetical order.
|
Protected Member Functions |
| NamedObject () |
| Create an empty unnamed cell object.
|
| NamedObject (NamedObject **hash, char *name, unsigned size=1) |
| Create a named object and add to hash indexed list.
|
| NamedObject (OrderedIndex *index, char *name) |
| Created a named object on an ordered list.
|
| ~NamedObject () |
| Destroy named object.
|
virtual void | clearId (void) |
| The behavior of clearing id's can be overriden if they are not assigned as strdup's from the heap.
|
Protected Attributes |
char * | id |
Detailed Description
A linked object base class with members found by name.
This class is used to help form named option lists and other forms of name indexed associative data structures. The id is assumed to be passed from a dupped or dynamically allocated string. If a constant string is used then you must not call delete for this object.
Named objects are either listed on an ordered list or keyed through an associate hash map table. When using a hash table, the name id string is used to determine the slot number to use in a list of n sized linked object lists. Hence, a hash index refers to a specific sized array of object indexes.
- Author:
- David Sugar <dyfet@gnutelephony.org>
Definition at line 336 of file linked.h.
Constructor & Destructor Documentation
ucc::NamedObject::NamedObject |
( |
NamedObject ** |
hash, |
|
|
char * |
name, |
|
|
unsigned |
size = 1 | |
|
) |
| | [protected] |
Create a named object and add to hash indexed list.
- Parameters:
-
| hash | map table to list node on. |
| name | of the object we are listing. |
| size | of hash map table used. |
ucc::NamedObject::NamedObject |
( |
OrderedIndex * |
index, |
|
|
char * |
name | |
|
) |
| | [protected] |
Created a named object on an ordered list.
This is commonly used to form attribute lists.
- Parameters:
-
| index | to list object on. |
| name | of the object we are listing. |
ucc::NamedObject::~NamedObject |
( |
|
) |
[protected] |
Destroy named object.
We do not always destroy named objects, since we may use them in reusable pools or we may initialize a list that we keep permenantly. If we do invoke delete for something based on NamedObject, then be aware the object id is assumed to be formed from a dup'd string which will also be freed unless clearId is overriden.
Member Function Documentation
virtual void ucc::NamedObject::clearId |
( |
void |
|
) |
[protected, virtual] |
The behavior of clearing id's can be overriden if they are not assigned as strdup's from the heap.
..
virtual bool ucc::NamedObject::compare |
( |
const char * |
name |
) |
const [virtual] |
Compare the name of our object to see if equal.
This is a virtual so that it can be overriden when using named lists or hash lookups that must be case insensitive.
- Parameters:
-
| name | to compare our name to. |
- Returns:
- true if effectivily equal.
static unsigned ucc::NamedObject::count |
( |
NamedObject ** |
hash, |
|
|
unsigned |
size | |
|
) |
| | [static] |
Count the total named objects in a hash table.
- Parameters:
-
| hash | map table of objects to index. |
| size | of hash map table used. |
Find a named object from a simple list.
This may also use the begin() member of an ordered index of named objects.
- Parameters:
-
| root | node of named object list. |
| name | of object to find. |
- Returns:
- object pointer or NULL if not found.
char* ucc::NamedObject::getId |
( |
void |
|
) |
const [inline] |
Get the named id string of this object.
- Returns:
- name id.
Definition at line 455 of file linked.h.
NamedObject* ucc::NamedObject::getNext |
( |
void |
|
) |
const [inline] |
Get next effective object when iterating.
- Returns:
- next linked object in list.
Reimplemented from ucc::OrderedObject.
Definition at line 448 of file linked.h.
Convert a hash index into a linear object pointer array.
The object pointer array is created from the heap and must be deleted when no longer used.
- Parameters:
-
| hash | map table of objects to index. |
| size | of hash map table used. |
- Returns:
- array of named object pointers.
static unsigned ucc::NamedObject::keyindex |
( |
const char * |
name, |
|
|
unsigned |
size | |
|
) |
| | [static] |
Internal function to convert a name to a hash index number.
- Parameters:
-
| name | to convert into index. |
| size | of map table. |
Find a named object through a hash map table.
- Parameters:
-
| hash | map table of objects to search. |
| name | of object to find. |
| size | of hash map table. |
bool ucc::NamedObject::operator!= |
( |
const char * |
name |
) |
const [inline] |
Comparison operator between our name and a string.
- Parameters:
-
- Returns:
- true if not equal.
Definition at line 480 of file linked.h.
bool ucc::NamedObject::operator== |
( |
const char * |
name |
) |
const [inline] |
Comparison operator between our name and a string.
- Parameters:
-
- Returns:
- true if equal.
Definition at line 472 of file linked.h.
static void ucc::NamedObject::purge |
( |
NamedObject ** |
hash, |
|
|
unsigned |
size | |
|
) |
| | [static] |
Purge a hash indexed table of named objects.
- Parameters:
-
| hash | map table to purge. |
| size | of hash map table used. |
Iterate through a hash map table.
- Parameters:
-
| hash | map table to iterate. |
| current | named object we iterated or NULL to find start of list. |
| size | of map table. |
- Returns:
- next named object in hash map or NULL if no more objects.
Sort an array of named objects in alphabetical order.
This would typically be used to sort a list created and returned by index().
- Parameters:
-
| list | of named objects to sort. |
| count | of objects in the list or 0 to find by NULL pointer. |
- Returns:
- list in sorted order.
The documentation for this class was generated from the following file: