reSIProcate/DialogUsageManager  9694
MergedRequestKey.cxx
Go to the documentation of this file.
00001 #include "resip/dum/MergedRequestKey.hxx"
00002 #include "resip/stack/SipMessage.hxx"
00003 #include "resip/stack/CSeqCategory.hxx"
00004 
00005 using namespace resip;
00006 
00007 const MergedRequestKey MergedRequestKey::Empty;
00008 
00009 MergedRequestKey::MergedRequestKey():
00010    mCheckRequestUri(true)
00011 {
00012 }
00013 
00014 MergedRequestKey::MergedRequestKey(const SipMessage& req, bool checkRequestUri) : 
00015    mRequestUri(Data::from(req.header(h_RequestLine).uri())),
00016    mCSeq(Data::from(req.header(h_CSeq))),
00017    mTag(req.header(h_From).exists(p_tag) ? req.header(h_From).param(p_tag) : Data::Empty),
00018    mCallId(req.header(h_CallID).value()),
00019    mCheckRequestUri(checkRequestUri)
00020 {
00021 }
00022 
00023 bool
00024 MergedRequestKey::operator==(const MergedRequestKey& other) const
00025 {
00026    return (mCallId == other.mCallId  &&
00027            mTag == other.mTag &&
00028            mCSeq == other.mCSeq &&
00029            (!mCheckRequestUri || (mRequestUri == other.mRequestUri)));
00030 }
00031 
00032 bool
00033 MergedRequestKey::operator!=(const MergedRequestKey& other) const
00034 {
00035    return !(*this == other);
00036 }
00037 
00038 bool
00039 MergedRequestKey::operator<(const MergedRequestKey& other) const
00040 {
00041    if ( mCallId < other.mCallId)
00042    {
00043       return true;
00044    }
00045    else if (mCallId > other.mCallId)
00046    {
00047       return false;
00048    }
00049    
00050    if (mTag < other.mTag)
00051    {
00052       return true;
00053    }
00054    else if (mTag > other.mTag)
00055    {
00056       return false;
00057    }
00058    
00059    if(!mCheckRequestUri)
00060    {
00061       return (mCSeq < other.mCSeq);
00062    }
00063    else
00064    {
00065       if (mCSeq < other.mCSeq)
00066       {
00067          return true;
00068       }
00069       else if (mCSeq > other.mCSeq)
00070       {
00071          return false;
00072       }
00073    
00074       return (mRequestUri < other.mRequestUri);
00075    }
00076 }
00077 
00078 Data& MergedRequestKey::cseq()
00079 {
00080     return mCSeq;
00081 }
00082 
00083 const Data& MergedRequestKey::cseq() const
00084 {
00085     return mCSeq;
00086 }
00087 
00088 
00089 /* ====================================================================
00090  * The Vovida Software License, Version 1.0 
00091  * 
00092  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00093  * 
00094  * Redistribution and use in source and binary forms, with or without
00095  * modification, are permitted provided that the following conditions
00096  * are met:
00097  * 
00098  * 1. Redistributions of source code must retain the above copyright
00099  *    notice, this list of conditions and the following disclaimer.
00100  * 
00101  * 2. Redistributions in binary form must reproduce the above copyright
00102  *    notice, this list of conditions and the following disclaimer in
00103  *    the documentation and/or other materials provided with the
00104  *    distribution.
00105  * 
00106  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00107  *    and "Vovida Open Communication Application Library (VOCAL)" must
00108  *    not be used to endorse or promote products derived from this
00109  *    software without prior written permission. For written
00110  *    permission, please contact vocal@vovida.org.
00111  *
00112  * 4. Products derived from this software may not be called "VOCAL", nor
00113  *    may "VOCAL" appear in their name, without prior written
00114  *    permission of Vovida Networks, Inc.
00115  * 
00116  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00117  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00118  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00119  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00120  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00121  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00122  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00123  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00124  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00125  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00126  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00127  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00128  * DAMAGE.
00129  * 
00130  * ====================================================================
00131  * 
00132  * This software consists of voluntary contributions made by Vovida
00133  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00134  * Inc.  For more information on Vovida Networks, Inc., please see
00135  * <http://www.vovida.org/>.
00136  *
00137  */