reSIProcate/repro  9694
Target.hxx
Go to the documentation of this file.
00001 #ifndef TARGET_HXX
00002 #define TARGET_HXX 1
00003 
00004 #include <list>
00005 #include <vector>
00006 
00007 #include "resip/stack/Uri.hxx"
00008 #include "resip/stack/NameAddr.hxx"
00009 #include "rutil/Data.hxx"
00010 #include "resip/stack/Via.hxx"
00011 #include "resip/dum/ContactInstanceRecord.hxx"
00012 #include "rutil/KeyValueStore.hxx"
00013 
00014 namespace repro
00015 {
00016 
00017 class Target
00018 {
00019    public:
00020    
00021       typedef enum
00022       {
00023          Candidate, //Transaction has not started
00024          Started, //Transaction has started, no final responses
00025          Cancelled, //Transaction has been cancelled, but no final response yet
00026          Terminated, //Transaction has received a final response
00027          NonExistent //The state of transactions that do not exist
00028       } Status;
00029    
00030       Target();
00031       Target(const resip::Uri& uri);
00032       Target(const resip::NameAddr& target);
00033       Target(const resip::ContactInstanceRecord& record);
00034 
00035       virtual ~Target();
00036       
00037       virtual const resip::Data& tid() const;
00038            
00039       virtual Status& status();
00040       virtual const Status& status() const;
00041       
00042       virtual const resip::Via& setVia(const resip::Via& via);
00043       virtual const resip::Via& via() const;
00044       
00045       virtual const resip::Uri& uri() const {return mRec.mContact.uri();}
00046       
00047       virtual const resip::ContactInstanceRecord& rec() const;
00048       virtual resip::ContactInstanceRecord& rec();
00049       virtual void setRec(const resip::ContactInstanceRecord& rec);
00050       
00051       virtual Target* clone() const;
00052       
00053       //In case you need const accessors to keep things happy.
00054       virtual int getPriority() const;
00055       virtual bool shouldAutoProcess() const;
00056       
00057       // Accessor for per-target extensible state storage for monkeys
00058       resip::KeyValueStore& getKeyValueStore() { return mKeyValueStore; }
00059 
00060       static bool priorityMetricCompare(const Target* lhs, const Target* rhs)
00061       {
00062          return lhs->mPriorityMetric > rhs->mPriorityMetric;
00063       }
00064 
00065       /**
00066          Higher value denotes higher priority.
00067       */
00068       int mPriorityMetric;
00069       bool mShouldAutoProcess;
00070       
00071    protected:
00072       Status mStatus;
00073       resip::Via mVia;
00074       resip::ContactInstanceRecord mRec;
00075       resip::KeyValueStore mKeyValueStore;
00076 };// class Target
00077 
00078 #ifdef __SUNPRO_CC
00079 typedef std::vector<Target*> TargetPtrList;
00080 #else
00081 typedef std::list<Target*> TargetPtrList;
00082 #endif
00083 
00084 EncodeStream& 
00085 operator<<(EncodeStream& strm, const repro::Target& t);
00086 
00087 }// namespace repro
00088 
00089 #endif
00090 
00091 /* ====================================================================
00092  * The Vovida Software License, Version 1.0 
00093  * 
00094  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00095  * 
00096  * Redistribution and use in source and binary forms, with or without
00097  * modification, are permitted provided that the following conditions
00098  * are met:
00099  * 
00100  * 1. Redistributions of source code must retain the above copyright
00101  *    notice, this list of conditions and the following disclaimer.
00102  * 
00103  * 2. Redistributions in binary form must reproduce the above copyright
00104  *    notice, this list of conditions and the following disclaimer in
00105  *    the documentation and/or other materials provided with the
00106  *    distribution.
00107  * 
00108  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00109  *    and "Vovida Open Communication Application Library (VOCAL)" must
00110  *    not be used to endorse or promote products derived from this
00111  *    software without prior written permission. For written
00112  *    permission, please contact vocal@vovida.org.
00113  *
00114  * 4. Products derived from this software may not be called "VOCAL", nor
00115  *    may "VOCAL" appear in their name, without prior written
00116  *    permission of Vovida Networks, Inc.
00117  * 
00118  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00119  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00120  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00121  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00122  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00123  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00124  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00125  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00126  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00127  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00128  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00129  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00130  * DAMAGE.
00131  * 
00132  * ====================================================================
00133  * 
00134  * This software consists of voluntary contributions made by Vovida
00135  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00136  * Inc.  For more information on Vovida Networks, Inc., please see
00137  * <http://www.vovida.org/>.
00138  *
00139  */