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_IOVService_IOVProxy_h
2 #define CondCore_IOVService_IOVProxy_h
3 
7 
8 #include <string>
10 #include <boost/shared_ptr.hpp>
11 #include <boost/iterator/transform_iterator.hpp>
12 #include <boost/iterator/counting_iterator.hpp>
13 
14 namespace cond {
15 
16  class IOVSequence;
17  typedef IOVSequence IOV;
18 
20  public:
22  explicit IOVElementProxy(cond::DbSession& dbSession) :
23  m_since(cond::invalidTime), m_till(cond::invalidTime), m_dbSession( dbSession ){}
25  cond::Time_t it,
26  std::string const& itoken,
27  cond::DbSession& dbSession) :
28  m_since(is), m_till(it), m_token(itoken), m_dbSession( dbSession ){}
29 
30  void set(cond::Time_t is,
31  cond::Time_t it,
32  std::string const& itoken ) {
33  m_since=is; m_till=it; m_token=itoken;
34  }
35 
36  void set(IOV const & v, int i);
37 
38  cond::Time_t since() const {return m_since;}
39  cond::Time_t till() const {return m_till;}
40  std::string const & token() const {return m_token;}
41  std::string const & wrapperToken() const {return m_token;}
42  cond::DbSession& db() const { return m_dbSession; }
43 
44  private:
47  std::string m_token;
49  };
50 
51 
52  namespace impl {
53  struct IOVImpl;
54  }
55 
56  /* IOV as the user wants it
57  */
58  class IOVProxy {
59  public:
60 
61  IOVProxy();
62  ~IOVProxy();
63 
64  IOVProxy(cond::DbSession& dbSession,
65  const std::string & token,
66  bool nolib,
67  bool keepOpen);
68 
69  struct IterHelp {
71  IterHelp() : iov(0){}
73 
74  result_type const & operator()(int i) const {
75  if (iov) elem.set(*iov,i);
76  return elem;
77  }
78 
79  private:
80  IOV const * iov;
82  };
83 
84  typedef boost::transform_iterator<IterHelp,boost::counting_iterator<int> > const_iterator;
85 
87  return boost::make_transform_iterator(boost::counting_iterator<int>(m_low),
88  IterHelp(*m_iov));
89  }
90 
91  const_iterator end() const {
92  return boost::make_transform_iterator(boost::counting_iterator<int>(m_high),
93  IterHelp(*m_iov));
94  }
95 
96  // find in range...
98 
99  // limit range
100  void resetRange() const;
101  void setRange(cond::Time_t since, cond::Time_t till) const;
102  // limit to the first n
103  void head(int n) const;
104  // limit to the last n
105  void tail(int n) const;
106 
107  int size() const;
108  IOV const & iov() const;
109  TimeType timetype() const;
110  std::string payloadContainerName() const;
111  std::string comment() const;
112  int revision() const;
113  cond::Time_t timestamp() const;
114 
116  return SequenceState(iov());
117  }
118 
119 
120 
121 
122  DbSession& db() const;
123 
124  bool refresh();
125 
126  private:
127  boost::shared_ptr<impl::IOVImpl> m_iov;
128  mutable int m_low;
129  mutable int m_high;
130 
131  };
132 }
133 
134 #endif // CondCore_IOVService_IOVProxy_h
int i
Definition: DBlmapReader.cc:9
cond::Time_t m_since
Definition: IOVProxy.h:45
std::string comment() const
Definition: IOVProxy.cc:143
cond::Time_t timestamp() const
Definition: IOVProxy.cc:152
Definition: IOV.h:12
DbSession & db() const
Definition: IOVProxy.cc:156
const_iterator begin() const
Definition: IOVProxy.h:86
cond::Time_t till() const
Definition: IOVProxy.h:39
std::string payloadContainerName() const
Definition: IOVProxy.cc:135
const_iterator end() const
Definition: IOVProxy.h:91
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: IOVProxy.h:84
TimeType timetype() const
Definition: IOVProxy.cc:129
TimeType
Definition: Time.h:21
cond::Time_t m_till
Definition: IOVProxy.h:46
const_iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:112
IOVElementProxy result_type
Definition: IOVProxy.h:70
unsigned long long Time_t
Definition: Time.h:16
std::string const & wrapperToken() const
Definition: IOVProxy.h:41
void set(cond::Time_t is, cond::Time_t it, std::string const &itoken)
Definition: IOVProxy.h:30
std::string const & token() const
Definition: IOVProxy.h:40
std::string m_token
Definition: IOVProxy.h:47
cond::DbSession m_dbSession
Definition: IOVProxy.h:48
void head(int n) const
Definition: IOVProxy.cc:103
const Time_t invalidTime(0)
IOVElementProxy elem
Definition: IOVProxy.h:81
IOV const & iov() const
Definition: IOVProxy.cc:125
IOVElementProxy(cond::Time_t is, cond::Time_t it, std::string const &itoken, cond::DbSession &dbSession)
Definition: IOVProxy.h:24
int revision() const
Definition: IOVProxy.cc:148
void tail(int n) const
Definition: IOVProxy.cc:107
result_type const & operator()(int i) const
Definition: IOVProxy.h:74
int size() const
Definition: IOVProxy.cc:121
bool refresh()
Definition: IOVProxy.cc:80
boost::shared_ptr< impl::IOVImpl > m_iov
Definition: IOVProxy.h:127
IOVElementProxy(cond::DbSession &dbSession)
Definition: IOVProxy.h:22
void resetRange() const
Definition: IOVProxy.cc:88
cond::Time_t since() const
Definition: IOVProxy.h:38
IOVSequence IOV
Definition: IOVProxy.h:16
cond::DbSession & db() const
Definition: IOVProxy.h:42
void setRange(cond::Time_t since, cond::Time_t till) const
Definition: IOVProxy.cc:94
SequenceState state() const
Definition: IOVProxy.h:115
mathSSE::Vec4< T > v