/[resiprocate]/branches/b-directory-reorg/sip/resiprocate/TransactionMap.cxx
ViewVC logotype

Contents of /branches/b-directory-reorg/sip/resiprocate/TransactionMap.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5271 - (show annotations) (download)
Thu Aug 18 23:43:07 2005 UTC (14 years, 3 months ago) by jason
File size: 4120 byte(s)
new directory reorg proposal
1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5 #include "resiprocate/os/Logger.hxx"
6 #include "resiprocate/TransactionMap.hxx"
7 #include "resiprocate/TransactionState.hxx"
8
9 using namespace resip;
10
11 #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSACTION
12
13 TransactionMap::~TransactionMap()
14 {
15 //DebugLog (<< "Deleting TransactionMap: " << this << " " << mMap.size() << " entries");
16 while (!mMap.empty())
17 {
18 DebugLog (<< mMap.begin()->first << " -> " << mMap.begin()->second << ": " << *mMap.begin()->second);
19 delete mMap.begin()->second;
20 }
21 }
22
23 TransactionState*
24 TransactionMap::find( const Data& tid ) const
25 {
26 MapConstIterator i = mMap.find(tid);
27 if (i != mMap.end())
28 {
29 return i->second;
30 }
31 else
32 {
33 return 0;
34 }
35 }
36
37 void
38 TransactionMap::add(const Data& tid, TransactionState* state )
39 {
40 MapIterator i = mMap.find(tid);
41 if (i != mMap.end())
42 {
43 if (i->second != state)
44 {
45 delete i->second;
46 mMap.erase(i);
47 //DebugLog (<< "Replacing TMAP[" << tid << "] = " << state << " : " << *state);
48 mMap[tid] = state;
49 }
50 }
51 else
52 {
53 //DebugLog (<< "Inserting TMAP[" << tid << "] = " << state << " : " << *state);
54 mMap[tid] = state;
55 }
56 }
57
58 void
59 TransactionMap::erase(const Data& tid )
60 {
61 MapIterator i = mMap.find(tid);
62 if (i != mMap.end())
63 {
64 // don't delete it here, the TransactionState deletes itself and removes
65 // itself from the map
66 //DebugLog (<< "Erasing " << tid << "(" << i->second << ")");
67 mMap.erase(i);
68 }
69 else
70 {
71 InfoLog (<< "Couldn't find " << tid << " to remove");
72 assert(0);
73 }
74 }
75
76 int
77 TransactionMap::size() const
78 {
79 return mMap.size();
80 }
81
82
83
84 /* ====================================================================
85 * The Vovida Software License, Version 1.0
86 *
87 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
88 *
89 * Redistribution and use in source and binary forms, with or without
90 * modification, are permitted provided that the following conditions
91 * are met:
92 *
93 * 1. Redistributions of source code must retain the above copyright
94 * notice, this list of conditions and the following disclaimer.
95 *
96 * 2. Redistributions in binary form must reproduce the above copyright
97 * notice, this list of conditions and the following disclaimer in
98 * the documentation and/or other materials provided with the
99 * distribution.
100 *
101 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
102 * and "Vovida Open Communication Application Library (VOCAL)" must
103 * not be used to endorse or promote products derived from this
104 * software without prior written permission. For written
105 * permission, please contact vocal@vovida.org.
106 *
107 * 4. Products derived from this software may not be called "VOCAL", nor
108 * may "VOCAL" appear in their name, without prior written
109 * permission of Vovida Networks, Inc.
110 *
111 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
112 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
113 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
114 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
115 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
116 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
117 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
118 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
119 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
120 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
121 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
122 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
123 * DAMAGE.
124 *
125 * ====================================================================
126 *
127 * This software consists of voluntary contributions made by Vovida
128 * Networks, Inc. and many individuals on behalf of Vovida Networks,
129 * Inc. For more information on Vovida Networks, Inc., please see
130 * <http://www.vovida.org/>.
131 *
132 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27