CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/CondCore/IOVService/interface/IOVEditor.h

Go to the documentation of this file.
00001 #ifndef CondCore_IOVService_IOVEditor_h
00002 #define CondCore_IOVService_IOVEditor_h
00003 #include <string>
00004 #include <vector>
00005 #include "CondCore/DBCommon/interface/Time.h"
00006 #include "CondCore/DBCommon/interface/DbSession.h"
00007 #include "CondFormats/Common/interface/IOVSequence.h"
00008 #include<iosfwd>
00009 
00010 //
00011 // Package:     CondCore/IOVService
00012 // Class  :     IOVEditor
00013 //
00017 //
00018 // Author:      Zhen Xie
00019 //
00020 
00021 namespace cond{
00022 
00023   class IOVElement;
00024   class IOVSequence;
00025 
00026   class IOVEditor{
00027   public:
00028 
00029     // default constructor
00030     explicit IOVEditor(cond::DbSession& dbSess);
00031 
00032     // constructor from existing iov
00033     IOVEditor( cond::DbSession& dbSess, const std::string& token);
00034  
00036     ~IOVEditor();
00037 
00038     // create empty default sequence
00039     void create( cond::TimeType timetype );
00040 
00041     // create empty sequence with fixed time boundary
00042     void create(cond::TimeType timetype, cond::Time_t lastTill );
00043 
00044     // return the current sequence
00045     IOVSequence & iov();
00046 
00048     unsigned int insert( cond::Time_t tillTime, const std::string& payloadToken );
00049 
00052     unsigned int append(  cond::Time_t sinceTime, const std::string& payloadToken );
00053 
00055     unsigned int freeInsert( cond::Time_t sinceTime, const std::string& payloadToken );
00056 
00058     void bulkAppend( std::vector< std::pair<cond::Time_t, std::string > >& values );
00059 
00060     void bulkAppend(std::vector< cond::IOVElement >& values);
00061     
00062     //stamp iov
00063     void stamp(std::string const & icomment, bool append=false);
00064 
00066     void editMetadata( std::string const & metadata, bool append=false);
00067 
00069     void setScope( cond::IOVSequence::ScopeType scope );
00070 
00072     void updateClosure( cond::Time_t newtillTime );
00073 
00074     // remove last entry
00075     unsigned int truncate(bool withPayload=false);
00076 
00077     // delete all entries
00078     void deleteEntries( bool withPayload=false);
00079 
00080     // 
00081     void import( const std::string& sourceIOVtoken );
00082 
00084     std::string const & token() const { return m_token;}
00085 
00086     Time_t firstSince() const;
00087   
00088     Time_t lastTill() const;
00089   
00090     TimeType timetype() const;
00091  
00092 
00093   private:
00094 
00095     void loadData( const std::string& token );
00096     void flushInserts();
00097     void flushUpdates();
00098 
00099     void init();
00100     bool validTime(cond::Time_t time, cond::TimeType timetype) const;
00101     bool validTime(cond::Time_t time) const;
00102 
00103     void debugInfo(std::ostream & co) const;
00104     void reportError(std::string message) const;
00105     void reportError(std::string message, cond::Time_t time) const;
00106 
00107   private:
00108 
00109     cond::DbSession m_dbSess;
00110     std::string m_token;
00111     bool m_isActive;
00112     boost::shared_ptr<cond::IOVSequence> m_iov;  
00113   };
00114 }//ns cond
00115 #endif