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