LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lariov::Snapshot< T > Class Template Reference

#include "Snapshot.h"

Public Member Functions

 Snapshot ()
 Default constructor. More...
 
 ~Snapshot ()
 Default destructor. More...
 
void Clear ()
 
const IOVTimeStampStart () const
 
const IOVTimeStampEnd () const
 
void SetIoV (const IOVTimeStamp &start, const IOVTimeStamp &end)
 
bool IsValid (const IOVTimeStamp &ts) const
 
size_t NChannels () const
 
const std::vector< T > & Data () const
 
template<class U = T, typename std::enable_if< std::is_base_of< ChData, U >::value, int >::type = 0>
bool HasChannel (unsigned int ch) const
 Only included with class if T has base class ChData. More...
 
template<class U = T, typename std::enable_if< std::is_base_of< ChData, U >::value, int >::type = 0>
const T & GetRow (unsigned int ch) const
 
template<class U = T, typename std::enable_if< std::is_base_of< ChData, U >::value, int >::type = 0>
void AddOrReplaceRow (const T &data)
 

Private Attributes

IOVTimeStamp fStart
 
IOVTimeStamp fEnd
 
std::vector< T > fData
 

Detailed Description

template<class T>
class lariov::Snapshot< T >

Definition at line 31 of file Snapshot.h.

Constructor & Destructor Documentation

template<class T>
lariov::Snapshot< T >::Snapshot ( )
inline

Default constructor.

Definition at line 35 of file Snapshot.h.

35 : fStart(0, 0), fEnd(0, 0) {}
IOVTimeStamp fEnd
Definition: Snapshot.h:98
IOVTimeStamp fStart
Definition: Snapshot.h:97
template<class T>
lariov::Snapshot< T >::~Snapshot ( )
inline

Default destructor.

Definition at line 38 of file Snapshot.h.

38 {}

Member Function Documentation

template<class T>
template<class U = T, typename std::enable_if< std::is_base_of< ChData, U >::value, int >::type = 0>
void lariov::Snapshot< T >::AddOrReplaceRow ( const T &  data)
inline

Definition at line 82 of file Snapshot.h.

83  {
84  typename std::vector<T>::iterator it =
85  std::lower_bound(fData.begin(), fData.end(), data.Channel());
86  if (it == fData.end() || data.Channel() != it->Channel()) {
87  bool sort = (!(fData.empty()) && data < fData.back());
88  fData.push_back(data);
89  if (sort) std::sort(fData.begin(), fData.end());
90  }
91  else {
92  *it = data;
93  }
94  }
intermediate_table::iterator iterator
std::vector< T > fData
Definition: Snapshot.h:99
template<class T >
void lariov::Snapshot< T >::Clear ( )

Definition at line 106 of file Snapshot.h.

References lariov::Snapshot< T >::fData, lariov::Snapshot< T >::fEnd, lariov::Snapshot< T >::fStart, lariov::IOVTimeStamp::MaxTimeStamp(), lariov::IOVTimeStamp::SetStamp(), lariov::IOVTimeStamp::Stamp(), and lariov::IOVTimeStamp::SubStamp().

Referenced by lariov::Snapshot< lariov::PmtGain >::~Snapshot().

107  {
108  fData.clear();
111  }
void SetStamp(unsigned long stamp, unsigned int substamp=0)
Definition: IOVTimeStamp.h:41
std::vector< T > fData
Definition: Snapshot.h:99
IOVTimeStamp fEnd
Definition: Snapshot.h:98
unsigned long SubStamp() const
Definition: IOVTimeStamp.h:38
IOVTimeStamp fStart
Definition: Snapshot.h:97
unsigned long Stamp() const
Definition: IOVTimeStamp.h:37
static IOVTimeStamp MaxTimeStamp()
template<class T>
const std::vector<T>& lariov::Snapshot< T >::Data ( ) const
inline

Definition at line 50 of file Snapshot.h.

50 { return fData; }
std::vector< T > fData
Definition: Snapshot.h:99
template<class T>
const IOVTimeStamp& lariov::Snapshot< T >::End ( ) const
inline

Definition at line 43 of file Snapshot.h.

43 { return fEnd; }
IOVTimeStamp fEnd
Definition: Snapshot.h:98
template<class T>
template<class U = T, typename std::enable_if< std::is_base_of< ChData, U >::value, int >::type = 0>
const T& lariov::Snapshot< T >::GetRow ( unsigned int  ch) const
inline

Definition at line 66 of file Snapshot.h.

67  {
68 
69  typename std::vector<T>::const_iterator it = std::lower_bound(fData.begin(), fData.end(), ch);
70 
71  if (it == fData.end() || it->Channel() != ch) {
72  std::string msg("Channel not found: ");
73  msg += std::to_string(ch);
74  throw IOVDataError(msg);
75  }
76 
77  return *it;
78  }
std::vector< T > fData
Definition: Snapshot.h:99
intermediate_table::const_iterator const_iterator
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
template<class T>
template<class U = T, typename std::enable_if< std::is_base_of< ChData, U >::value, int >::type = 0>
bool lariov::Snapshot< T >::HasChannel ( unsigned int  ch) const
inline

Only included with class if T has base class ChData.

Definition at line 55 of file Snapshot.h.

56  {
57 
58  typename std::vector<T>::const_iterator it = std::lower_bound(fData.begin(), fData.end(), ch);
59  if (it == fData.end() || it->Channel() != ch) { return false; }
60  else
61  return true;
62  }
std::vector< T > fData
Definition: Snapshot.h:99
intermediate_table::const_iterator const_iterator
template<class T >
bool lariov::Snapshot< T >::IsValid ( const IOVTimeStamp ts) const

Definition at line 125 of file Snapshot.h.

References lariov::Snapshot< T >::fEnd, and lariov::Snapshot< T >::fStart.

Referenced by lariov::Snapshot< lariov::PmtGain >::End().

126  {
127  return (ts >= fStart && ts < fEnd);
128  }
IOVTimeStamp fEnd
Definition: Snapshot.h:98
IOVTimeStamp fStart
Definition: Snapshot.h:97
template<class T>
size_t lariov::Snapshot< T >::NChannels ( ) const
inline

Definition at line 48 of file Snapshot.h.

48 { return fData.size(); }
std::vector< T > fData
Definition: Snapshot.h:99
template<class T >
void lariov::Snapshot< T >::SetIoV ( const IOVTimeStamp start,
const IOVTimeStamp end 
)

Definition at line 114 of file Snapshot.h.

References util::end(), lariov::Snapshot< T >::fEnd, and lariov::Snapshot< T >::fStart.

Referenced by lariov::Snapshot< lariov::PmtGain >::End().

115  {
116  if (start >= end) {
117  throw IOVDataError("Called Snapshot::SetIoV with start timestamp >= end timestamp!");
118  }
119 
120  fStart = start;
121  fEnd = end;
122  }
IOVTimeStamp fEnd
Definition: Snapshot.h:98
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
IOVTimeStamp fStart
Definition: Snapshot.h:97
template<class T>
const IOVTimeStamp& lariov::Snapshot< T >::Start ( ) const
inline

Definition at line 42 of file Snapshot.h.

42 { return fStart; }
IOVTimeStamp fStart
Definition: Snapshot.h:97

Member Data Documentation


The documentation for this class was generated from the following file: