CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  IOVEditor();
31  // ctor
32  explicit IOVEditor(const std::shared_ptr<SessionImpl>& session);
33 
34  // ctor used after new tag creation. the specified params are assumed and passed directly to the object.
35  IOVEditor(const std::shared_ptr<SessionImpl>& session,
36  const std::string& tag,
38  const std::string& payloadType,
40  const boost::posix_time::ptime& creationTime = boost::posix_time::microsec_clock::universal_time());
41 
42  //
43  IOVEditor(const IOVEditor& rhs);
44 
45  //
46  IOVEditor& operator=(const IOVEditor& rhs);
47 
48  //
49  ~IOVEditor();
50 
51  // loads to tag to edit
52  void load(const std::string& tag);
53 
54  // read only getters. they could be changed to return references...
55  std::string tag() const;
56  cond::TimeType timeType() const;
57  std::string payloadType() const;
58 
59  // getters/setters for the updatable parameters
61  void setSynchronizationType(cond::SynchronizationType synchronizationType);
62 
64  void setEndOfValidity(cond::Time_t validity);
65 
66  std::string description() const;
67  void setDescription(const std::string& description);
68 
71 
72  // register a new insertion.
73  // if checkType==true, the payload corresponding to the specified id is verified to be the same type as the iov payloadObjectType
74  void insert(cond::Time_t since, const cond::Hash& payloadHash, bool checkType = false);
75  void insert(cond::Time_t since,
76  const cond::Hash& payloadHash,
77  const boost::posix_time::ptime& insertionTime,
78  bool checkType = false);
79 
80  // register a new deletion.
81  void erase(cond::Time_t since, const cond::Hash& payloadHash);
82 
83  // execute the update/intert queries and reset the buffer
84  bool flush();
85  bool flush(const boost::posix_time::ptime& operationTime);
86  bool flush(const std::string& logText);
87  bool flush(const std::string& logText, bool forceInsertion);
88 
89  bool isLocked() const;
90  void lock();
91  void unlock();
92 
93  private:
94  bool flush(const std::string& logText, const boost::posix_time::ptime& operationTime, bool forceInsertion);
95  void checkTransaction(const std::string& ctx);
96 
97  private:
98  std::shared_ptr<IOVEditorData> m_data;
99  std::shared_ptr<SessionImpl> m_session;
100  };
101 
102  } // namespace persistency
103 } // namespace cond
104 
105 #endif
void checkTransaction(const std::string &ctx)
Definition: IOVEditor.cc:369
void load(const std::string &tag)
Definition: IOVEditor.cc:71
void setDescription(const std::string &description)
Definition: IOVEditor.cc:139
void setLastValidatedTime(cond::Time_t time)
Definition: IOVEditor.cc:151
std::shared_ptr< SessionImpl > m_session
Definition: IOVEditor.h:99
TimeType
Definition: Time.h:19
std::string description() const
Definition: IOVEditor.cc:137
unsigned long long Time_t
Definition: Time.h:14
std::string Hash
Definition: Types.h:43
IOVEditor & operator=(const IOVEditor &rhs)
Definition: IOVEditor.cc:65
cond::SynchronizationType synchronizationType() const
Definition: IOVEditor.cc:115
void erase(cond::Time_t since, const cond::Hash &payloadHash)
Definition: IOVEditor.cc:174
cond::Time_t endOfValidity() const
Definition: IOVEditor.cc:127
void insert(cond::Time_t since, const cond::Hash &payloadHash, bool checkType=false)
Definition: IOVEditor.cc:159
std::shared_ptr< IOVEditorData > m_data
Definition: IOVEditor.h:98
cond::TimeType timeType() const
Definition: IOVEditor.cc:111
cond::Time_t lastValidatedTime() const
Definition: IOVEditor.cc:147
SynchronizationType
Definition: Types.h:27
void setEndOfValidity(cond::Time_t validity)
Definition: IOVEditor.cc:129
std::string tag() const
Definition: IOVEditor.cc:109
void setSynchronizationType(cond::SynchronizationType synchronizationType)
Definition: IOVEditor.cc:119
std::string payloadType() const
Definition: IOVEditor.cc:113