Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CondCore_CondDB_RunInfoProxy_h
0002 #define CondCore_CondDB_RunInfoProxy_h
0003 //
0004 // Package:     CondDB
0005 // Class  :     RunInfoProxy
0006 //
0007 /**\class RunInfoProxy RunInfoProxy.h CondCore/CondDB/interface/RunInfoProxy.h
0008    Description: service for read/only access to the Run information.  
0009 */
0010 //
0011 // Author:      Giacomo Govi
0012 // Created:     Dec 2016
0013 //
0014 
0015 #include "CondCore/CondDB/interface/Types.h"
0016 //
0017 
0018 namespace cond {
0019 
0020   namespace persistency {
0021 
0022     class SessionImpl;
0023     class RunInfoProxyData;
0024 
0025     // value semantics. to be used WITHIN the parent session transaction ( therefore the session should be kept alive ).
0026     class RunInfoProxy {
0027     public:
0028       typedef std::vector<std::tuple<Time_t, boost::posix_time::ptime, boost::posix_time::ptime> > RunInfoData;
0029 
0030     public:
0031       // more or less compliant with typical iterator semantics...
0032       class Iterator : public std::iterator<std::input_iterator_tag, cond::RunInfo_t> {
0033       public:
0034         //
0035         Iterator();
0036         explicit Iterator(RunInfoData::const_iterator current);
0037         Iterator(const Iterator& rhs);
0038 
0039         //
0040         Iterator& operator=(const Iterator& rhs);
0041 
0042         // returns a VALUE not a reference!
0043         cond::RunInfo_t operator*();
0044 
0045         //
0046         Iterator& operator++();
0047         Iterator operator++(int);
0048 
0049         //
0050         bool operator==(const Iterator& rhs) const;
0051         bool operator!=(const Iterator& rhs) const;
0052 
0053       private:
0054         RunInfoData::const_iterator m_current;
0055       };
0056 
0057     public:
0058       RunInfoProxy();
0059 
0060       //
0061       explicit RunInfoProxy(const std::shared_ptr<SessionImpl>& session);
0062 
0063       //
0064       RunInfoProxy(const RunInfoProxy& rhs);
0065 
0066       //
0067       RunInfoProxy& operator=(const RunInfoProxy& rhs);
0068 
0069       // loads in memory the RunInfo data for the specified run range
0070       void load(Time_t low, Time_t up);
0071 
0072       // loads in memory the RunInfo data for the specified run range
0073       void load(const boost::posix_time::ptime& low, const boost::posix_time::ptime& up);
0074 
0075       // clear all the iov data in memory
0076       void reset();
0077 
0078       // start the iteration.
0079       Iterator begin() const;
0080 
0081       //
0082       Iterator end() const;
0083 
0084       //
0085       Iterator find(Time_t target) const;
0086 
0087       //
0088       Iterator find(const boost::posix_time::ptime& target) const;
0089 
0090       //
0091       cond::RunInfo_t get(Time_t target) const;
0092 
0093       //
0094       cond::RunInfo_t get(const boost::posix_time::ptime& target) const;
0095 
0096       //
0097       int size() const;
0098 
0099     private:
0100       void checkTransaction(const std::string& ctx);
0101 
0102     private:
0103       std::shared_ptr<RunInfoProxyData> m_data;
0104       std::shared_ptr<SessionImpl> m_session;
0105     };
0106 
0107   }  // namespace persistency
0108 }  // namespace cond
0109 
0110 #endif