Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:24

0001 #ifndef CondCore_CondDB_IOVEditor_h
0002 #define CondCore_CondDB_IOVEditor_h
0003 //
0004 // Package:     CondDB
0005 // Class  :     IOVEditor
0006 //
0007 /**\class IOVEditor IOVEditor.h CondCore/CondDB/interface/IOVEditor.h
0008    Description: service for update access to the condition IOVs.  
0009 */
0010 //
0011 // Author:      Giacomo Govi
0012 // Created:     Apr 2013
0013 //
0014 
0015 #include "CondCore/CondDB/interface/Time.h"
0016 #include "CondCore/CondDB/interface/Types.h"
0017 //
0018 #include <boost/date_time/posix_time/posix_time.hpp>
0019 
0020 namespace cond {
0021 
0022   namespace persistency {
0023 
0024     class SessionImpl;
0025     class IOVEditorData;
0026 
0027     // value semantics...
0028     class IOVEditor {
0029     public:
0030       IOVEditor();
0031       // ctor
0032       explicit IOVEditor(const std::shared_ptr<SessionImpl>& session);
0033 
0034       // ctor used after new tag creation. the specified params are assumed and passed directly to the object.
0035       IOVEditor(const std::shared_ptr<SessionImpl>& session,
0036                 const std::string& tag,
0037                 cond::TimeType timeType,
0038                 const std::string& payloadType,
0039                 cond::SynchronizationType synchronizationType,
0040                 const boost::posix_time::ptime& creationTime = boost::posix_time::microsec_clock::universal_time());
0041 
0042       //
0043       IOVEditor(const IOVEditor& rhs);
0044 
0045       //
0046       IOVEditor& operator=(const IOVEditor& rhs);
0047 
0048       //
0049       ~IOVEditor();
0050 
0051       // loads to tag to edit
0052       void load(const std::string& tag);
0053 
0054       // read only getters. they could be changed to return references...
0055       std::string tag() const;
0056       cond::TimeType timeType() const;
0057       std::string payloadType() const;
0058 
0059       // getters/setters for the updatable parameters
0060       cond::SynchronizationType synchronizationType() const;
0061       void setSynchronizationType(cond::SynchronizationType synchronizationType);
0062 
0063       cond::Time_t endOfValidity() const;
0064       void setEndOfValidity(cond::Time_t validity);
0065 
0066       std::string description() const;
0067       void setDescription(const std::string& description);
0068 
0069       cond::Time_t lastValidatedTime() const;
0070       void setLastValidatedTime(cond::Time_t time);
0071 
0072       // register a new insertion.
0073       // if checkType==true, the payload corresponding to the specified id is verified to be the same type as the iov payloadObjectType
0074       void insert(cond::Time_t since, const cond::Hash& payloadHash, bool checkType = false);
0075       void insert(cond::Time_t since,
0076                   const cond::Hash& payloadHash,
0077                   const boost::posix_time::ptime& insertionTime,
0078                   bool checkType = false);
0079 
0080       // register a new deletion.
0081       void erase(cond::Time_t since, const cond::Hash& payloadHash);
0082 
0083       // execute the update/intert queries and reset the buffer
0084       bool flush();
0085       bool flush(const boost::posix_time::ptime& operationTime);
0086       bool flush(const std::string& logText);
0087       bool flush(const std::string& logText, bool forceInsertion);
0088 
0089       bool isLocked() const;
0090       void lock();
0091       void unlock();
0092 
0093     private:
0094       bool flush(const std::string& logText, const boost::posix_time::ptime& operationTime, bool forceInsertion);
0095       void checkTransaction(const std::string& ctx);
0096 
0097     private:
0098       std::shared_ptr<IOVEditorData> m_data;
0099       std::shared_ptr<SessionImpl> m_session;
0100     };
0101 
0102   }  // namespace persistency
0103 }  // namespace cond
0104 
0105 #endif