CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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 "DataSvc/Ref.h"
00008 #include<iosfwd>
00009 
00010 
00011 //
00012 // Package:     CondCore/IOVService
00013 // Class  :     IOVEditor
00014 //
00018 //
00019 // Author:      Zhen Xie
00020 //
00021 namespace cond{
00022   class IOVElement;
00023   class IOVSequence;
00024 
00025   class IOVEditor{
00026   public:
00027 
00028     // default constructor
00029     explicit IOVEditor(cond::DbSession& dbSess);
00030 
00031     // constructor from existing iov
00032     IOVEditor( cond::DbSession& dbSess,
00033                    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 
00047 
00049     unsigned int insert( cond::Time_t tillTime,
00050                          const std::string& payloadToken
00051                                  );
00052 
00054     unsigned int append(  cond::Time_t sinceTime,
00055                           const std::string& payloadToken
00056                                   );
00057 
00059     unsigned int 
00060     freeInsert( cond::Time_t sinceTime ,
00061                 const std::string& payloadToken
00062                 );
00063 
00065     void bulkAppend( std::vector< std::pair<cond::Time_t,std::string> >& values );
00066 
00067     void bulkAppend(std::vector< cond::IOVElement >& values);
00068     
00069     //stamp iov
00070     void stamp(std::string const & icomment, bool append=false);
00071 
00073     void updateClosure( cond::Time_t newtillTime );
00074     // remove last entry
00075     unsigned int truncate(bool withPayload=false);
00076     // delete all entries
00077     void deleteEntries( bool withPayload=false);
00078     // 
00079     void import( const std::string& sourceIOVtoken );
00081     std::string const & token() const { return m_token;}
00082 
00083     Time_t firstSince() const;
00084   
00085     Time_t lastTill() const;
00086   
00087     TimeType timetype() const;
00088  
00089 
00090   private:
00091 
00092     void init();
00093     bool validTime(cond::Time_t time, cond::TimeType timetype) const;
00094     bool validTime(cond::Time_t time) const;
00095 
00096     void debugInfo(std::ostream & co) const;
00097     void reportError(std::string message) const;
00098     void reportError(std::string message, cond::Time_t time) const;
00099 
00100   private:
00101 
00102     cond::DbSession m_dbSess;
00103     std::string m_token;
00104     bool m_isActive;
00105     boost::shared_ptr<cond::IOVSequence> m_iov;  
00106   };
00107 }//ns cond
00108 #endif