CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/EventFilter/StorageManager/interface/QueueID.h

Go to the documentation of this file.
00001 // $Id: QueueID.h,v 1.4 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_QueueID_h
00005 #define EventFilter_StorageManager_QueueID_h
00006 
00007 #include <cstddef>
00008 #include <iostream>
00009 #include <vector>
00010 
00011 #include "EventFilter/StorageManager/interface/EnquingPolicyTag.h"
00012 
00013 namespace stor {
00014 
00023   class QueueID
00024     {
00025     public:
00026 
00027       typedef enquing_policy::PolicyTag PolicyType;
00028 
00033       QueueID();
00034 
00039       QueueID(PolicyType policy, size_t index);
00040 
00044       PolicyType policy() const;
00045 
00049       size_t index() const;
00050 
00055       bool isValid() const;
00056 
00061       bool operator< (QueueID const& other) const;
00062 
00067       bool operator== (QueueID const& other) const;
00068 
00072       bool operator!= (QueueID const& other) const;
00073 
00074     private:
00075       size_t   index_;
00076       PolicyType policy_;
00077 
00078     };
00079 
00080   typedef std::vector<QueueID> QueueIDs;
00081 
00082   inline
00083   QueueID::QueueID() :
00084     index_(0),
00085     policy_(enquing_policy::Max)
00086   { }
00087 
00088   inline 
00089   QueueID::QueueID(PolicyType policy, size_t index) :
00090     index_(index),
00091     policy_(policy)
00092   { }
00093 
00094   inline 
00095   QueueID::PolicyType
00096   QueueID::policy() const
00097   {
00098     return policy_;
00099   }
00100 
00101   inline
00102   size_t
00103   QueueID::index() const
00104   {
00105     return index_;
00106   }
00107 
00108   inline
00109   bool
00110   QueueID::isValid() const
00111   {
00112     return policy_ != enquing_policy::Max;
00113   }
00114 
00115   inline
00116   bool
00117   QueueID::operator< (QueueID const& other) const
00118   {
00119     return policy_ == other.policy_
00120       ? index_ < other.index_
00121       : policy_ < other.policy_;
00122   }
00123 
00124   inline
00125   bool
00126   QueueID::operator== (QueueID const& other) const
00127   {
00128     return policy_ == other.policy_ && index_ == other.index_;
00129   }
00130 
00131   inline
00132   bool
00133   QueueID::operator!= (QueueID const& other) const
00134   {
00135     return !( operator==(other));
00136   }
00137 
00138   inline
00139   std::ostream&
00140   operator<< ( std::ostream& os, const QueueID& queueId )
00141   {
00142     os << "policy: " << queueId.policy() << 
00143       "   index: " << queueId.index();
00144     return os;
00145   }
00146 
00147 } // namespace stor
00148 
00149 #endif // EventFilter_StorageManager_QueueID_h 
00150 
00151