CMS 3D CMS Logo

RunInfoProxy.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_RunInfoProxy_h
2 #define CondCore_CondDB_RunInfoProxy_h
3 //
4 // Package: CondDB
5 // Class : RunInfoProxy
6 //
10 //
11 // Author: Giacomo Govi
12 // Created: Dec 2016
13 //
14 
16 //
17 
18 namespace cond {
19 
20  namespace persistency {
21 
22  class SessionImpl;
23  class RunInfoProxyData;
24 
25  // value semantics. to be used WITHIN the parent session transaction ( therefore the session should be kept alive ).
26  class RunInfoProxy {
27  public:
28  typedef std::vector<std::tuple<Time_t, boost::posix_time::ptime, boost::posix_time::ptime> > RunInfoData;
29 
30  public:
31  // more or less compliant with typical iterator semantics...
32  class Iterator {
33  public:
34  // C++17 compliant iterator definition
35  using iterator_category = std::input_iterator_tag;
37  using difference_type = void; // Not used
38  using pointer = void; // Not used
39  using reference = void; // Not used
40 
41  //
42  Iterator();
43  explicit Iterator(RunInfoData::const_iterator current);
44  Iterator(const Iterator& rhs);
45 
46  //
47  Iterator& operator=(const Iterator& rhs);
48 
49  // returns a VALUE not a reference!
51 
52  //
54  Iterator operator++(int);
55 
56  //
57  bool operator==(const Iterator& rhs) const;
58  bool operator!=(const Iterator& rhs) const;
59 
60  private:
61  RunInfoData::const_iterator m_current;
62  };
63 
64  public:
65  RunInfoProxy();
66 
67  //
68  explicit RunInfoProxy(const std::shared_ptr<SessionImpl>& session);
69 
70  //
71  RunInfoProxy(const RunInfoProxy& rhs);
72 
73  //
74  RunInfoProxy& operator=(const RunInfoProxy& rhs);
75 
76  // loads in memory the RunInfo data for the specified run range
77  void load(Time_t low, Time_t up);
78 
79  // loads in memory the RunInfo data for the specified run range
80  void load(const boost::posix_time::ptime& low, const boost::posix_time::ptime& up);
81 
82  // clear all the iov data in memory
83  void reset();
84 
85  // start the iteration.
86  Iterator begin() const;
87 
88  //
89  Iterator end() const;
90 
91  //
92  Iterator find(Time_t target) const;
93 
94  //
95  Iterator find(const boost::posix_time::ptime& target) const;
96 
97  //
98  cond::RunInfo_t get(Time_t target) const;
99 
100  //
101  cond::RunInfo_t get(const boost::posix_time::ptime& target) const;
102 
103  //
104  int size() const;
105 
106  private:
107  void checkTransaction(const std::string& ctx);
108 
109  private:
110  std::shared_ptr<RunInfoProxyData> m_data;
111  std::shared_ptr<SessionImpl> m_session;
112  };
113 
114  } // namespace persistency
115 } // namespace cond
116 
117 #endif
Definition: BitonicSort.h:7
std::input_iterator_tag iterator_category
Definition: RunInfoProxy.h:35
void load(Time_t low, Time_t up)
Definition: RunInfoProxy.cc:66
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoProxy.h:111
RunInfoData::const_iterator m_current
Definition: RunInfoProxy.h:61
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
unsigned long long Time_t
Definition: Time.h:14
Iterator find(Time_t target) const
RunInfoProxy & operator=(const RunInfoProxy &rhs)
Definition: RunInfoProxy.cc:59
bool operator!=(const Iterator &rhs) const
Definition: RunInfoProxy.cc:50
bool operator==(const Iterator &rhs) const
Definition: RunInfoProxy.cc:44
Iterator & operator=(const Iterator &rhs)
Definition: RunInfoProxy.cc:24
void checkTransaction(const std::string &ctx)
std::shared_ptr< RunInfoProxyData > m_data
Definition: RunInfoProxy.h:110
std::vector< std::tuple< Time_t, boost::posix_time::ptime, boost::posix_time::ptime > > RunInfoData
Definition: RunInfoProxy.h:28