reSIProcate/stack  9694
TupleMarkManager.hxx
Go to the documentation of this file.
00001 #ifndef TUPLE_MARK_MANAGER
00002 #define TUPLE_MARK_MANAGER
00003 
00004 #include "resip/stack/Tuple.hxx"
00005 #include "rutil/Mutex.hxx"
00006 #include <set>
00007 #include <map>
00008 
00009 namespace resip
00010 {
00011 
00012 class MarkListener;
00013 
00014 class TupleMarkManager
00015 {
00016    public:
00017       TupleMarkManager(){}
00018       virtual ~TupleMarkManager(){}
00019       
00020       typedef enum
00021       {
00022          OK,
00023          GREY,
00024          BLACK
00025       }
00026       MarkType;
00027 
00028       MarkType getMarkType(const Tuple& tuple);
00029       
00030       void mark(const Tuple& tuple,UInt64 expiry,MarkType mark);
00031       void registerMarkListener(MarkListener*);
00032       void unregisterMarkListener(MarkListener*);
00033 
00034    private:
00035       
00036       class ListEntry
00037       {
00038          public:
00039             ListEntry(const Tuple& tuple, UInt64 expiry);
00040             ListEntry(const ListEntry& orig);
00041             ~ListEntry();
00042             bool operator<(const ListEntry& rhs) const;
00043             bool operator>(const ListEntry& rhs) const;
00044             bool operator==(const ListEntry& rhs) const;
00045             
00046             Tuple mTuple;
00047             UInt64 mExpiry;
00048          private:
00049             ListEntry();
00050       };
00051       
00052       typedef std::map<ListEntry,MarkType> TupleList;
00053 
00054       TupleList mList;
00055       resip::Mutex mListMutex;
00056             
00057       typedef std::set<MarkListener*> Listeners;
00058       Listeners mListeners;
00059       
00060       void notifyListeners(const resip::Tuple& tuple, UInt64& expiry, MarkType& mark);
00061 };
00062 
00063 }
00064 
00065 #endif
00066 
00067 /* ====================================================================
00068  * The Vovida Software License, Version 1.0 
00069  * 
00070  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00071  * 
00072  * Redistribution and use in source and binary forms, with or without
00073  * modification, are permitted provided that the following conditions
00074  * are met:
00075  * 
00076  * 1. Redistributions of source code must retain the above copyright
00077  *    notice, this list of conditions and the following disclaimer.
00078  * 
00079  * 2. Redistributions in binary form must reproduce the above copyright
00080  *    notice, this list of conditions and the following disclaimer in
00081  *    the documentation and/or other materials provided with the
00082  *    distribution.
00083  * 
00084  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00085  *    and "Vovida Open Communication Application Library (VOCAL)" must
00086  *    not be used to endorse or promote products derived from this
00087  *    software without prior written permission. For written
00088  *    permission, please contact vocal@vovida.org.
00089  *
00090  * 4. Products derived from this software may not be called "VOCAL", nor
00091  *    may "VOCAL" appear in their name, without prior written
00092  *    permission of Vovida Networks, Inc.
00093  * 
00094  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00095  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00096  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00097  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00098  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00099  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00100  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00101  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00102  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00103  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00104  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00105  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00106  * DAMAGE.
00107  * 
00108  * ====================================================================
00109  * 
00110  * This software consists of voluntary contributions made by Vovida
00111  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00112  * Inc.  For more information on Vovida Networks, Inc., please see
00113  * <http://www.vovida.org/>.
00114  *
00115  */