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

Helper class to keep track of a range of elements added to the end of a container. More...

#include <ContainerRangeGuard.h>

Collaboration diagram for PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >:

Public Member Functions

 ContainerRangeGuard (T_ContainerPtr ptr)
T_RangeType range () const
 create a range for the elements added to the container since the guard was created.
std::size_t startIndex () const
T_ContainerPtr & ptr ()
 return the pointer to the container which contains the element range of this range guard
const T_ContainerPtr & ptr () const
 return the pointer to the container which contains the element range of this range guard (read only)
bool empty () const
 return true if no elements have been added to the container since the construction of this guard.

Private Attributes

T_ContainerPtr m_ptr
std::size_t m_startIndex

Detailed Description

template<typename T_RangeType, typename T_ContainerPtr>
class PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >

Helper class to keep track of a range of elements added to the end of a container.

The element range is defined by the size of the container when this guard is constructed and the size of the container when the range is requested. The container may additionally be identified by an id in the container collection Usage: <verbatim> ContainerRangeGuard<DataRange, ContainerPtr> range_guard(container_ptr); for (const auto input : input_container) { /*... add elements to container_ptr e.g. addDataForModule(container_collection, range_guard, ... ); ‍/ } if (!range_guard.empty()) { / ... register range ... *‍/ } </verbatim>

Definition at line 32 of file ContainerRangeGuard.h.

Constructor & Destructor Documentation

◆ ContainerRangeGuard()

template<typename T_RangeType, typename T_ContainerPtr>
PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::ContainerRangeGuard ( T_ContainerPtr ptr)
inline

Definition at line 34 of file ContainerRangeGuard.h.

34: m_ptr(ptr), m_startIndex(m_ptr->size()) {}
T_ContainerPtr & ptr()
return the pointer to the container which contains the element range of this range guard

Member Function Documentation

◆ empty()

template<typename T_RangeType, typename T_ContainerPtr>
bool PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::empty ( ) const
inline

return true if no elements have been added to the container since the construction of this guard.

Definition at line 57 of file ContainerRangeGuard.h.

57 {
58 return m_ptr->size() == m_startIndex;
59 }

◆ ptr() [1/2]

template<typename T_RangeType, typename T_ContainerPtr>
T_ContainerPtr & PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::ptr ( )
inline

return the pointer to the container which contains the element range of this range guard

Definition at line 48 of file ContainerRangeGuard.h.

48 {
49 return m_ptr;
50 }

◆ ptr() [2/2]

template<typename T_RangeType, typename T_ContainerPtr>
const T_ContainerPtr & PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::ptr ( ) const
inline

return the pointer to the container which contains the element range of this range guard (read only)

Definition at line 52 of file ContainerRangeGuard.h.

52 {
53 return m_ptr;
54 }

◆ range()

template<typename T_RangeType, typename T_ContainerPtr>
T_RangeType PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::range ( ) const
inline

create a range for the elements added to the container since the guard was created.

Definition at line 36 of file ContainerRangeGuard.h.

36 {
37 if constexpr(hasContainerId<T_ContainerPtr>) {
38 return T_RangeType::makeDataRange(m_startIndex, m_ptr->size(),m_ptr.containerId());
39 }
40 else {
42 }
43 }
Helper class to keep track of a range of elements added to the end of a container.

◆ startIndex()

template<typename T_RangeType, typename T_ContainerPtr>
std::size_t PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::startIndex ( ) const
inline

Definition at line 44 of file ContainerRangeGuard.h.

44 {
45 return m_startIndex;
46 }

Member Data Documentation

◆ m_ptr

template<typename T_RangeType, typename T_ContainerPtr>
T_ContainerPtr PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::m_ptr
private

Definition at line 61 of file ContainerRangeGuard.h.

◆ m_startIndex

template<typename T_RangeType, typename T_ContainerPtr>
std::size_t PhaseII::ContainerRangeGuard< T_RangeType, T_ContainerPtr >::m_startIndex
private

Definition at line 62 of file ContainerRangeGuard.h.


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