Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:20

0001 #ifndef CondCore_CondDB_GTProxy_h
0002 #define CondCore_CondDB_GTProxy_h
0003 //
0004 // Package:     CondDB
0005 // Class  :     GTProxy
0006 //
0007 /**\class GTProxy GTProxy.h CondCore/CondDB/interface/GTProxy.h
0008    Description: service for read/only access to the condition Global Tags.  
0009 */
0010 //
0011 // Author:      Giacomo Govi
0012 // Created:     Jul 2013
0013 //
0014 
0015 #include "CondCore/CondDB/interface/Time.h"
0016 #include "CondCore/CondDB/interface/Types.h"
0017 //
0018 #include <boost/date_time/posix_time/posix_time.hpp>
0019 
0020 namespace cond {
0021 
0022   namespace persistency {
0023 
0024     // required to handle the tag overriding
0025     std::string fullyQualifiedTag(const std::string& tag, const std::string& connectionString);
0026     std::pair<std::string, std::string> parseTag(const std::string& tag);
0027 
0028     class SessionImpl;
0029     class GTProxyData;
0030 
0031     // value semantics. to be used WITHIN the parent session transaction ( therefore the session should be kept alive ).
0032     class GTProxy {
0033     public:
0034       typedef std::vector<std::tuple<std::string, std::string, std::string> > GTContainer;
0035 
0036     public:
0037       // more or less compliant with typical iterator semantics...
0038       class Iterator : public std::iterator<std::input_iterator_tag, cond::GTEntry_t> {
0039       public:
0040         //
0041         Iterator();
0042         explicit Iterator(GTContainer::const_iterator current);
0043         Iterator(const Iterator& rhs);
0044 
0045         //
0046         Iterator& operator=(const Iterator& rhs);
0047 
0048         // returns a VALUE not a reference!
0049         cond::GTEntry_t operator*();
0050 
0051         //
0052         Iterator& operator++();
0053         Iterator operator++(int);
0054 
0055         //
0056         bool operator==(const Iterator& rhs) const;
0057         bool operator!=(const Iterator& rhs) const;
0058 
0059       private:
0060         GTContainer::const_iterator m_current;
0061       };
0062 
0063     public:
0064       GTProxy();
0065       // the only way to construct it from scratch...
0066       explicit GTProxy(const std::shared_ptr<SessionImpl>& session);
0067 
0068       //
0069       GTProxy(const GTProxy& rhs);
0070 
0071       //
0072       GTProxy& operator=(const GTProxy& rhs);
0073 
0074       // loads in memory the gtag information and the tags. to be resurrected after the changeover.
0075       //void load( const std::string& gtName );
0076 
0077       // overloading for pre- and post-fix. Used in the ORA implementation
0078       void load(const std::string& gtName, const std::string& preFix = "", const std::string& postFix = "");
0079 
0080       // reset the data in memory and execute again the queries for the current tag
0081       void reload();
0082 
0083       // clear all the iov data in memory
0084       void reset();
0085 
0086       std::string name() const;
0087 
0088       cond::Time_t validity() const;
0089 
0090       boost::posix_time::ptime snapshotTime() const;
0091 
0092       // start the iteration.
0093       Iterator begin() const;
0094 
0095       //
0096       Iterator end() const;
0097 
0098       //
0099       int size() const;
0100 
0101     private:
0102       void checkTransaction(const std::string& ctx);
0103 
0104     private:
0105       std::shared_ptr<GTProxyData> m_data;
0106       std::shared_ptr<SessionImpl> m_session;
0107     };
0108 
0109   }  // namespace persistency
0110 }  // namespace cond
0111 
0112 #endif