File indexing completed on 2025-04-02 23:19:22
0001 #ifndef CondCore_CondDB_IOVProxy_h
0002 #define CondCore_CondDB_IOVProxy_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
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 class SessionImpl;
0025 class IOVProxyData;
0026
0027 typedef std::vector<std::tuple<cond::Time_t, cond::Hash> > IOVContainer;
0028
0029 class IOVArray {
0030 public:
0031 IOVArray();
0032 IOVArray(const IOVArray& rhs);
0033 IOVArray& operator=(const IOVArray& rhs);
0034
0035 public:
0036
0037 class Iterator {
0038 public:
0039
0040 using iterator_category = std::input_iterator_tag;
0041 using value_type = cond::Iov_t;
0042 using difference_type = void;
0043 using pointer = void;
0044 using reference = void;
0045
0046
0047 Iterator();
0048 Iterator(IOVContainer::const_iterator current, const IOVArray* parent);
0049
0050 Iterator(const Iterator& rhs);
0051
0052
0053 Iterator& operator=(const Iterator& rhs);
0054
0055
0056 cond::Iov_t operator*();
0057
0058
0059 Iterator& operator++();
0060 Iterator operator++(int);
0061
0062
0063 bool operator==(const Iterator& rhs) const;
0064 bool operator!=(const Iterator& rhs) const;
0065
0066 private:
0067 IOVContainer::const_iterator m_current;
0068 const IOVArray* m_parent;
0069 };
0070 friend class Iterator;
0071
0072 public:
0073 const cond::Tag_t& tagInfo() const;
0074
0075
0076
0077 Iterator begin() const;
0078
0079
0080 Iterator end() const;
0081
0082
0083
0084
0085 Iterator find(cond::Time_t time) const;
0086
0087 size_t size() const;
0088
0089
0090 bool isEmpty() const;
0091
0092 private:
0093 friend class IOVProxy;
0094 std::unique_ptr<IOVContainer> m_array;
0095 cond::Tag_t m_tagInfo;
0096 };
0097
0098
0099 class IOVProxy {
0100 public:
0101 IOVProxy() = default;
0102
0103
0104 explicit IOVProxy(const std::shared_ptr<SessionImpl>& session);
0105
0106 IOVArray selectAll();
0107 IOVArray selectAll(const boost::posix_time::ptime& snapshottime);
0108
0109 IOVArray selectRange(const cond::Time_t& begin, const cond::Time_t& end);
0110 IOVArray selectRange(const cond::Time_t& begin,
0111 const cond::Time_t& end,
0112 const boost::posix_time::ptime& snapshottime);
0113
0114 bool selectRange(const cond::Time_t& begin, const cond::Time_t& end, IOVContainer& destination);
0115
0116 cond::Tag_t tagInfo() const;
0117
0118 cond::TagInfo_t iovSequenceInfo() const;
0119
0120
0121
0122
0123
0124 cond::Iov_t getInterval(cond::Time_t time);
0125
0126 std::tuple<std::string, boost::posix_time::ptime, boost::posix_time::ptime> getMetadata() const;
0127
0128
0129
0130 void load(const std::string& tag);
0131
0132
0133 void load(const std::string& tag, const boost::posix_time::ptime& snapshottime);
0134
0135
0136 void reset();
0137
0138
0139 cond::Iov_t getLast();
0140
0141
0142 int loadedSize() const;
0143
0144
0145 int sequenceSize() const;
0146
0147
0148 size_t numberOfQueries() const;
0149
0150
0151 std::pair<cond::Time_t, cond::Time_t> loadedGroup() const;
0152
0153
0154 const std::shared_ptr<SessionImpl>& session() const;
0155
0156 void setPrintDebug(bool printDebug) { m_printDebug = printDebug; }
0157
0158 private:
0159 void checkTransaction(const std::string& ctx) const;
0160 void resetIOVCache();
0161 void loadGroups();
0162 void fetchSequence(cond::Time_t lowerGroup, cond::Time_t higherGroup);
0163
0164 private:
0165 std::shared_ptr<IOVProxyData> m_data;
0166 std::shared_ptr<SessionImpl> m_session;
0167
0168
0169 bool m_printDebug = false;
0170 };
0171
0172 }
0173 }
0174
0175 #endif