ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType > Class Template Reference

Helper class which adds a range check to an array access if NDEBUG is not defined. More...

#include <TargetBuffer_t.h>

Collaboration diagram for TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >:

Public Member Functions

 BufferBase_t (T_VectorType &buffer)
 
const T_BaseType & operator[] (typename std::vector< T_BaseType >::size_type idx) const
 
const T_BaseType & upper_bound_at (typename std::vector< T_BaseType >::size_type idx) const
 

Protected Member Functions

template<typename T1 , typename T2 , typename T3 >
 BufferBase_t (const BufferBase_t< T1, T2, T3 > &buffer)
 
template<typename T1 , typename T2 , typename T3 >
BufferBase_toperator= (const BufferBase_t< T1, T2, T3 > &buffer)
 
 BufferBase_t (T_BufferType *buffer, typename std::vector< T_BaseType >::size_type max_idx[[maybe_unused]], const std::vector< double > &full_vector[[maybe_unused]])
 
std::vector< T_BaseType >::size_type optionalRangeCheck (typename std::vector< T_BaseType >::size_type idx) const
 
std::vector< T_BaseType >::size_type optionalRangeCheckUpperBound (typename std::vector< T_BaseType >::size_type idx) const
 
void throwRangeError (typename std::vector< T_BaseType >::size_type idx) const
 

Protected Attributes

T_BufferType * m_ptr
 
std::vector< T_BaseType >::size_type m_maxIndex
 
const T_BaseType * m_bufferStart
 
const T_BaseType * m_bufferEnd
 

Friends

class DoubleBuffer_t
 
template<typename T1 , typename T2 , typename T3 >
class BufferBase_t
 

Detailed Description

template<typename T_BaseType, typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
class TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >

Helper class which adds a range check to an array access if NDEBUG is not defined.

The helper class only provides read only access to the array, but allows a derived class to add write access if permitted by the base type.

Definition at line 22 of file TargetBuffer_t.h.

Constructor & Destructor Documentation

◆ BufferBase_t() [1/3]

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::BufferBase_t ( T_VectorType &  buffer)
inline

Definition at line 27 of file TargetBuffer_t.h.

28  : m_ptr (&(buffer[0]))
29 #ifndef NDEBUG
30  // debug code
31  , m_maxIndex(buffer.size())
32  , m_bufferStart(buffer.data())
33  , m_bufferEnd(m_bufferStart + buffer.size())//assumed contiguous
34 #endif
35  {
36  }

◆ BufferBase_t() [2/3]

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
template<typename T1 , typename T2 , typename T3 >
TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::BufferBase_t ( const BufferBase_t< T1, T2, T3 > &  buffer)
inlineprotected

Definition at line 41 of file TargetBuffer_t.h.

42  : m_ptr(buffer.m_ptr)
43 #ifndef NDEBUG
44  , m_maxIndex(buffer.m_maxIndex)
45  , m_bufferStart(buffer.m_bufferStart)
46  , m_bufferEnd(buffer.m_bufferEnd)
47 #endif
48  {
49  }

◆ BufferBase_t() [3/3]

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::BufferBase_t ( T_BufferType *  buffer,
typename std::vector< T_BaseType >::size_type max_idx]  [[maybe_unused],
const std::vector< double > &full_vector]  [[maybe_unused] 
)
inlineprotected

Definition at line 65 of file TargetBuffer_t.h.

68  : m_ptr(buffer)
69 #ifndef NDEBUG
70  // debug code
71  , m_maxIndex(max_idx)
72  , m_bufferStart(full_vector.data())
73  , m_bufferEnd(m_bufferStart+full_vector.size())//assumed contiguous
74 #endif
75  {
76  }

Member Function Documentation

◆ operator=()

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
template<typename T1 , typename T2 , typename T3 >
BufferBase_t& TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::operator= ( const BufferBase_t< T1, T2, T3 > &  buffer)
inlineprotected

Definition at line 53 of file TargetBuffer_t.h.

54  {
55  m_ptr=buffer.m_ptr;
56 #ifndef NDEBUG
57  m_maxIndex=buffer.m_maxIndex;
58  m_bufferStart=buffer.m_bufferStart;
59  m_bufferEnd=buffer.m_bufferEnd;
60 #endif
61  return *this;
62  }

◆ operator[]()

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
const T_BaseType& TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::operator[] ( typename std::vector< T_BaseType >::size_type  idx) const
inline

Definition at line 79 of file TargetBuffer_t.h.

79  {
80  return m_ptr[optionalRangeCheck(idx)];
81  }

◆ optionalRangeCheck()

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
std::vector<T_BaseType>::size_type TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::optionalRangeCheck ( typename std::vector< T_BaseType >::size_type  idx) const
inlineprotected

Definition at line 98 of file TargetBuffer_t.h.

98  {
99  if (idx>=m_maxIndex || &(m_ptr[idx])<m_bufferStart || &(m_ptr[idx])>=m_bufferEnd) {
101  }
102  return idx;
103  }

◆ optionalRangeCheckUpperBound()

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
std::vector<T_BaseType>::size_type TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::optionalRangeCheckUpperBound ( typename std::vector< T_BaseType >::size_type  idx) const
inlineprotected

Definition at line 104 of file TargetBuffer_t.h.

104  {
105  // allow for idx==0
106  if (idx>0 && (idx-1>=m_maxIndex || &(m_ptr[idx-1])<m_bufferStart || &(m_ptr[idx-1])>=m_bufferEnd)) {
108  }
109  return idx;
110  }

◆ throwRangeError()

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
void TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::throwRangeError ( typename std::vector< T_BaseType >::size_type  idx) const
protected

◆ upper_bound_at()

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
const T_BaseType& TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::upper_bound_at ( typename std::vector< T_BaseType >::size_type  idx) const
inline

Definition at line 83 of file TargetBuffer_t.h.

83  {
85  }

Friends And Related Function Documentation

◆ BufferBase_t

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
template<typename T1 , typename T2 , typename T3 >
friend class BufferBase_t
friend

Definition at line 24 of file TargetBuffer_t.h.

◆ DoubleBuffer_t

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
friend class DoubleBuffer_t
friend

Definition at line 23 of file TargetBuffer_t.h.

Member Data Documentation

◆ m_bufferEnd

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
const T_BaseType* TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::m_bufferEnd
protected

Definition at line 115 of file TargetBuffer_t.h.

◆ m_bufferStart

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
const T_BaseType* TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::m_bufferStart
protected

Definition at line 114 of file TargetBuffer_t.h.

◆ m_maxIndex

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
std::vector<T_BaseType>::size_type TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::m_maxIndex
protected

Definition at line 113 of file TargetBuffer_t.h.

◆ m_ptr

template<typename T_BaseType , typename T_BufferType = const T_BaseType, typename T_VectorType = const std::vector<T_BaseType>>
T_BufferType* TTN::BufferBase_t< T_BaseType, T_BufferType, T_VectorType >::m_ptr
protected

Definition at line 88 of file TargetBuffer_t.h.


The documentation for this class was generated from the following file:
TTN::BufferBase_t::optionalRangeCheck
std::vector< T_BaseType >::size_type optionalRangeCheck(typename std::vector< T_BaseType >::size_type idx) const
Definition: TargetBuffer_t.h:98
TTN::BufferBase_t::m_bufferStart
const T_BaseType * m_bufferStart
Definition: TargetBuffer_t.h:114
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
TTN::BufferBase_t::m_ptr
T_BufferType * m_ptr
Definition: TargetBuffer_t.h:88
TTN::BufferBase_t::m_bufferEnd
const T_BaseType * m_bufferEnd
Definition: TargetBuffer_t.h:115
TTN::BufferBase_t::throwRangeError
void throwRangeError(typename std::vector< T_BaseType >::size_type idx) const
TTN::BufferBase_t::m_maxIndex
std::vector< T_BaseType >::size_type m_maxIndex
Definition: TargetBuffer_t.h:113
TTN::BufferBase_t::optionalRangeCheckUpperBound
std::vector< T_BaseType >::size_type optionalRangeCheckUpperBound(typename std::vector< T_BaseType >::size_type idx) const
Definition: TargetBuffer_t.h:104
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69