CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOVEditor.h
Go to the documentation of this file.
1 #ifndef CondCore_IOVService_IOVEditor_h
2 #define CondCore_IOVService_IOVEditor_h
3 
5 
8 
9 //
10 // Package: CondCore/IOVService
11 // Class : IOVEditor
12 //
16 //
17 // Author: Zhen Xie
18 // Fixes and other changes: Giacomo Govi
19 //
20 
21 namespace cond{
22 
23  class IOVElement;
24  class IOVSequence;
25 
27  public:
28  explicit IOVImportIterator( boost::shared_ptr<cond::IOVProxyData>& destIov );
29 
30  virtual ~IOVImportIterator();
31 
32  void setUp( cond::IOVProxy& sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize = 1 );
33 
34  void setUp( cond::DbSession& sourceSess, const std::string& sourceIovToken, cond::Time_t since, cond::Time_t till,
35  bool outOfOrder, size_t bulkSize = 1 );
36 
37  void setUp( cond::IOVProxy& sourceIov, size_t bulkSize = 1 );
38 
39  void setUp( cond::DbSession& sourceSess, const std::string& sourceIovToken, size_t bulkSize = 1 );
40 
41  bool hasMoreElements();
42 
43  size_t importMoreElements();
44 
45  size_t importAll();
46 
47  private:
49  boost::shared_ptr<cond::IOVProxyData> m_destIov;
51  size_t m_bulkSize;
54  };
55 
56  class IOVEditor{
57  public:
58 
59  // default constructor
60  explicit IOVEditor(cond::DbSession& dbSess);
61 
62  // constructor from existing iov
63  IOVEditor( cond::DbSession& dbSess, const std::string& token);
64 
66  ~IOVEditor();
67 
68  void reload();
69 
70  void load( const std::string& token );
71 
73 
74  // create empty default sequence
75  std::string create( cond::TimeType timetype );
76 
77  // create empty sequence with fixed time boundary
78  std::string create(cond::TimeType timetype, cond::Time_t lastTill, const std::string& metadata );
79 
80  // ####### TO BE REOMOVED ONLY USED IN TESTS
81  std::string create(cond::TimeType timetype, cond::Time_t lastTill );
82 
84  unsigned int insert( cond::Time_t tillTime, const std::string& payloadToken );
85 
88  unsigned int append( cond::Time_t sinceTime, const std::string& payloadToken );
89 
91  unsigned int freeInsert( cond::Time_t sinceTime, const std::string& payloadToken );
92 
94  void bulkAppend( std::vector< std::pair<cond::Time_t, std::string > >& values );
95 
96  void bulkAppend(std::vector< cond::IOVElement >& values);
97 
98  //stamp iov
99  void stamp(std::string const & icomment, bool append=false);
100 
102  void editMetadata( std::string const & metadata, bool append=false);
103 
106 
108  void updateClosure( cond::Time_t newtillTime );
109 
110  // remove last entry
111  unsigned int truncate(bool withPayload=false);
112 
113  // delete all entries
114  void deleteEntries( bool withPayload=false);
115 
116  //
117  size_t import( cond::DbSession& sourceSess, const std::string& sourceIovToken );
118 
119  //
120  boost::shared_ptr<IOVImportIterator> importIterator();
121 
122  TimeType timetype() const;
123 
124  std::string const & token() const;
125 
127 
128  private:
129 
130  bool validTime(cond::Time_t time, cond::TimeType timetype) const;
131  bool validTime(cond::Time_t time) const;
132 
133  void debugInfo(std::ostream & co) const;
134  void reportError(std::string message) const;
135  void reportError(std::string message, cond::Time_t time) const;
136 
137  private:
138 
140  boost::shared_ptr<cond::IOVProxyData> m_iov;
141  };
142 }//ns cond
143 #endif
std::string create(cond::TimeType timetype)
Definition: IOVEditor.cc:244
void debugInfo(std::ostream &co) const
Definition: IOVEditor.cc:192
cond::IOVProxy proxy()
Definition: IOVEditor.cc:530
void load(const std::string &token)
Definition: IOVEditor.cc:186
void reportError(std::string message) const
Definition: IOVEditor.cc:215
bool validTime(cond::Time_t time, cond::TimeType timetype) const
Definition: IOVEditor.cc:268
std::string const & token() const
Definition: IOVEditor.cc:526
void setScope(cond::IOVSequence::ScopeType scope)
set the scope
Definition: IOVEditor.cc:379
Container::const_iterator const_iterator
Definition: IOVSequence.h:28
unsigned int freeInsert(cond::Time_t sinceTime, const std::string &payloadToken)
insert a payload with known since in any position
Definition: IOVEditor.cc:435
cond::IOVProxy m_sourceIov
Definition: IOVEditor.h:48
IOVSequence::const_iterator m_cursor
Definition: IOVEditor.h:52
TimeType
Definition: Time.h:21
IOVImportIterator(boost::shared_ptr< cond::IOVProxyData > &destIov)
Definition: IOVEditor.cc:50
unsigned int truncate(bool withPayload=false)
Definition: IOVEditor.cc:469
unsigned long long Time_t
Definition: Time.h:16
TimeType timetype() const
Definition: IOVEditor.cc:522
unsigned int insert(cond::Time_t tillTime, const std::string &payloadToken)
Assign a payload with till time. Returns the payload index in the iov sequence.
Definition: IOVEditor.cc:281
bool createIOVContainerIfNecessary()
Definition: IOVEditor.cc:233
IOVSequence::const_iterator m_till
Definition: IOVEditor.h:53
void updateClosure(cond::Time_t newtillTime)
Update the closure of the iov sequence.
Definition: IOVEditor.cc:389
unsigned int append(cond::Time_t sinceTime, const std::string &payloadToken)
Definition: IOVEditor.cc:400
cond::Time_t m_lastSince
Definition: IOVEditor.h:50
virtual ~IOVImportIterator()
Definition: IOVEditor.cc:60
void bulkAppend(std::vector< std::pair< cond::Time_t, std::string > > &values)
Bulk append of iov chunck.
Definition: IOVEditor.cc:305
void stamp(std::string const &icomment, bool append=false)
Definition: IOVEditor.cc:359
void deleteEntries(bool withPayload=false)
Definition: IOVEditor.cc:488
IOVEditor(cond::DbSession &dbSess)
Definition: IOVEditor.cc:170
boost::shared_ptr< IOVImportIterator > importIterator()
Definition: IOVEditor.cc:515
void setUp(cond::IOVProxy &sourceIov, cond::Time_t since, cond::Time_t till, bool outOfOrder, size_t bulkSize=1)
Definition: IOVEditor.cc:63
boost::shared_ptr< cond::IOVProxyData > m_destIov
Definition: IOVEditor.h:49
boost::shared_ptr< cond::IOVProxyData > m_iov
Definition: IOVEditor.h:140
~IOVEditor()
Destructor.
Definition: IOVEditor.cc:168
void editMetadata(std::string const &metadata, bool append=false)
edit metadata
Definition: IOVEditor.cc:369