CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 in the "bridge" mode, to be removed with the ORA based code after the transition
25  std::pair<std::string,std::string> parseTag( const std::string& tag );
26 
27  class SessionImpl;
28  class GTProxyData;
29 
30  // value semantics. to be used WITHIN the parent session transaction ( therefore the session should be kept alive ).
31  class GTProxy {
32  public:
33  typedef std::vector<std::tuple<std::string,std::string,std::string> > GTContainer;
34  public:
35  // more or less compliant with typical iterator semantics...
36  class Iterator : public std::iterator<std::input_iterator_tag, cond::GTEntry_t> {
37  public:
38  //
39  Iterator();
40  explicit Iterator( GTContainer::const_iterator current );
41  Iterator( const Iterator& rhs );
42 
43  //
44  Iterator& operator=( const Iterator& rhs );
45 
46  // returns a VALUE not a reference!
48 
49  //
51  Iterator operator++(int);
52 
53  //
54  bool operator==( const Iterator& rhs ) const;
55  bool operator!=( const Iterator& rhs ) const;
56 
57  private:
58  GTContainer::const_iterator m_current;
59  };
60 
61  public:
62  GTProxy();
63  // the only way to construct it from scratch...
64  explicit GTProxy( const std::shared_ptr<SessionImpl>& session );
65 
66  //
67  GTProxy( const GTProxy& rhs );
68 
69  //
70  GTProxy& operator=( const GTProxy& rhs );
71 
72  // loads in memory the gtag information and the tags. to be resurrected after the changeover.
73  //void load( const std::string& gtName );
74 
75  // overloading for pre- and post-fix. Used in the ORA implementation
76  void load( const std::string& gtName, const std::string& preFix="", const std::string& postFix="" );
77 
78  // reset the data in memory and execute again the queries for the current tag
79  void reload();
80 
81  // clear all the iov data in memory
82  void reset();
83 
84  std::string name() const;
85 
86  cond::Time_t validity() const;
87 
88  boost::posix_time::ptime snapshotTime() const;
89 
90  // start the iteration.
91  Iterator begin() const;
92 
93  //
94  Iterator end() const;
95 
96  //
97  int size() const;
98 
99  private:
100  void checkTransaction( const std::string& ctx );
101 
102  private:
103  std::shared_ptr<GTProxyData> m_data;
104  std::shared_ptr<SessionImpl> m_session;
105  };
106 
107  }
108 }
109 
110 #endif
111 
GTContainer::const_iterator m_current
Definition: GTProxy.h:58
std::vector< std::tuple< std::string, std::string, std::string > > GTContainer
Definition: GTProxy.h:33
GTProxy & operator=(const GTProxy &rhs)
Definition: GTProxy.cc:101
Iterator & operator=(const Iterator &rhs)
Definition: GTProxy.cc:55
bool operator==(const Iterator &rhs) const
Definition: GTProxy.cc:77
void checkTransaction(const std::string &ctx)
Definition: GTProxy.cc:165
cond::Time_t validity() const
Definition: GTProxy.cc:157
unsigned long long Time_t
Definition: Time.h:16
std::pair< std::string, std::string > parseTag(const std::string &tag)
Definition: GTProxy.cc:8
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:125
std::shared_ptr< GTProxyData > m_data
Definition: GTProxy.h:103
boost::posix_time::ptime snapshotTime() const
Definition: GTProxy.cc:161
Iterator begin() const
Definition: GTProxy.cc:170
Iterator end() const
Definition: GTProxy.cc:177
std::string name() const
Definition: GTProxy.cc:153
bool operator!=(const Iterator &rhs) const
Definition: GTProxy.cc:82
std::shared_ptr< SessionImpl > m_session
Definition: GTProxy.h:104