CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOVProxy.cc
Go to the documentation of this file.
2 //#include "DataSvc/Ref.h"
3 
8 
10 
11 namespace cond {
12  namespace impl {
13 
14  struct IOVImpl {
16  const std::string & token,
17  bool /*nolib*/,
18  bool keepOpen) : poolDb(dbs), m_token(token), /*m_nolib(nolib),*/ m_keepOpen(keepOpen){
19  refresh();
20  if (m_keepOpen) {
22  poolDb.transaction().start(false);
23  else poolDb.transaction().start(true);
24  }
25  }
26 
27  void refresh() {
29  if(transaction.isActive() && !transaction.isReadOnly())
30  transaction.start(false);
31  else transaction.start(true);
33  transaction.commit();
34  /*
35  if (!iov->iovs().empty() && !m_nolib) {
36  // load dict (change: use IOV metadata....)
37  std::string ptok = iov->iovs().front().wrapperToken();
38  cond::reflexTypeByToken(ptok);
39  }
40  */
41  }
42 
45  }
46 
48  boost::shared_ptr<cond::IOVSequence> iov;
49  std::string m_token;
50  //bool m_nolib;
51  bool m_keepOpen;
52  };
53  }
54 
55  void IOVElementProxy::set(IOVSequence const & v, int ii) {
56  size_t i =ii;
57  if (i>=v.iovs().size()) {
59  return;
60  }
61  m_since = v.iovs()[i].sinceTime();
62  m_till = (i+1==v.iovs().size()) ? v.lastTill() : v.iovs()[i+1].sinceTime()-1;
63  m_token = v.iovs()[i].wrapperToken();
64  }
65 
67  iov(&(*impl.iov)), elem(impl.poolDb){}
68 
70 
72 
74  const std::string & token,
75  bool nolib,
76  bool keepOpen)
77  :m_iov(new impl::IOVImpl(dbSession,token,nolib,keepOpen)), m_low(0), m_high(size()){}
78 
79 
81  int oldsize = size();
82  m_iov->refresh();
83  bool anew = oldsize<size();
84  if (anew) m_high = size(); // FIXME
85  return anew;
86  }
87 
88  void IOVProxy::resetRange() const {
89  m_low=0;
90  m_high=size();
91  }
92 
93 
94  void IOVProxy::setRange(cond::Time_t since, cond::Time_t till) const {
95  m_low = (since<iov().iovs().front().sinceTime()) ? 0 :
96  iov().find(since)-iov().iovs().begin();
97  m_high=iov().find(till)-iov().iovs().begin();
99  }
100 
101 
102  //FIXME cannot be done twice....
103  void IOVProxy::head(int n) const {
105  }
106 
107  void IOVProxy::tail(int n) const {
108  m_low = std::max(m_high-n,m_low);
109  }
110 
111 
113  int n = iov().find(time)-iov().iovs().begin();
114  return (n<m_low || m_high<n ) ?
115  end() :
116  boost::make_transform_iterator(boost::counting_iterator<int>(n),
117  IterHelp(*m_iov));
118  }
119 
120 
121  int IOVProxy::size() const {
122  return iov().iovs().size();
123  }
124 
125  IOV const & IOVProxy::iov() const {
126  return *(*m_iov).iov;
127  }
128 
130  return iov().timeType();
131  }
132 
133 
134  std::string
136  // FIXME move to metadata
137  std::string payloadtokstr=iov().iovs().front().wrapperToken();
138  std::pair<std::string,int> oidData = parseToken( payloadtokstr );
139  return oidData.first;
140  }
141 
142  std::string
144  return iov().comment();
145  }
146 
147  int
149  return iov().revision();
150  }
151 
153  return iov().timestamp();
154  }
155 
157  return m_iov->poolDb;
158  }
159 
160 
161 
162 }
IOVImpl(cond::DbSession &dbs, const std::string &token, bool, bool keepOpen)
Definition: IOVProxy.cc:15
int i
Definition: DBlmapReader.cc:9
cond::Time_t lastTill() const
Definition: IOVSequence.h:63
cond::DbSession poolDb
Definition: IOVProxy.cc:47
boost::shared_ptr< cond::IOVSequence > iov
Definition: IOVProxy.cc:48
std::pair< std::string, int > parseToken(const std::string &objectId)
Definition: PoolToken.cc:16
cond::Time_t m_since
Definition: IOVProxy.h:45
DbTransaction & transaction()
Definition: DbSession.cc:153
int isActive() const
current transaction is active
std::string comment() const
Definition: IOVProxy.cc:143
cond::TimeType timeType() const
Definition: IOV.h:50
cond::Time_t timestamp() const
Definition: IOVProxy.cc:152
std::string m_token
Definition: IOVProxy.cc:49
Definition: IOV.h:12
DbSession & db() const
Definition: IOVProxy.cc:156
int commit()
commit transaction.
Container iov
Definition: IOV.h:53
Container const & iovs() const
Definition: IOVSequence.cc:54
bool isReadOnly() const
current transaction is readonly
#define min(a, b)
Definition: mlp_lapack.h:161
int isActive() const
current transaction is active
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
int start(bool readOnly=false)
start transaction
unsigned long long Time_t
Definition: Time.h:16
iterator find(cond::Time_t time)
Definition: IOV.h:31
tuple iov
Definition: o2o.py:307
const T & max(const T &a, const T &b)
void set(cond::Time_t is, cond::Time_t it, std::string const &itoken)
Definition: IOVProxy.h:30
std::string m_token
Definition: IOVProxy.h:47
void head(int n) const
Definition: IOVProxy.cc:103
const Time_t invalidTime(0)
IOV const & iov() const
Definition: IOVProxy.cc:125
int start(bool readOnly=false)
start transaction
int revision() const
Definition: IOVProxy.cc:148
void tail(int n) const
Definition: IOVProxy.cc:107
int size() const
Definition: IOVProxy.cc:121
bool refresh()
Definition: IOVProxy.cc:80
boost::shared_ptr< impl::IOVImpl > m_iov
Definition: IOVProxy.h:127
void resetRange() const
Definition: IOVProxy.cc:88
size_type size() const
Definition: PVector.h:102
void setRange(cond::Time_t since, cond::Time_t till) const
Definition: IOVProxy.cc:94
bool isReadOnly() const
current transaction is readonly
boost::shared_ptr< T > getTypedObject(const std::string &objectId)
Definition: DbSession.h:98
int commit()
commit transaction. Will disconnect from database if connection timeout==0 or connectted time close t...
tuple size
Write out results.
mathSSE::Vec4< T > v