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 <vector> 00007 #include <string> 00008 #include "CondCore/ORA/interface/PVector.h" 00009 00010 #include "CondFormats/Common/interface/IOVProvenance.h" 00011 #include "CondFormats/Common/interface/IOVDescription.h" 00012 #include "CondFormats/Common/interface/IOVUserMetaData.h" 00013 00014 00015 namespace cond { 00016 00022 class IOVSequence : public UpdateStamp{ 00023 public: 00024 typedef cond::IOVElement Item; 00025 typedef ora::PVector<Item> Container; 00026 typedef Container::iterator iterator; 00027 typedef Container::const_iterator const_iterator; 00028 00029 IOVSequence(); 00030 00031 // the real default constructor... 00032 explicit IOVSequence(cond::TimeType ttype); 00033 00034 // constructor for the editor 00035 IOVSequence(int type, cond::Time_t till, std::string const& imetadata); 00036 00037 ~IOVSequence(); 00038 00039 IOVSequence(IOVSequence const & rh); 00040 IOVSequence & operator=(IOVSequence const & rh); 00041 00042 // append a new item, return position of last inserted entry 00043 size_t add(cond::Time_t time, 00044 std::string const & wrapperToken); 00045 00046 // remove last entry, return position of last entry still valid 00047 size_t truncate(); 00048 00049 // find IOV for which time is valid (this is not STANDARD std::find!) 00050 const_iterator find(cond::Time_t time) const; 00051 00052 // find IOV with a given since (this is not STANDARD std::find!) 00053 const_iterator findSince(cond::Time_t time) const; 00054 00055 // true if an iov with since==time already exists 00056 bool exist(cond::Time_t time) const; 00057 00058 cond::TimeType timeType() const { return cond::timeTypeSpecs[m_timetype].type;} 00059 00060 // FIXME shall we cache it? 00061 cond::Time_t firstSince() const { return iovs().front().sinceTime();} 00062 00063 cond::Time_t lastTill() const { return m_lastTill;} 00064 00065 void updateLastTill(cond::Time_t till) { m_lastTill=till;} 00066 00067 00068 public: 00069 Container const & iovs() const; 00070 00071 // if true the "sorted" sequence is not guaranted to be the same as in previous version 00072 bool notOrdered() const { return m_notOrdered;} 00073 00074 std::string const & metadataToken() const { return m_metadata;} 00075 00076 00077 // void set_description(cond::IOVDescription * id) { m_description = id;} 00078 00079 // cond::IOVDescription const & description() const {return *m_description;} 00080 00081 00082 void loadAll() const; 00083 00084 public: 00085 00086 // the real persistent container... 00087 Container & piovs() { return m_iovs;} 00088 Container const & piovs() const { return m_iovs;} 00089 00090 private: 00091 00092 // iovs is not in order: take action! 00093 void disorder(); 00094 00095 // sort the container in m_sorted 00096 Container const & sortMe() const; 00097 00098 private: 00099 00100 Container m_iovs; 00101 int m_timetype; 00102 cond::Time_t m_lastTill; 00103 00104 bool m_notOrdered; 00105 00106 std::string m_metadata; // FIXME not used??? 00107 00108 // to describe history and be used as provenance 00109 // pool::PolyPtr<cond::IOVProvenance> m_provenance; 00110 00111 // keep list of types, list of keywords, 00112 // pool::PolyPtr<cond::IOVDescription> m_description; 00113 00114 // for the user 00115 // pool::PolyPtr<cond::IOVUserMetaData> m_userMetadata; 00116 00117 mutable Container * m_sorted; 00118 00119 }; 00120 00121 }//ns cond 00122 #endif