|
reSIProcate/stack
9694
|
00001 #if defined(HAVE_CONFIG_H) 00002 #include "config.h" 00003 #endif 00004 00005 #include "rutil/Logger.hxx" 00006 #include "resip/stack/TransactionMap.hxx" 00007 #include "resip/stack/TransactionState.hxx" 00008 00009 using namespace resip; 00010 00011 #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSACTION 00012 00013 TransactionMap::~TransactionMap() 00014 { 00015 //DebugLog (<< "Deleting TransactionMap: " << this << " " << mMap.size() << " entries"); 00016 while (!mMap.empty()) 00017 { 00018 DebugLog (<< mMap.begin()->first << " -> " << mMap.begin()->second << ": " << *mMap.begin()->second); 00019 delete mMap.begin()->second; 00020 } 00021 } 00022 00023 TransactionState* 00024 TransactionMap::find( const Data& tid ) const 00025 { 00026 MapConstIterator i = mMap.find(tid); 00027 if (i != mMap.end()) 00028 { 00029 return i->second; 00030 } 00031 else 00032 { 00033 return 0; 00034 } 00035 } 00036 00037 void 00038 TransactionMap::add(const Data& tid, TransactionState* state ) 00039 { 00040 MapIterator i = mMap.find(tid); 00041 if (i != mMap.end()) 00042 { 00043 if (i->second != state) 00044 { 00045 // .bwc. ~TransactionState will remove itself from the map. 00046 delete i->second; 00047 //DebugLog (<< "Replacing TMAP[" << tid << "] = " << state << " : " << *state); 00048 mMap[tid] = state; 00049 } 00050 } 00051 else 00052 { 00053 //DebugLog (<< "Inserting TMAP[" << tid << "] = " << state << " : " << *state); 00054 mMap[tid] = state; 00055 } 00056 } 00057 00058 void 00059 TransactionMap::erase(const Data& tid ) 00060 { 00061 MapIterator i = mMap.find(tid); 00062 if (i != mMap.end()) 00063 { 00064 // don't delete it here, the TransactionState deletes itself and removes 00065 // itself from the map 00066 //DebugLog (<< "Erasing " << tid << "(" << i->second << ")"); 00067 mMap.erase(i); 00068 } 00069 else 00070 { 00071 InfoLog (<< "Couldn't find " << tid << " to remove"); 00072 assert(0); 00073 } 00074 } 00075 00076 int 00077 TransactionMap::size() const 00078 { 00079 return (int)mMap.size(); 00080 } 00081 00082 00083 00084 /* ==================================================================== 00085 * The Vovida Software License, Version 1.0 00086 * 00087 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00088 * 00089 * Redistribution and use in source and binary forms, with or without 00090 * modification, are permitted provided that the following conditions 00091 * are met: 00092 * 00093 * 1. Redistributions of source code must retain the above copyright 00094 * notice, this list of conditions and the following disclaimer. 00095 * 00096 * 2. Redistributions in binary form must reproduce the above copyright 00097 * notice, this list of conditions and the following disclaimer in 00098 * the documentation and/or other materials provided with the 00099 * distribution. 00100 * 00101 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00102 * and "Vovida Open Communication Application Library (VOCAL)" must 00103 * not be used to endorse or promote products derived from this 00104 * software without prior written permission. For written 00105 * permission, please contact vocal@vovida.org. 00106 * 00107 * 4. Products derived from this software may not be called "VOCAL", nor 00108 * may "VOCAL" appear in their name, without prior written 00109 * permission of Vovida Networks, Inc. 00110 * 00111 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00112 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00113 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00114 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00115 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00116 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00117 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00118 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00119 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00120 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00121 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00122 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00123 * DAMAGE. 00124 * 00125 * ==================================================================== 00126 * 00127 * This software consists of voluntary contributions made by Vovida 00128 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00129 * Inc. For more information on Vovida Networks, Inc., please see 00130 * <http://www.vovida.org/>. 00131 * 00132 */
1.7.5.1