ATLAS Offline Software
Loading...
Searching...
No Matches
PhaseII::IndexedRanges< T_DataContainer, T_RangeType > Class Template Reference

Helper class to associate ranges of elements in multiple containers to a contiguous index. More...

#include <PhaseIIInDetRawDataContainer.h>

Inheritance diagram for PhaseII::IndexedRanges< T_DataContainer, T_RangeType >:
Collaboration diagram for PhaseII::IndexedRanges< T_DataContainer, T_RangeType >:

Public Types

using DataContainerType = T_DataContainer
using T_RangeTypeBase = decltype( GetValue<T_RangeType>::value(T_RangeType{}))

Public Member Functions

 IndexedRanges (unsigned int n_ranges, unsigned int container_list_size)
 create a container collection for n_ranges and a certain maximum number of containers.
bool registerOrEraseNewData (unsigned int index, const T_RangeTypeBase &new_range)
 register an element range or erase the elements of this range.
bool update (unsigned int index, T_RangeTypeBase &is_range, const T_RangeTypeBase &new_range)
 update a range (version for an "atomic" range)
bool update (unsigned int index, T_RangeTypeBase &is_range, const T_RangeTypeBase &new_range)
 update a range (version for a "non-atomic" range)
const T_DataContainer & data (unsigned int container_index) const
 Get an existing container from the container collection (read only).
T_DataContainer & data (unsigned int container_index)
 Get an existing container from the container collection.
const T_RangeType & range (unsigned int index) const
 Get a specific element range.
std::size_t size () const
 return the total number of element ranges.
std::size_t empty () const
 return true there are no element ranges.
std::size_t containerListCapacity () const
const auto & errorContainer (unsigned int container_index) const
 if there is an associated error container get it.
auto & errorContainer (unsigned int container_index)
 if there is an associated error container get it (read/write access).

Protected Attributes

ContainerList< T_DataContainer > m_containers
std::vector< T_RangeType > m_range

Detailed Description

template<class T_DataContainer, class T_RangeType>
class PhaseII::IndexedRanges< T_DataContainer, T_RangeType >

Helper class to associate ranges of elements in multiple containers to a contiguous index.

The elements are stored in containers of a container collection. The range provides an element range and a container index which identifies the container within the collection, the The idea is that a contiguous range of elements is added at the end of a one container of the collection. Once all element of this range are added to the container, the range is registered for a certain index which identifies the element range e.g. an IdentifierHash If there is already a range registered for that index, the elements that just had been added to the end of the container and still constitute the end of the container are erased. The range can be either an atomic range i.e. provides compare_exchange_weak(is_range, new_range) or a simple value. The container has to allow for erasing an element range at the end of the container (erase_back) @TODO introduce concepts for T_DataContainer and T_RangeType ?

Definition at line 109 of file PhaseIIInDetRawDataContainer.h.

Member Typedef Documentation

◆ DataContainerType

template<class T_DataContainer, class T_RangeType>
using PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::DataContainerType = T_DataContainer

Definition at line 111 of file PhaseIIInDetRawDataContainer.h.

◆ T_RangeTypeBase

template<class T_DataContainer, class T_RangeType>
using PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::T_RangeTypeBase = decltype( GetValue<T_RangeType>::value(T_RangeType{}))

Definition at line 112 of file PhaseIIInDetRawDataContainer.h.

Constructor & Destructor Documentation

◆ IndexedRanges()

template<class T_DataContainer, class T_RangeType>
PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::IndexedRanges ( unsigned int n_ranges,
unsigned int container_list_size )
inline

create a container collection for n_ranges and a certain maximum number of containers.

Parameters
n_rangesthe maximum number of element ranges which can be registered e.g. PixelID::wafer_hash_max
container_list_sizethe maximum number of containers in the container collection e.g. 1

Definition at line 117 of file PhaseIIInDetRawDataContainer.h.

Helper class to associate ranges of elements in multiple containers to a contiguous index.
std::vector< T_RangeType > m_range
ContainerList< T_DataContainer > m_containers

Member Function Documentation

◆ containerListCapacity()

template<class T_DataContainer, class T_RangeType>
std::size_t PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::containerListCapacity ( ) const
inline

Definition at line 183 of file PhaseIIInDetRawDataContainer.h.

183{ return m_containers.size(); }

◆ data() [1/2]

template<class T_DataContainer, class T_RangeType>
T_DataContainer & PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::data ( unsigned int container_index)
inline

Get an existing container from the container collection.

Parameters
container_indexthe index which identifies the container in the container collection.

Definition at line 165 of file PhaseIIInDetRawDataContainer.h.

◆ data() [2/2]

template<class T_DataContainer, class T_RangeType>
const T_DataContainer & PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::data ( unsigned int container_index) const
inline

Get an existing container from the container collection (read only).

Parameters
container_indexthe index which identifies the container in the container collection.

Definition at line 160 of file PhaseIIInDetRawDataContainer.h.

◆ empty()

template<class T_DataContainer, class T_RangeType>
std::size_t PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::empty ( ) const
inline

return true there are no element ranges.

Definition at line 180 of file PhaseIIInDetRawDataContainer.h.

180{ return m_range.empty(); }

◆ errorContainer() [1/2]

template<class T_DataContainer, class T_RangeType>
auto & PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::errorContainer ( unsigned int container_index)
inline

if there is an associated error container get it (read/write access).

Definition at line 192 of file PhaseIIInDetRawDataContainer.h.

192 {
194 return m_containers[container_index].errors();
195 }

◆ errorContainer() [2/2]

template<class T_DataContainer, class T_RangeType>
const auto & PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::errorContainer ( unsigned int container_index) const
inline

if there is an associated error container get it.

Definition at line 186 of file PhaseIIInDetRawDataContainer.h.

186 {
189 return m_containers[container_index].errors();
190 }
std::size_t empty() const
return true there are no element ranges.
std::size_t size() const
return the total number of element ranges.

◆ range()

template<class T_DataContainer, class T_RangeType>
const T_RangeType & PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::range ( unsigned int index) const
inline

Get a specific element range.

Parameters
indexthe index which identifies the element range the element range will in addition to the actual element range also provide the index of the container in container collection which contains these elements.

Definition at line 172 of file PhaseIIInDetRawDataContainer.h.

172 {
173 assert(index < m_range.size());
174 return m_range[index];
175 }

◆ registerOrEraseNewData()

template<class T_DataContainer, class T_RangeType>
bool PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::registerOrEraseNewData ( unsigned int index,
const T_RangeTypeBase & new_range )
inline

register an element range or erase the elements of this range.

Parameters
indexand index which identifies the range i.e. the group of elements of this range
new_rangethe element range that should be be registered. The element range will be registered for the given index unless a range has been registered already. In the latter case the element of this new range well be erased.

Definition at line 126 of file PhaseIIInDetRawDataContainer.h.

127 {
128 assert (index < m_range.size());
129 assert( new_range.containerIndex() < m_containers.size() );
131 if (is_range.size() != new_range.size()) {
134 return true;
135 }
136 }
137 // it is assumed that data is always added at the end and then registered.
138 assert( new_range.beginIndex() + new_range.size() == m_containers[new_range.containerIndex()].size());
139 m_containers[new_range.containerIndex()].erase_back(new_range.beginIndex());
140 return false;
141 }
bool update(unsigned int index, T_RangeTypeBase &is_range, const T_RangeTypeBase &new_range)
update a range (version for an "atomic" range)
decltype(GetValue< T_RangeType >::value(T_RangeType{})) T_RangeTypeBase

◆ size()

template<class T_DataContainer, class T_RangeType>
std::size_t PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::size ( ) const
inline

return the total number of element ranges.

Definition at line 178 of file PhaseIIInDetRawDataContainer.h.

178{ return m_range.size(); }

◆ update() [1/2]

template<class T_DataContainer, class T_RangeType>
bool PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::update ( unsigned int index,
T_RangeTypeBase & is_range,
const T_RangeTypeBase & new_range )
inline

update a range (version for an "atomic" range)

Definition at line 144 of file PhaseIIInDetRawDataContainer.h.

145 {
146 assert( index < m_range.size());
147 return m_range[index].compare_exchange_weak(is_range, new_range);
148 }

◆ update() [2/2]

template<class T_DataContainer, class T_RangeType>
bool PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::update ( unsigned int index,
T_RangeTypeBase & is_range,
const T_RangeTypeBase & new_range )
inline

update a range (version for a "non-atomic" range)

Definition at line 151 of file PhaseIIInDetRawDataContainer.h.

152 {
153 assert( index < m_range.size());
155 return true;
156 }

Member Data Documentation

◆ m_containers

template<class T_DataContainer, class T_RangeType>
ContainerList<T_DataContainer> PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::m_containers
protected

Definition at line 198 of file PhaseIIInDetRawDataContainer.h.

◆ m_range

template<class T_DataContainer, class T_RangeType>
std::vector<T_RangeType> PhaseII::IndexedRanges< T_DataContainer, T_RangeType >::m_range
protected

Definition at line 199 of file PhaseIIInDetRawDataContainer.h.


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