CMS 3D CMS Logo

GTProxy.cc
Go to the documentation of this file.
2 #include "SessionImpl.h"
3 
4 namespace cond {
5 
6  namespace persistency {
7 
9  if (connectionString.empty())
10  return tag;
11  return tag + "@[" + connectionString + "]";
12  }
13 
14  std::pair<std::string, std::string> parseTag(const std::string& tag) {
15  std::string pfn("");
16  std::string t(tag);
17  size_t pos = tag.rfind("[");
18  if (pos != std::string::npos && tag.size() >= pos + 2) {
19  if (tag[pos - 1] == '@' && tag[tag.size() - 1] == ']') {
20  pfn = tag.substr(pos + 1, tag.size() - pos - 2);
21  t = tag.substr(0, pos - 1);
22  }
23  }
24  return std::make_pair(t, pfn);
25  }
26 
27  // implementation details...
28  // only hosting data in this case
29  class GTProxyData {
30  public:
31  GTProxyData() : name(""), preFix(""), postFix(""), tagList() {}
32 
34  // will become useless after the transition...
38  boost::posix_time::ptime snapshotTime;
39  // tag list
41  };
42 
43  GTProxy::Iterator::Iterator() : m_current() {}
44 
45  GTProxy::Iterator::Iterator(GTContainer::const_iterator current) : m_current(current) {}
46 
47  GTProxy::Iterator::Iterator(const Iterator& rhs) : m_current(rhs.m_current) {}
48 
50  if (this != &rhs) {
51  m_current = rhs.m_current;
52  }
53  return *this;
54  }
55 
57 
59  m_current++;
60  return *this;
61  }
62 
64  Iterator tmp(*this);
65  operator++();
66  return tmp;
67  }
68 
69  bool GTProxy::Iterator::operator==(const Iterator& rhs) const {
70  if (m_current != rhs.m_current)
71  return false;
72  return true;
73  }
74 
75  bool GTProxy::Iterator::operator!=(const Iterator& rhs) const { return !operator==(rhs); }
76 
78 
79  GTProxy::GTProxy(const std::shared_ptr<SessionImpl>& session) : m_data(new GTProxyData), m_session(session) {}
80 
81  GTProxy::GTProxy(const GTProxy& rhs) : m_data(rhs.m_data), m_session(rhs.m_session) {}
82 
84  m_data = rhs.m_data;
85  m_session = rhs.m_session;
86  return *this;
87  }
88 
106  // overloading for pre- and post-fix. Used in the ORA implementation
107  void GTProxy::load(const std::string& gtName, const std::string& pref, const std::string& postf) {
108  // clear
109  reset();
110 
111  checkTransaction("GTProxy::load");
112 
113  if (!m_session->gtSchema().gtTable().select(gtName, m_data->validity, m_data->snapshotTime)) {
114  throwException("Global Tag \"" + gtName + "\" has not been found in the database.", "GTProxy::load");
115  }
116  m_data->name = gtName;
117  m_data->preFix = pref;
118  m_data->postFix = postf;
119 
120  m_session->gtSchema().gtMapTable().select(m_data->name, pref, postf, m_data->tagList);
121  }
122 
123  void GTProxy::reload() { load(m_data->name); }
124 
125  void GTProxy::reset() {
126  if (m_data.get()) {
127  m_data->tagList.clear();
128  }
129  }
130 
131  std::string GTProxy::name() const { return m_data.get() ? m_data->name : std::string(""); }
132 
133  cond::Time_t GTProxy::validity() const { return m_data.get() ? m_data->validity : cond::time::MIN_VAL; }
134 
135  boost::posix_time::ptime GTProxy::snapshotTime() const {
136  return m_data.get() ? m_data->snapshotTime : boost::posix_time::ptime();
137  }
138 
140  if (!m_session.get())
141  throwException("The session is not active.", ctx);
142  if (!m_session->isTransactionActive(false))
143  throwException("The transaction is not active.", ctx);
144  }
145 
147  if (m_data.get()) {
148  return Iterator(m_data->tagList.begin());
149  }
150  return Iterator();
151  }
152 
154  if (m_data.get()) {
155  return Iterator(m_data->tagList.end());
156  }
157  return Iterator();
158  }
159 
160  int GTProxy::size() const { return m_data.get() ? m_data->tagList.size() : 0; }
161 
162  } // namespace persistency
163 } // namespace cond
cond::persistency::GTProxy::Iterator::Iterator
Iterator()
Definition: GTProxy.cc:43
cond::persistency::GTProxyData::GTProxyData
GTProxyData()
Definition: GTProxy.cc:31
cond::time::MIN_VAL
const Time_t MIN_VAL(0)
cond::persistency::GTProxy::reset
void reset()
Definition: GTProxy.cc:125
cond::persistency::GTProxy
Definition: GTProxy.h:32
cond::persistency::GTProxy::reload
void reload()
Definition: GTProxy.cc:123
pos
Definition: PixelAliasList.h:18
cond::persistency::GTProxy::Iterator::operator==
bool operator==(const Iterator &rhs) const
Definition: GTProxy.cc:69
cond::persistency::GTProxyData::validity
cond::Time_t validity
Definition: GTProxy.cc:37
cond::persistency::GTProxyData
Definition: GTProxy.cc:29
cond::persistency::GTProxy::operator=
GTProxy & operator=(const GTProxy &rhs)
Definition: GTProxy.cc:83
cond::persistency::GTProxy::size
int size() const
Definition: GTProxy.cc:160
cond::persistency::fullyQualifiedTag
std::string fullyQualifiedTag(const std::string &tag, const std::string &connectionString)
Definition: GTProxy.cc:8
cond::persistency::GTProxy::end
Iterator end() const
Definition: GTProxy.cc:153
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
cond::persistency::GTProxy::checkTransaction
void checkTransaction(const std::string &ctx)
Definition: GTProxy.cc:139
cond::persistency::GTProxyData::tagList
GTProxy::GTContainer tagList
Definition: GTProxy.cc:40
cond::persistency::GTProxyData::preFix
std::string preFix
Definition: GTProxy.cc:35
cms::Iterator
TGeoIterator Iterator
Definition: DDFilteredView.h:49
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
cond::persistency::GTProxy::m_data
std::shared_ptr< GTProxyData > m_data
Definition: GTProxy.h:105
cond::GTEntry_t
Definition: Types.h:109
SessionImpl.h
cond::persistency::GTProxy::validity
cond::Time_t validity() const
Definition: GTProxy.cc:133
cond::persistency::GTProxyData::snapshotTime
boost::posix_time::ptime snapshotTime
Definition: GTProxy.cc:38
OrderedSet.t
t
Definition: OrderedSet.py:90
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cond
Definition: plugin.cc:23
operator==
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
Definition: QGLikelihoodObject.h:49
cond::persistency::GTProxy::Iterator::operator*
cond::GTEntry_t operator*()
Definition: GTProxy.cc:56
cond::persistency::GTProxy::Iterator
Definition: GTProxy.h:38
cond::Time_t
unsigned long long Time_t
Definition: Time.h:14
cond::persistency::parseTag
std::pair< std::string, std::string > parseTag(const std::string &tag)
Definition: GTProxy.cc:14
cond::persistency::GTProxy::load
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:107
cond::persistency::GTProxyData::name
std::string name
Definition: GTProxy.cc:33
cond::persistency::GTProxyData::postFix
std::string postFix
Definition: GTProxy.cc:36
cond::persistency::GTProxy::Iterator::operator!=
bool operator!=(const Iterator &rhs) const
Definition: GTProxy.cc:75
cond::persistency::GTProxy::Iterator::m_current
GTContainer::const_iterator m_current
Definition: GTProxy.h:60
cond::persistency::throwException
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:12
cond::persistency::GTProxy::snapshotTime
boost::posix_time::ptime snapshotTime() const
Definition: GTProxy.cc:135
cond::persistency::GTProxy::Iterator::operator++
Iterator & operator++()
Definition: GTProxy.cc:58
cond::persistency::GTProxy::Iterator::operator=
Iterator & operator=(const Iterator &rhs)
Definition: GTProxy.cc:49
GTProxy.h
l1RCTOmdsFedVectorProducer_cfi.connectionString
connectionString
Definition: l1RCTOmdsFedVectorProducer_cfi.py:4
cond::persistency::GTProxy::GTProxy
GTProxy()
Definition: GTProxy.cc:77
cond::persistency::GTProxy::GTContainer
std::vector< std::tuple< std::string, std::string, std::string > > GTContainer
Definition: GTProxy.h:34
cond::persistency::GTProxy::name
std::string name() const
Definition: GTProxy.cc:131
cond::persistency::GTProxy::begin
Iterator begin() const
Definition: GTProxy.cc:146
cond::persistency::GTProxy::m_session
std::shared_ptr< SessionImpl > m_session
Definition: GTProxy.h:106