CMS 3D CMS Logo

GTProxy.h
Go to the documentation of this file.
1 #ifndef CondCore_CondDB_GTProxy_h
2 #define CondCore_CondDB_GTProxy_h
3 //
4 // Package: CondDB
5 // Class : GTProxy
6 //
10 //
11 // Author: Giacomo Govi
12 // Created: Jul 2013
13 //
14 
17 //
18 #include <boost/date_time/posix_time/posix_time.hpp>
19 
20 namespace cond {
21 
22  namespace persistency {
23 
24  // required to handle the tag overriding
26  std::pair<std::string, std::string> parseTag(const std::string& tag);
27 
28  class SessionImpl;
29  class GTProxyData;
30 
31  // value semantics. to be used WITHIN the parent session transaction ( therefore the session should be kept alive ).
32  class GTProxy {
33  public:
34  typedef std::vector<std::tuple<std::string, std::string, std::string> > GTContainer;
35 
36  public:
37  // more or less compliant with typical iterator semantics...
38  class Iterator : public std::iterator<std::input_iterator_tag, cond::GTEntry_t> {
39  public:
40  //
41  Iterator();
42  explicit Iterator(GTContainer::const_iterator current);
43  Iterator(const Iterator& rhs);
44 
45  //
46  Iterator& operator=(const Iterator& rhs);
47 
48  // returns a VALUE not a reference!
50 
51  //
53  Iterator operator++(int);
54 
55  //
56  bool operator==(const Iterator& rhs) const;
57  bool operator!=(const Iterator& rhs) const;
58 
59  private:
60  GTContainer::const_iterator m_current;
61  };
62 
63  public:
64  GTProxy();
65  // the only way to construct it from scratch...
66  explicit GTProxy(const std::shared_ptr<SessionImpl>& session);
67 
68  //
69  GTProxy(const GTProxy& rhs);
70 
71  //
72  GTProxy& operator=(const GTProxy& rhs);
73 
74  // loads in memory the gtag information and the tags. to be resurrected after the changeover.
75  //void load( const std::string& gtName );
76 
77  // overloading for pre- and post-fix. Used in the ORA implementation
78  void load(const std::string& gtName, const std::string& preFix = "", const std::string& postFix = "");
79 
80  // reset the data in memory and execute again the queries for the current tag
81  void reload();
82 
83  // clear all the iov data in memory
84  void reset();
85 
86  std::string name() const;
87 
88  cond::Time_t validity() const;
89 
90  boost::posix_time::ptime snapshotTime() const;
91 
92  // start the iteration.
93  Iterator begin() const;
94 
95  //
96  Iterator end() const;
97 
98  //
99  int size() const;
100 
101  private:
102  void checkTransaction(const std::string& ctx);
103 
104  private:
105  std::shared_ptr<GTProxyData> m_data;
106  std::shared_ptr<SessionImpl> m_session;
107  };
108 
109  } // namespace persistency
110 } // namespace cond
111 
112 #endif
cond::persistency::GTProxy::Iterator::Iterator
Iterator()
Definition: GTProxy.cc:43
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
cond::persistency::GTProxy::Iterator::operator==
bool operator==(const Iterator &rhs) const
Definition: GTProxy.cc:69
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
cond::persistency::GTProxy::checkTransaction
void checkTransaction(const std::string &ctx)
Definition: GTProxy.cc:139
cond::persistency::GTProxy::m_data
std::shared_ptr< GTProxyData > m_data
Definition: GTProxy.h:105
cond::GTEntry_t
Definition: Types.h:109
cond::persistency::GTProxy::validity
cond::Time_t validity() const
Definition: GTProxy.cc:133
cond
Definition: plugin.cc:23
Time.h
cond::persistency::GTProxy::Iterator::operator*
cond::GTEntry_t operator*()
Definition: GTProxy.cc:56
cond::persistency::GTProxy::Iterator
Definition: GTProxy.h:38
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
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
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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::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
Types.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