CMS 3D CMS Logo

IOVEditor.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_IOVEditor_h
2 #define CondCore_CondDB_IOVEditor_h
3 //
4 // Package: CondDB
5 // Class : IOVEditor
6 //
10 //
11 // Author: Giacomo Govi
12 // Created: Apr 2013
13 //
14 
17 //
18 #include <boost/date_time/posix_time/posix_time.hpp>
19 
20 namespace cond {
21 
22  namespace persistency {
23 
24  class SessionImpl;
25  class IOVEditorData;
26 
27  // value semantics...
28  class IOVEditor {
29  public:
30 
31  IOVEditor();
32  // ctor
33  explicit IOVEditor( const std::shared_ptr<SessionImpl>& session );
34 
35  // ctor used after new tag creation. the specified params are assumed and passed directly to the object.
36  IOVEditor( const std::shared_ptr<SessionImpl>& session,
37  const std::string& tag,
39  const std::string& payloadType,
41  const boost::posix_time::ptime& creationTime = boost::posix_time::microsec_clock::universal_time() );
42 
43  //
44  IOVEditor( const IOVEditor& rhs );
45 
46  //
47  IOVEditor& operator=( const IOVEditor& rhs );
48 
49  // loads to tag to edit
50  void load( const std::string& tag );
51 
52  // read only getters. they could be changed to return references...
53  std::string tag() const;
54  cond::TimeType timeType() const;
55  std::string payloadType() const;
56 
57  // getters/setters for the updatable parameters
59  void setSynchronizationType( cond::SynchronizationType synchronizationType );
60 
62  void setEndOfValidity( cond::Time_t validity );
63 
64  std::string description() const;
65  void setDescription( const std::string& description );
66 
69 
70  // flag (hack) for the validation
71  void setValidationMode();
72 
73  // register a new insertion.
74  // if checkType==true, the payload corresponding to the specified id is verified to be the same type as the iov payloadObjectType
75  void insert( cond::Time_t since, const cond::Hash& payloadHash, bool checkType=false );
76  void insert( cond::Time_t since, const cond::Hash& payloadHash, const boost::posix_time::ptime& insertionTime, bool checkType=false );
77 
78  // execute the update/intert queries and reset the buffer
79  bool flush();
80  bool flush( const boost::posix_time::ptime& operationTime );
81  bool flush( const std::string& logText );
82  bool flush( const std::string& logText, bool forceInsertion );
83 
84  private:
85  bool flush( const std::string& logText, const boost::posix_time::ptime& operationTime, bool forceInsertion );
86  void checkTransaction( const std::string& ctx );
87 
88  private:
89  std::shared_ptr<IOVEditorData> m_data;
90  std::shared_ptr<SessionImpl> m_session;
91 
92  };
93 
94  }
95 }
96 
97 #endif
98 
void checkTransaction(const std::string &ctx)
Definition: IOVEditor.cc:263
void load(const std::string &tag)
Definition: IOVEditor.cc:75
void setDescription(const std::string &description)
Definition: IOVEditor.cc:128
void setLastValidatedTime(cond::Time_t time)
Definition: IOVEditor.cc:140
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:90
TimeType
Definition: Time.h:21
std::string description() const
Definition: IOVEditor.cc:124
unsigned long long Time_t
Definition: Time.h:16
std::string Hash
Definition: Types.h:45
IOVEditor & operator=(const IOVEditor &rhs)
Definition: IOVEditor.cc:69
cond::SynchronizationType synchronizationType() const
Definition: IOVEditor.cc:100
cond::Time_t endOfValidity() const
Definition: IOVEditor.cc:112
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:152
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:89
cond::TimeType timeType() const
Definition: IOVEditor.cc:92
cond::Time_t lastValidatedTime() const
Definition: IOVEditor.cc:136
Definition: plugin.cc:24
SynchronizationType
Definition: Types.h:29
void setEndOfValidity(cond::Time_t validity)
Definition: IOVEditor.cc:116
std::string tag() const
Definition: IOVEditor.cc:87
void setSynchronizationType(cond::SynchronizationType synchronizationType)
Definition: IOVEditor.cc:104
std::string payloadType() const
Definition: IOVEditor.cc:96