CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CondFormats/Common/interface/IOVSequence.h

Go to the documentation of this file.
00001 #ifndef Cond_IOVSequence_h
00002 #define Cond_IOVSequence_h
00003 #include "CondFormats/Common/interface/UpdateStamp.h"
00004 #include "CondFormats/Common/interface/IOVElement.h"
00005 #include "CondFormats/Common/interface/Time.h"
00006 #include "CondFormats/Common/interface/IOVProvenance.h"
00007 #include "CondFormats/Common/interface/IOVDescription.h"
00008 #include "CondFormats/Common/interface/IOVUserMetaData.h"
00009 
00010 #include "CondCore/ORA/interface/QueryableVector.h"
00011 
00012 #include <vector>
00013 #include <string>
00014 #include <set>
00015 
00016 namespace cond {
00017 
00023   class IOVSequence : public  UpdateStamp{
00024   public:
00025     typedef cond::IOVElement Item;
00026     typedef ora::QueryableVector<Item> Container;
00027     typedef Container::iterator iterator;
00028     typedef Container::const_iterator const_iterator;
00029     typedef enum { Unknown=-1, Obsolete, Tag, TagInGT, ChildTag, ChildTagInGT } ScopeType;
00030 
00031     IOVSequence();
00032 
00033     // the real default constructor...
00034     explicit IOVSequence( cond::TimeType ttype );
00035 
00036     // constructor for the editor
00037     IOVSequence(int type, cond::Time_t till, std::string const& imetadata);
00038 
00039     ~IOVSequence();
00040 
00041     IOVSequence(IOVSequence const & rh);
00042     IOVSequence & operator=(IOVSequence const & rh);
00043 
00044     // append a new item, return position of last inserted entry
00045     size_t add(cond::Time_t time, std::string const & token, std::string const& payloadClassName );
00046 
00047     // remove last entry, return position of last entry still valid
00048     size_t truncate();
00049     
00050     // find IOV for which time is valid (this is not STANDARD std::find!)
00051     const_iterator find(cond::Time_t time) const;
00052 
00053     // find IOV with a given since  (this is not STANDARD std::find!)
00054     const_iterator findSince(cond::Time_t time) const;
00055 
00056     // true if an iov with since==time already exists
00057     bool exist(cond::Time_t time) const;
00058 
00059     cond::TimeType timeType() const { return cond::timeTypeSpecs[m_timetype].type;}
00060 
00061     // FIXME shall we cache it?
00062     cond::Time_t firstSince() const { return  iovs().front().sinceTime();}
00063 
00064     cond::Time_t lastTill() const { return  m_lastTill;}
00065 
00066     void updateLastTill(cond::Time_t till) { m_lastTill=till;}
00067 
00068     void updateMetadata( const std::string& metadata, bool append=true );
00069 
00070     void setScope( ScopeType type ) { m_scope = type;}
00071 
00072   public:
00073     Container const & iovs() const;
00074 
00075     // if true the "sorted" sequence is not guaranted to be the same as in previous version
00076     bool notOrdered() const { return m_notOrdered;}
00077 
00078     std::string const & metadata() const { return m_metadata;}
00079 
00080     std::set<std::string> const& payloadClasses() const { return m_payloadClasses; }
00081     
00082     ScopeType scope() const { return m_scope;}
00083  
00084     void loadAll() const;
00085 
00086   public:
00087 
00088     // the real persistent container...
00089     Container & piovs() { 
00090       m_iovs.load();
00091       return m_iovs;
00092     }
00093     Container const & piovs() const { 
00094       m_iovs.load();
00095       return m_iovs;
00096     }
00097 
00098     void swapTokens( ora::ITokenParser& parser ) const;
00099     void swapOIds( ora::ITokenWriter& writer ) const;
00100 
00101   private:
00102     
00103     // iovs is not in order: take action!
00104     void disorder();
00105 
00106     // sort the container in m_sorted
00107     Container const & sortMe() const;
00108     
00109   private:
00110 
00111     Container m_iovs;
00112     int m_timetype;
00113     cond::Time_t m_lastTill;
00114     bool m_notOrdered;
00115     std::string m_metadata; // FIXME not used???
00116     std::set<std::string> m_payloadClasses;
00117     ScopeType m_scope;
00118     
00119     mutable Container * m_sorted;
00120 
00121   };
00122 
00123 }//ns cond
00124 #endif