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 {
39  public:
40  // C++17 compliant iterator definition
41  using iterator_category = std::input_iterator_tag;
43  using difference_type = void; // Not used
44  using pointer = void; // Not used
45  using reference = void; // Not used
46 
47  //
48  Iterator();
49  explicit Iterator(GTContainer::const_iterator current);
50  Iterator(const Iterator& rhs);
51 
52  //
53  Iterator& operator=(const Iterator& rhs);
54 
55  // returns a VALUE not a reference!
57 
58  //
60  Iterator operator++(int);
61 
62  //
63  bool operator==(const Iterator& rhs) const;
64  bool operator!=(const Iterator& rhs) const;
65 
66  private:
67  GTContainer::const_iterator m_current;
68  };
69 
70  public:
71  GTProxy();
72  // the only way to construct it from scratch...
73  explicit GTProxy(const std::shared_ptr<SessionImpl>& session);
74 
75  //
76  GTProxy(const GTProxy& rhs);
77 
78  //
79  GTProxy& operator=(const GTProxy& rhs);
80 
81  // loads in memory the gtag information and the tags. to be resurrected after the changeover.
82  //void load( const std::string& gtName );
83 
84  // overloading for pre- and post-fix. Used in the ORA implementation
85  void load(const std::string& gtName, const std::string& preFix = "", const std::string& postFix = "");
86 
87  // reset the data in memory and execute again the queries for the current tag
88  void reload();
89 
90  // clear all the iov data in memory
91  void reset();
92 
93  std::string name() const;
94 
95  cond::Time_t validity() const;
96 
97  boost::posix_time::ptime snapshotTime() const;
98 
99  // start the iteration.
100  Iterator begin() const;
101 
102  //
103  Iterator end() const;
104 
105  //
106  int size() const;
107 
108  private:
109  void checkTransaction(const std::string& ctx);
110 
111  private:
112  std::shared_ptr<GTProxyData> m_data;
113  std::shared_ptr<SessionImpl> m_session;
114  };
115 
116  } // namespace persistency
117 } // namespace cond
118 
119 #endif
GTContainer::const_iterator m_current
Definition: GTProxy.h:67
Iterator begin() const
Definition: GTProxy.cc:146
GTProxy & operator=(const GTProxy &rhs)
Definition: GTProxy.cc:83
Iterator & operator=(const Iterator &rhs)
Definition: GTProxy.cc:49
void checkTransaction(const std::string &ctx)
Definition: GTProxy.cc:139
cond::Time_t validity() const
Definition: GTProxy.cc:133
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
bool operator==(const Iterator &rhs) const
Definition: GTProxy.cc:69
unsigned long long Time_t
Definition: Time.h:14
std::pair< std::string, std::string > parseTag(const std::string &tag)
Definition: GTProxy.cc:14
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:107
std::string name() const
Definition: GTProxy.cc:131
std::shared_ptr< GTProxyData > m_data
Definition: GTProxy.h:112
std::string fullyQualifiedTag(const std::string &tag, const std::string &connectionString)
Definition: GTProxy.cc:8
std::vector< std::tuple< std::string, std::string, std::string > > GTContainer
Definition: GTProxy.h:34
boost::posix_time::ptime snapshotTime() const
Definition: GTProxy.cc:135
bool operator!=(const Iterator &rhs) const
Definition: GTProxy.cc:75
std::shared_ptr< SessionImpl > m_session
Definition: GTProxy.h:113
std::input_iterator_tag iterator_category
Definition: GTProxy.h:41
Iterator end() const
Definition: GTProxy.cc:153