CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
GTContainer::const_iterator m_current
Definition: GTProxy.h:60
GTProxy & operator=(const GTProxy &rhs)
Definition: GTProxy.cc:83
Iterator & operator=(const Iterator &rhs)
Definition: GTProxy.cc:49
bool operator==(const Iterator &rhs) const
Definition: GTProxy.cc:69
void checkTransaction(const std::string &ctx)
Definition: GTProxy.cc:139
cond::Time_t validity() const
Definition: GTProxy.cc:133
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::shared_ptr< GTProxyData > m_data
Definition: GTProxy.h:105
boost::posix_time::ptime snapshotTime() const
Definition: GTProxy.cc:135
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
Iterator begin() const
Definition: GTProxy.cc:146
Iterator end() const
Definition: GTProxy.cc:153
std::string name() const
Definition: GTProxy.cc:131
bool operator!=(const Iterator &rhs) const
Definition: GTProxy.cc:75
std::shared_ptr< SessionImpl > m_session
Definition: GTProxy.h:106