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 : public std::iterator<std::input_iterator_tag, cond::RunInfo_t> {
33  public:
34  //
35  Iterator();
36  explicit Iterator(RunInfoData::const_iterator current);
37  Iterator(const Iterator& rhs);
38 
39  //
40  Iterator& operator=(const Iterator& rhs);
41 
42  // returns a VALUE not a reference!
44 
45  //
47  Iterator operator++(int);
48 
49  //
50  bool operator==(const Iterator& rhs) const;
51  bool operator!=(const Iterator& rhs) const;
52 
53  private:
54  RunInfoData::const_iterator m_current;
55  };
56 
57  public:
58  RunInfoProxy();
59 
60  //
61  explicit RunInfoProxy(const std::shared_ptr<SessionImpl>& session);
62 
63  //
64  RunInfoProxy(const RunInfoProxy& rhs);
65 
66  //
67  RunInfoProxy& operator=(const RunInfoProxy& rhs);
68 
69  // loads in memory the RunInfo data for the specified run range
70  void load(Time_t low, Time_t up);
71 
72  // loads in memory the RunInfo data for the specified run range
73  void load(const boost::posix_time::ptime& low, const boost::posix_time::ptime& up);
74 
75  // clear all the iov data in memory
76  void reset();
77 
78  // start the iteration.
79  Iterator begin() const;
80 
81  //
82  Iterator end() const;
83 
84  //
85  Iterator find(Time_t target) const;
86 
87  //
88  Iterator find(const boost::posix_time::ptime& target) const;
89 
90  //
91  cond::RunInfo_t get(Time_t target) const;
92 
93  //
94  cond::RunInfo_t get(const boost::posix_time::ptime& target) const;
95 
96  //
97  int size() const;
98 
99  private:
100  void checkTransaction(const std::string& ctx);
101 
102  private:
103  std::shared_ptr<RunInfoProxyData> m_data;
104  std::shared_ptr<SessionImpl> m_session;
105  };
106 
107  } // namespace persistency
108 } // namespace cond
109 
110 #endif
Definition: BitonicSort.h:7
void load(Time_t low, Time_t up)
Definition: RunInfoProxy.cc:66
std::shared_ptr< SessionImpl > m_session
Definition: RunInfoProxy.h:104
RunInfoData::const_iterator m_current
Definition: RunInfoProxy.h:54
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:103
std::vector< std::tuple< Time_t, boost::posix_time::ptime, boost::posix_time::ptime > > RunInfoData
Definition: RunInfoProxy.h:28