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  std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime > getMetadata() const;
97 
98  // returns true if at least one IOV is in the sequence.
99  bool isEmpty() const;
100 
101  // 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.
102  // returns data only when a find or a load( tag, true ) have been at least called once.
103  Iterator begin() const;
104 
105  // the real end of the LOADED iov sequence subset.
106  Iterator end() const;
107 
108  // searches the DB for a valid iov containing the specified time.
109  // if the available iov sequence subset contains the target time, it does not issue a new query.
110  // otherwise, a new query will be executed using the resolved group boundaries.
112 
113  // searches the DB for a valid iov containing the specified time.
114  // if the available iov sequence subset contains the target time, it does not issue a new query.
115  // otherwise, a new query will be executed using the resolved group boundaries.
116  // throws if the target time cannot be found.
118 
119  // it does NOT use the cache, every time it performs a new query.
121 
122  // the size of the LOADED iov sequence subset. Matches the sequence size if a load( tag, true ) has been called.
123  int loadedSize() const;
124 
125  // the size of the entire iov sequence. Peforms a query at every call.
126  int sequenceSize() const;
127 
128  // for reporting
129  size_t numberOfQueries() const;
130 
131  // for debugging
132  std::pair<cond::Time_t,cond::Time_t> loadedGroup() const;
133 
134  // maybe will be removed with a re-design of the top level interface (ESSources )
135  const std::shared_ptr<SessionImpl>& session() const;
136 
137  private:
138  void checkTransaction( const std::string& ctx ) const ;
139  void fetchSequence( cond::Time_t lowerGroup, cond::Time_t higherGroup );
140 
141  private:
142  std::shared_ptr<IOVProxyData> m_data;
143  std::shared_ptr<SessionImpl> m_session;
144  };
145 
146  }
147 }
148 
149 #endif
150 
void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup)
Definition: IOVProxy.cc:205
void checkTransaction(const std::string &ctx) const
Definition: IOVProxy.cc:200
cond::SynchronizationType synchronizationType() const
Definition: IOVProxy.cc:174
std::shared_ptr< SessionImpl > m_session
Definition: IOVProxy.h:143
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:335
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:228
Iterator & operator=(const Iterator &rhs)
Definition: IOVProxy.cc:54
std::tuple< std::string, boost::posix_time::ptime, boost::posix_time::ptime > getMetadata() const
Definition: IOVProxy.cc:186
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:258
cond::Iov_t getInterval(cond::Time_t time)
Definition: IOVProxy.cc:303
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:142
SynchronizationType
Definition: Types.h:31
bool operator==(const Iterator &rhs) const
Definition: IOVProxy.cc:93
size_t numberOfQueries() const
Definition: IOVProxy.cc:331
Iterator end() const
Definition: IOVProxy.cc:236
const std::shared_ptr< SessionImpl > & session() const
Definition: IOVProxy.cc:339