sipXcallLib home page


TaoObjectMap.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 _TaoObjectMap_h_
13 #define _TaoObjectMap_h_
14 
15 #if _MSC_VER >= 1000
16 #pragma once
17 #endif // _MSC_VER >= 1000
18 
19 // SYSTEM INCLUDES
20 
21 // APPLICATION INCLUDES
22 
23 #include <utl/UtlHashMap.h>
24 
25 #include "ptapi/PtDefs.h"
26 #include "tao/TaoDefs.h"
27 #include "tao/TaoObject.h"
28 #include "tao/TaoMessage.h"
29 
30 // DEFINES
31 //#define MAX_NUM_LISTENERS 20
32 #define MAX_NUM_TONE_LISTENERS 50
33 // MACROS
34 // EXTERNAL FUNCTIONS
35 // EXTERNAL VARIABLES
36 // CONSTANTS
37 // STRUCTS
38 // TYPEDEFS
39 // FORWARD DECLARATIONS
40 
42 {
43 public:
44  TaoListenerDb();
45 
47 
48  UtlString mName;
50  int mRef;
51  int mId;
52  int mIntData;
53 };
54 
55 //:Maintains a db of TaoObjHandle to TaoObject or PTAPI object mappings.
57 {
58 /* //////////////////////////// PUBLIC //////////////////////////////////// */
59 public:
60 
61  enum TaoObjectDbInitSize { TAOOBJ_DB_INIT_SIZE = 256 };
62 
63 /* ============================ CREATORS ================================== */
64 
65  TaoObjectMap(int initialDbSize = TAOOBJ_DB_INIT_SIZE);
66  //:Default constructor
67 
68  TaoObjectMap(const TaoObjectMap& rTaoObjectMap);
69  //:Copy constructor
70 
71  TaoObjectMap& operator=(const TaoObjectMap& rhs);
72  //:Assignment operator
73 
74  virtual
75  ~TaoObjectMap();
76  //:Destructor
77 
78 /* ============================ MANIPULATORS ============================== */
79 
80  TaoStatus insert(TaoObjHandle objId, TaoMessage::TaoMsgTypes objValue);
81  //:Insert the indicated TaoObjHandle into the database of active TaoObjHandles.
82  // Return TAO_SUCCESS if successful, TAO_EXISTS if the key is
83  // already in the database.
84 
85  TaoStatus insert(TaoObjHandle objId, TaoObjTypes objValue);
86  //:Insert the indicated TaoObjHandle into the database of active TaoObjHandles.
87  // Return TAO_SUCCESS if successful, TAO_EXISTS if the key is
88  // already in the database.
89 
90  TaoStatus insert(TaoObjHandle objId, TaoObjHandle objValue);
91  //:Insert the indicated TaoObjHandle into the database of active TaoObjHandles.
92  // Return TAO_SUCCESS if successful, TAO_EXISTS if the key is
93  // already in the database.
94 
95  TaoStatus insert(const char* key, TaoObjHandle objValue);
96  //:Insert the indicated TaoObjHandle into the database of active TaoObjHandles.
97  // Return TAO_SUCCESS if successful, TAO_EXISTS if the key is
98  // already in the database.
99 
100  TaoStatus insert(TaoObjHandle objId, UtlString objValue);
101  //:Insert the indicated TaoObjHandle into the database of active TaoObjHandles.
102  // Return TAO_SUCCESS if successful, TAO_EXISTS if the key is
103  // already in the database.
104 
105  TaoStatus remove(TaoObjHandle objId);
106  //:Remove the indicated TaoObjHandle from the database of active TaoObjHandles.
107  // Return TAO_SUCCESS if the indicated TaoObjHandleId is found, return
108  // TAO_NOT_FOUND if there is no match for the specified key.
109 
110  TaoStatus remove(const char* key);
111  //:Remove the indicated TaoObjHandle from the database of active TaoObjHandles.
112  // Return TAO_SUCCESS if the indicated TaoObjHandleId is found, return
113  // TAO_NOT_FOUND if there is no match for the specified key.
114 
115  TaoStatus removeByValue(TaoObjHandle value);
116  //:Find an active TaoObjHandle that has the value of the input,
117  // then remove the indicated TaoObjHandle from the database.
118  // Return TAO_SUCCESS if the indicated value is found, return
119  // TAO_NOT_FOUND if there is no match for the specified value.
120 
121 /* ============================ ACCESSORS ================================= */
122 
123  TaoStatus findValue(TaoObjHandle objId, TaoObjTypes& objValue);
124  //:Finds the value associated with the objId key.
125  // Return TAO_SUCCESS if successful, TAO_NOT_FOUND if the key is
126  // not found in the database.
127 
128  TaoStatus findValue(TaoObjHandle objId, TaoObjHandle& objValue);
129  //:Finds the value associated with the objId key.
130  // Return TAO_SUCCESS if successful, TAO_NOT_FOUND if the key is
131  // not found in the database.
132 
133  TaoStatus findValue(const char* key, TaoObjHandle& objValue);
134  //:Finds the value associated with the objId key.
135  // Return TAO_SUCCESS if successful, TAO_NOT_FOUND if the key is
136  // not found in the database.
137 
138  TaoStatus findValue(TaoObjHandle key, UtlString& objValue);
139  //:Finds the value associated with the objId key.
140  // Return TAO_SUCCESS if successful, TAO_NOT_FOUND if the key is
141  // not found in the database.
142 
143  UtlBoolean findValue(TaoObjHandle objValue);
144  //:Check if the value exists.
145  // Return TRUE if successful, FALSE if the value is
146  // not found in the database.
147 
148  int getActiveObjects(TaoObjHandle activeObjects[], int size);
149  //:Get an array of pointers to the TaoObjHandles that are currently active.
150  // The caller provides an array that can hold up to <i>size</i> TaoObjHandles.
151  // This method will fill in the <i>activeObjects</i> array with
152  // up to <i>size</i> TaoObjHandles. The method returns the number of TaoObjHandles
153  // in the array that were actually filled in.
154 
155  void getDbStats(unsigned& nInserts, unsigned& nRemoves) const;
156  //:Get the number of insertions and removals for the database.
157 
158  int numEntries(void) const { return (mNumInserts - mNumRemoves); };
159  //:Return the number of key-value pairs in the database.
160 
161 /* ============================ INQUIRY =================================== */
162 
163  UtlBoolean isEmpty(void) const { return ((mNumInserts - mNumRemoves) ? TRUE : FALSE); };
164  //:Return TRUE if the mObjDict database is empty.
165 
166 /* //////////////////////////// PROTECTED ///////////////////////////////// */
167 protected:
168 
169 /* //////////////////////////// PRIVATE /////////////////////////////////// */
170 private:
171  UtlHashMap mDict; // hash table used to store the key/value
172 
173  unsigned mNumInserts; // number of insertions into the database
174  unsigned mNumRemoves; // number of removals from the database
175 
176 
177 
178 };
179 
180 #endif // _TaoObjectMap_h_
TaoObjTypes
Definition: TaoDefs.h:90
Definition: TaoObjectMap.h:56
int mId
Definition: TaoObjectMap.h:51
unsigned mNumInserts
Definition: TaoObjectMap.h:173
TaoListenerDb()
Definition: TaoObjectMap.cpp:26
unsigned mNumRemoves
Definition: TaoObjectMap.h:174
int mIntData
Definition: TaoObjectMap.h:52
TaoMsgTypes
Definition: TaoMessage.h:57
UtlHashMap mDict
Definition: TaoObjectMap.h:163
UtlString mName
Definition: TaoObjectMap.h:48
int mpListenerPtr
Definition: TaoObjectMap.h:49
TaoStatus
Definition: TaoDefs.h:41
Definition: TaoObjectMap.h:41
int numEntries(void) const
Definition: TaoObjectMap.h:158
int mRef
Definition: TaoObjectMap.h:50
TaoObjectDbInitSize
Definition: TaoObjectMap.h:61
uintptr_t TaoObjHandle
Definition: TaoDefs.h:32
~TaoListenerDb()
Definition: TaoObjectMap.cpp:35