A map table allows for entities to be mapped (hash index) onto it.
More...
#include <object.h>
Inheritance diagram for MapTable:
Collaboration diagram for MapTable:
Public Member Functions
Create a map table with a specified number of slots.
More...
Destroy the table, calls cleanup.
More...
virtual unsigned
getIndex (const char *id)
Get index value from id string.
More...
Return range of this table.
More...
Return the number of object stored in this table.
More...
Lookup an object by id key.
More...
Map an object to our table.
More...
Get the first element into table, it is returned as void * for easy re-cast.
More...
Get the last element into table, it is returned as void * for easy re-cast.
More...
Get table's end, useful for cycle control; it is returned as void * for easy re-cast.
More...
Get next object from managed free list.
More...
Add an object to the managed free list.
More...
An operator to map an object to the table.
More...
This operator is virtual in case it must also add the object to a managed free list.
More...
Enable setting of mutex name for deadlock debug.
More...
Entering a
Mutex locks the mutex for the current thread.
More...
Future abi will use enter/leave/test members.
More...
Future abi will use enter/leave/test members.
More...
Future abi will use enter/leave/test members.
More...
Tries to lock the mutex for the current thread.
More...
Leaving a mutex frees that mutex for use by another thread.
More...
Static Public Member Functions
Enable or disable deadlock debugging.
More...
Protected Member Functions
Protected Attributes
Friends
Detailed Description
A map table allows for entities to be mapped (hash index) onto it.
Unlike with Assoc, This form of map table also allows objects to be removed from the table. This table also includes a mutex lock for thread safety. A free list is also optionally maintained for reusable maps.
- Author
- David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org Table to hold hash indexed objects.
Definition at line 335 of file object.h.
Constructor & Destructor Documentation
MapTable::MapTable
(
unsigned
size )
Create a map table with a specified number of slots.
- Parameters
-
number of slots.
virtual MapTable::~MapTable
(
)
virtual
Destroy the table, calls cleanup.
Member Function Documentation
Add an object to the managed free list.
Some MapObject's may override delete operator to detach and do this.
- Parameters
-
object to add.
Map an object to our table.
If it is in another table already, it is removed there first.
- Parameters
-
object to map.
void MapTable::cleanup
(
void
)
protected
void Mutex::enter
(
void
)
inlineinherited
Future abi will use enter/leave/test members.
Definition at line 263 of file thread.h.
void Mutex::enterMutex
(
void
)
inherited
Entering a Mutex locks the mutex for the current thread.
This also can be done using the ENTER_CRITICAL macro or by using the ++ operator on a mutex.
- See Also
- leaveMutex
void* MapTable::getEnd
(
)
inline
Get table's end, useful for cycle control; it is returned as void * for easy re-cast.
- Returns
- pointer to found object or NULL.
Definition at line 423 of file object.h.
void* MapTable::getFirst
(
)
Get the first element into table, it is returned as void * for easy re-cast.
- Returns
- pointer to found object or NULL.
void* MapTable::getFree
(
void
)
Get next object from managed free list.
This returns as a void so it can be recast into the actual type being used in derived MapObject's. A derived version of MapTable may well offer an explicit type version of this. Some derived MapObject's may override new to use managed list.
- Returns
- next object on free list.
virtual unsigned MapTable::getIndex
(
const char *
id )
virtual
Get index value from id string.
This function can be changed as needed to provide better collision avoidence for specific tables.
- Parameters
-
id string
- Returns
- index slot in table.
void* MapTable::getLast
(
)
Get the last element into table, it is returned as void * for easy re-cast.
- Returns
- pointer to found object or NULL.
void* MapTable::getObject
(
const char *
id )
Lookup an object by id key.
It is returned as void * for easy re-cast.
- Parameters
-
key to find.
- Returns
- pointer to found object or NULL.
unsigned MapTable::getRange
(
void
)
inline
Return range of this table.
- Returns
- table range.
Definition at line 374 of file object.h.
unsigned MapTable::getSize
(
void
)
inline
Return the number of object stored in this table.
- Returns
- table size.
Definition at line 382 of file object.h.
void Mutex::leave
(
void
)
inlineinherited
Future abi will use enter/leave/test members.
Definition at line 269 of file thread.h.
void Mutex::leaveMutex
(
void
)
inherited
Leaving a mutex frees that mutex for use by another thread.
If the mutex has been entered (invoked) multiple times (recursivily) by the same thread, then it will need to be exited the same number of instances before it is free for re-use. This operation can also be done using the LEAVE_CRITICAL macro or by the – operator on a mutex.
- See Also
- enterMutex
void Mutex::nameMutex
(
const char *
name )
inlineinherited
Enable setting of mutex name for deadlock debug.
- Parameters
-
name for mutex.
Definition at line 248 of file thread.h.
An operator to map an object to the table.
- Returns
- table being used.
- Parameters
-
object being mapped.
This operator is virtual in case it must also add the object to a managed free list.
- Returns
- current table.
- Parameters
-
object entity to remove.
static void Mutex::setDebug
(
bool
mode )
inlinestaticinherited
Enable or disable deadlock debugging.
- Parameters
-
mode debug mode.
Definition at line 240 of file thread.h.
bool Mutex::test
(
void
)
inlineinherited
Future abi will use enter/leave/test members.
- Returns
- true if entered.
Definition at line 277 of file thread.h.
bool Mutex::tryEnterMutex
(
void
)
inherited
Tries to lock the mutex for the current thread.
Behaves like enterMutex , except that it doesn't block the calling thread if the mutex is already locked by another thread.
- Returns
- true if locking the mutex was succesful otherwise false
- See Also
- enterMutex
-
leaveMutex
Friends And Related Function Documentation
Field Documentation
unsigned MapTable::count
protected
unsigned MapTable::range
protected
The documentation for this class was generated from the following file: