CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOVProxy.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_IOVProxy_h
2 #define CondCore_CondDB_IOVProxy_h
3 //
4 // Package: CondDB
5 // Class : IOVProxy
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 IOVProxyData;
26 
27  // value semantics. to be used WITHIN the parent session transaction ( therefore the session should be kept alive ).
28  class IOVProxy {
29  public:
30  typedef std::vector<std::tuple<cond::Time_t,cond::Hash> > IOVContainer;
31  // more or less compliant with typical iterator semantics...
32  class Iterator : public std::iterator<std::input_iterator_tag, cond::Iov_t> {
33  public:
34  //
35  Iterator();
36  Iterator( IOVContainer::const_iterator current, IOVContainer::const_iterator end,
38  Iterator( const Iterator& rhs );
39 
40  //
41  Iterator& operator=( const Iterator& rhs );
42 
43  // returns a VALUE not a reference!
45 
46  //
48  Iterator operator++(int);
49 
50  //
51  bool operator==( const Iterator& rhs ) const;
52  bool operator!=( const Iterator& rhs ) const;
53 
54  private:
55  IOVContainer::const_iterator m_current;
56  IOVContainer::const_iterator m_end;
59  };
60 
61  public:
62  //
63  IOVProxy();
64 
65  // the only way to construct it from scratch...
66  explicit IOVProxy( const std::shared_ptr<SessionImpl>& session );
67 
68  //
69  IOVProxy( const IOVProxy& rhs );
70 
71  //
72  IOVProxy& operator=( const IOVProxy& rhs );
73 
74  // loads in memory the tag information and the iov groups
75  // full=true load the full iovSequence
76  void load( const std::string& tag, bool full=false );
77 
78  // reset the data in memory and execute again the queries for the current tag
79  void reload();
80 
81  // clear all the iov data in memory
82  void reset();
83 
84  std::string tag() const;
85 
86  cond::TimeType timeType() const;
87 
89 
91 
93 
95 
96  // returns true if at least one IOV is in the sequence.
97  bool isEmpty() const;
98 
99  // start the iteration. it referes to the LOADED iov sequence subset, which consists in two consecutive groups - or the entire sequence if it has been requested.
100  // returns data only when a find or a load( tag, true ) have been at least called once.
101  Iterator begin() const;
102 
103  // the real end of the LOADED iov sequence subset.
104  Iterator end() const;
105 
106  // searches the DB for a valid iov containing the specified time.
107  // if the available iov sequence subset contains the target time, it does not issue a new query.
108  // otherwise, a new query will be executed using the resolved group boundaries.
110 
111  // searches the DB for a valid iov containing the specified time.
112  // if the available iov sequence subset contains the target time, it does not issue a new query.
113  // otherwise, a new query will be executed using the resolved group boundaries.
114  // throws if the target time cannot be found.
116 
117  // it does NOT use the cache, every time it performs a new query.
119 
120  // the size of the LOADED iov sequence subset. Matches the sequence size if a load( tag, true ) has been called.
121  int loadedSize() const;
122 
123  // the size of the entire iov sequence. Peforms a query at every call.
124  int sequenceSize() const;
125 
126  // for reporting
127  size_t numberOfQueries() const;
128 
129  // for debugging
130  std::pair<cond::Time_t,cond::Time_t> loadedGroup() const;
131 
132  // maybe will be removed with a re-design of the top level interface (ESSources )
133  const std::shared_ptr<SessionImpl>& session() const;
134 
135  private:
136  void checkTransaction( const std::string& ctx ) const ;
137  void fetchSequence( cond::Time_t lowerGroup, cond::Time_t higherGroup );
138 
139  private:
140  std::shared_ptr<IOVProxyData> m_data;
141  std::shared_ptr<SessionImpl> m_session;
142  };
143 
144  }
145 }
146 
147 #endif
148 
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:195
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:190
cond::SynchronizationType synchronizationType() const
Definition: IOVProxy.cc:174
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:141
std::string tag() const
Definition: IOVProxy.cc:162
IOVProxy & operator=(const IOVProxy &rhs)
Definition: IOVProxy.cc:118
void load(const std::string &tag, bool full=false)
Definition: IOVProxy.cc:124
std::pair< cond::Time_t, cond::Time_t > loadedGroup() const
Definition: IOVProxy.cc:306
std::string payloadObjectType() const
Definition: IOVProxy.cc:170
bool operator!=(const Iterator &rhs) const
Definition: IOVProxy.cc:99
TimeType
Definition: Time.h:21
Iterator begin() const
Definition: IOVProxy.cc:205
Iterator & operator=(const Iterator &rhs)
Definition: IOVProxy.cc:54
cond::TimeType timeType() const
Definition: IOVProxy.cc:166
unsigned long long Time_t
Definition: Time.h:16
IOVContainer::const_iterator m_current
Definition: IOVProxy.h:55
std::vector< std::tuple< cond::Time_t, cond::Hash > > IOVContainer
Definition: IOVProxy.h:30
Definition: GenABIO.cc:180
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:235
cond::Iov_t getInterval(cond::Time_t time)
Definition: IOVProxy.cc:274
IOVContainer::const_iterator m_end
Definition: IOVProxy.h:56
cond::Time_t endOfValidity() const
Definition: IOVProxy.cc:178
cond::Time_t lastValidatedTime() const
Definition: IOVProxy.cc:182
std::shared_ptr< IOVProxyData > m_data
Definition: IOVProxy.h:140
SynchronizationType
Definition: Types.h:31
bool operator==(const Iterator &rhs) const
Definition: IOVProxy.cc:93
size_t numberOfQueries() const
Definition: IOVProxy.cc:302
Iterator end() const
Definition: IOVProxy.cc:213
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:310