ATLAS Offline Software
IovStore.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
6 #ifndef IOVDbSvc_IovStore_h
7 #define IOVDbSvc_IovStore_h
8 
13 #include "CoolKernel/ValidityKey.h"
14 #include <vector>
15 #include <utility> //pair
16 
17 namespace IOVDbNamespace{
18  //@brief Manages the caching of IOV since/until pairs but encapsulating the functionality
19  //in a single class
20  class IovStore{
21  public:
22  typedef std::pair<cool::ValidityKey, cool::ValidityKey> Iov_t;
26  IovStore(const Iov_t & cacheBounds);
28  void addIov(const Iov_t & iov);
29  void addIov(const cool::ValidityKey & since, const cool::ValidityKey & until);
31  Iov_t getCacheBounds() const;
33  void setCacheBounds(const Iov_t & cacheBounds);
37  void setIovSpan(const Iov_t & span);
39  std::vector<Iov_t> & vectorStore();
41  std::pair<unsigned int, unsigned int> numberOfIovsOnBoundaries() const;
43  bool empty() const { return m_iovs.empty();}
45  unsigned int size() const { return m_iovs.size();}
47  void clear();
49  Iov_t at(const unsigned int idx) const { return m_iovs.at(idx);}
51  void extendIov(const unsigned int idx, const cool::ValidityKey & newUntilTime);
53  bool extendCacheLo();
55  bool extendCacheHi();
56  private:
57  static std::pair<bool,bool> straddling(const Iov_t & iov, const Iov_t & bounds) ;
59  std::vector<Iov_t> m_iovs{};
65  cool::ValidityKey m_maxStraddlingSince{cool::ValidityKeyMin};
69  cool::ValidityKey m_minStraddlingUntil{cool::ValidityKeyMax};
71  std::pair<unsigned int, unsigned int> m_countStraddling{};
72  };
73 
74 }
75 
76 #endif
IOVDbNamespace::IovStore::extendIov
void extendIov(const unsigned int idx, const cool::ValidityKey &newUntilTime)
Extend a specific iov at the index to a new 'until' time.
Definition: IovStore.cxx:77
CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
dqt_zlumi_alleff_HIST.iov
iov
Definition: dqt_zlumi_alleff_HIST.py:119
IOVDbNamespace::IovStore::vectorStore
std::vector< Iov_t > & vectorStore()
Return the internal vector store.
Definition: IovStore.cxx:64
IOVDbNamespace::IovStore::getMinimumStraddlingSpan
Iov_t getMinimumStraddlingSpan() const
Get the minimum straddling span (max 'since' to min 'until')
Definition: IovStore.cxx:45
IOVDbNamespace::IovStore::numberOfIovsOnBoundaries
std::pair< unsigned int, unsigned int > numberOfIovsOnBoundaries() const
Return the current count of added Iovs which straddled cache boundaries.
Definition: IovStore.cxx:51
IOVDbNamespace::IovStore::clear
void clear()
clear the store
Definition: IovStore.cxx:56
IOVDbNamespace::IovStore::size
unsigned int size() const
length of store
Definition: IovStore.h:45
IOVDbNamespace::IovStore::Iov_t
std::pair< cool::ValidityKey, cool::ValidityKey > Iov_t
Definition: IovStore.h:22
IOVDbNamespace::IovStore::m_cacheBounds
Iov_t m_cacheBounds
cache bounds, 'since', 'until', corresponds to m_cachestart, m_cachestop in original
Definition: IovStore.h:61
dq_defect_copy_defect_database.since
def since
Definition: dq_defect_copy_defect_database.py:54
dq_defect_copy_defect_database.until
def until
Definition: dq_defect_copy_defect_database.py:55
IOVDbNamespace::IovStore::IovStore
IovStore()
Default constructor, cache bounds set to 0,0.
IOVDbNamespace::IovStore::m_iovs
std::vector< Iov_t > m_iovs
main vector of iovs
Definition: IovStore.h:59
IOVDbNamespace::IovStore::m_maxStraddlingSince
cool::ValidityKey m_maxStraddlingSince
max 'since' of the iovs which straddle the cache boundary, corresponds to 'm_boundmin' in the origina...
Definition: IovStore.h:65
IOVDbNamespace::IovStore::getCacheBounds
Iov_t getCacheBounds() const
Report the current cache bounds.
Definition: IovStore.cxx:31
IOVDbNamespace::IovStore::setCacheBounds
void setCacheBounds(const Iov_t &cacheBounds)
Set the cache bound variables.
Definition: IovStore.cxx:36
IOVDbNamespace::IovStore::m_minStraddlingUntil
cool::ValidityKey m_minStraddlingUntil
min 'until' of the iovs which straddle the boundary corresponds to 'm_boundmax' in the original code
Definition: IovStore.h:69
IOVDbNamespace::IovStore::addIov
void addIov(const Iov_t &iov)
Add an iov to the store and update the span variables.
Definition: IovStore.cxx:16
IOVDbNamespace::IovStore::m_countStraddling
std::pair< unsigned int, unsigned int > m_countStraddling
count of iovs straddling the since or until boundaries
Definition: IovStore.h:71
IOVDbNamespace::IovStore::extendCacheHi
bool extendCacheHi()
Extend upper cache bound to the minimum 'until' time; return whether this changes its value.
Definition: IovStore.cxx:96
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
IOVDbNamespace::IovStore::at
Iov_t at(const unsigned int idx) const
'at' to read iov at specific index
Definition: IovStore.h:49
IOVDbNamespace::IovStore::extendCacheLo
bool extendCacheLo()
Extend lower cache bound to the maximum 'since' time; return whether this changes its value.
Definition: IovStore.cxx:89
IOVDbNamespace::IovStore::straddling
static std::pair< bool, bool > straddling(const Iov_t &iov, const Iov_t &bounds)
Definition: IovStore.cxx:69
IOVDbNamespace::IovStore::empty
bool empty() const
is the store empty?
Definition: IovStore.h:43
IOVDbNamespace::IovStore::setIovSpan
void setIovSpan(const Iov_t &span)
Set span.
Definition: IovStore.cxx:82
IOVDbNamespace
Definition: Base64Codec.cxx:16
IOVDbNamespace::IovStore
Definition: IovStore.h:20