sipxtacklib  Version 3.3
SipXHandleMap.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _SipXHandleMap_h_
13 #define _SipXHandleMap_h_
14 
15 // SYSTEM INCLUDES
16 // APPLICATION INCLUDES
17 #include "os/OsMutex.h"
18 #include "utl/UtlHashMap.h"
19 
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 typedef unsigned int SIPXHANDLE ;
29 // FORWARD DECLARATIONS
30 
41 class SipXHandleMap : public UtlHashMap
42 {
43 /* //////////////////////////// PUBLIC //////////////////////////////////// */
44  public:
45 
46 /* ============================ CREATORS ================================== */
47 
51  SipXHandleMap(int startingHandle = 1);
52 
56  virtual ~SipXHandleMap();
57 
58 /* ============================ MANIPULATORS ============================== */
59 
60 
68  void addHandleRef(SIPXHANDLE handle);
69 
76  SIPXHANDLE allocHandle(const void* pData) ;
77 
78 
82  const void* findHandle(SIPXHANDLE handle) ;
83 
87  const void* removeHandle(SIPXHANDLE handle) ;
88 
94  void lock() ;
95 
101  void unlock() ;
102 /* ============================ ACCESSORS ================================= */
103 
104  void dump() ;
105  void dumpCalls();
106 
107 /* ============================ INQUIRY =================================== */
108 
109 /* //////////////////////////// PROTECTED ///////////////////////////////// */
110  protected:
111  OsMutex mLock ;
115 /* //////////////////////////// PRIVATE /////////////////////////////////// */
116  private:
117  UtlHashMap mLockCountHash;
118 
126  void releaseHandleRef(SIPXHANDLE handle);
127 
128 };
129 
130 /* ============================ INLINE METHODS ============================ */
131 
132 #endif // _SipXHandleMap_h_
const void * findHandle(SIPXHANDLE handle)
Find the data associated with the designated handle and return it.
SIPXHANDLE mNextHandle
Next available handle index.
Definition: SipXHandleMap.h:112
const void * removeHandle(SIPXHANDLE handle)
Remove the handle and data assoicated with it from the map.
void addHandleRef(SIPXHANDLE handle)
Adds a reference count to the handle lock.
void dumpCalls()
SIPXHANDLE allocHandle(const void *pData)
Allocate a unique handle and associate the designed pData value with that handle. ...
OsMutex mLock
Locked used for addEntry and removeEntry.
Definition: SipXHandleMap.h:111
virtual ~SipXHandleMap()
Destructor.
void lock()
Lock/guard access to the allocHandle, findHandle, and removeHandle routines.
void unlock()
Unlock access to the allocHandle, findHandle, and removeHandle routines.
SipXHandleMap provides a very simple container that associates a void* with a handle value...
Definition: SipXHandleMap.h:41
unsigned int SIPXHANDLE
Definition: SipXHandleMap.h:28
SipXHandleMap(int startingHandle=1)
Default constructor.

sipXtackLib home page