sipxtacklib  Version 3.3
Public Member Functions | Protected Attributes | List of all members
SipXHandleMap Class Reference

SipXHandleMap provides a very simple container that associates a void* with a handle value. More...

#include <SipXHandleMap.h>

Inheritance diagram for SipXHandleMap:
Inheritance graph
[legend]
Collaboration diagram for SipXHandleMap:
Collaboration graph
[legend]

Public Member Functions

 SipXHandleMap (int startingHandle=1)
 Default constructor. More...
 
virtual ~SipXHandleMap ()
 Destructor. More...
 
void addHandleRef (SIPXHANDLE handle)
 Adds a reference count to the handle lock. More...
 
SIPXHANDLE allocHandle (const void *pData)
 Allocate a unique handle and associate the designed pData value with that handle. More...
 
const void * findHandle (SIPXHANDLE handle)
 Find the data associated with the designated handle and return it. More...
 
const void * removeHandle (SIPXHANDLE handle)
 Remove the handle and data assoicated with it from the map. More...
 
void lock ()
 Lock/guard access to the allocHandle, findHandle, and removeHandle routines. More...
 
void unlock ()
 Unlock access to the allocHandle, findHandle, and removeHandle routines. More...
 
void dump ()
 
void dumpCalls ()
 

Protected Attributes

OsMutex mLock
 Locked used for addEntry and removeEntry. More...
 
SIPXHANDLE mNextHandle
 Next available handle index. More...
 

Detailed Description

SipXHandleMap provides a very simple container that associates a void* with a handle value.

The handle value is a unique incrementing number. In theory, we could get collisions if the numbers wrap, however, this is not designed for that type of call volume (millions of call per hour?)

Generally, use the allocHandle, removeHandle, and findHandle methods. lock() and unlock() methods are also provided for external iterators.

Constructor & Destructor Documentation

SipXHandleMap ( int  startingHandle = 1)

Default constructor.

virtual ~SipXHandleMap ( )
virtual

Destructor.

Member Function Documentation

void addHandleRef ( SIPXHANDLE  handle)

Adds a reference count to the handle lock.

In this way, removeHandle is guarded against removal while a handle is in use. releaseHandleRef decrements the reference count. addHandleRef should only be used in very specific cases, when the handle might become invalid before it is needed again.

SIPXHANDLE allocHandle ( const void *  pData)

Allocate a unique handle and associate the designed pData value with that handle.

Parameters
pDataData to be associated with the newly allocated handle
const void* findHandle ( SIPXHANDLE  handle)

Find the data associated with the designated handle and return it.

const void* removeHandle ( SIPXHANDLE  handle)

Remove the handle and data assoicated with it from the map.

void lock ( )

Lock/guard access to the allocHandle, findHandle, and removeHandle routines.

This is called automatically for those routines, however, should be called explicitly if using an external iterator on the map.

void unlock ( )

Unlock access to the allocHandle, findHandle, and removeHandle routines.

This is called automatically for those routines, however, should be called explicitly if using an external iterator on the map.

void dump ( )
void dumpCalls ( )

Member Data Documentation

OsMutex mLock
protected

Locked used for addEntry and removeEntry.

SIPXHANDLE mNextHandle
protected

Next available handle index.


sipXtackLib home page