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 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  public:
36  // more or less compliant with typical iterator semantics...
37  class Iterator : public std::iterator<std::input_iterator_tag, cond::GTEntry_t> {
38  public:
39  //
40  Iterator();
41  explicit Iterator( GTContainer::const_iterator current );
42  Iterator( const Iterator& rhs );
43 
44  //
45  Iterator& operator=( const Iterator& rhs );
46 
47  // returns a VALUE not a reference!
49 
50  //
52  Iterator operator++(int);
53 
54  //
55  bool operator==( const Iterator& rhs ) const;
56  bool operator!=( const Iterator& rhs ) const;
57 
58  private:
59  GTContainer::const_iterator m_current;
60  };
61 
62  public:
63  GTProxy();
64  // the only way to construct it from scratch...
65  explicit GTProxy( const std::shared_ptr<SessionImpl>& session );
66 
67  //
68  GTProxy( const GTProxy& rhs );
69 
70  //
71  GTProxy& operator=( const GTProxy& rhs );
72 
73  // loads in memory the gtag information and the tags. to be resurrected after the changeover.
74  //void load( const std::string& gtName );
75 
76  // overloading for pre- and post-fix. Used in the ORA implementation
77  void load( const std::string& gtName, const std::string& preFix="", const std::string& postFix="" );
78 
79  // reset the data in memory and execute again the queries for the current tag
80  void reload();
81 
82  // clear all the iov data in memory
83  void reset();
84 
85  std::string name() const;
86 
87  cond::Time_t validity() const;
88 
89  boost::posix_time::ptime snapshotTime() const;
90 
91  // start the iteration.
92  Iterator begin() const;
93 
94  //
95  Iterator end() const;
96 
97  //
98  int size() const;
99 
100  private:
101  void checkTransaction( const std::string& ctx );
102 
103  private:
104  std::shared_ptr<GTProxyData> m_data;
105  std::shared_ptr<SessionImpl> m_session;
106  };
107 
108  }
109 }
110 
111 #endif
112 
GTContainer::const_iterator m_current
Definition: GTProxy.h:59
std::vector< std::tuple< std::string, std::string, std::string > > GTContainer
Definition: GTProxy.h:34
GTProxy & operator=(const GTProxy &rhs)
Definition: GTProxy.cc:106
Iterator & operator=(const Iterator &rhs)
Definition: GTProxy.cc:60
bool operator==(const Iterator &rhs) const
Definition: GTProxy.cc:82
void checkTransaction(const std::string &ctx)
Definition: GTProxy.cc:170
cond::Time_t validity() const
Definition: GTProxy.cc:162
unsigned long long Time_t
Definition: Time.h:16
std::pair< std::string, std::string > parseTag(const std::string &tag)
Definition: GTProxy.cc:13
void load(const std::string &gtName, const std::string &preFix="", const std::string &postFix="")
Definition: GTProxy.cc:130
std::shared_ptr< GTProxyData > m_data
Definition: GTProxy.h:104
boost::posix_time::ptime snapshotTime() const
Definition: GTProxy.cc:166
std::string fullyQualifiedTag(const std::string &tag, const std::string &connectionString)
Definition: GTProxy.cc:8
Iterator begin() const
Definition: GTProxy.cc:175
Iterator end() const
Definition: GTProxy.cc:182
string connectionString
Definition: autoCondHLT.py:4
std::string name() const
Definition: GTProxy.cc:158
bool operator!=(const Iterator &rhs) const
Definition: GTProxy.cc:87
std::shared_ptr< SessionImpl > m_session
Definition: GTProxy.h:105