ATLAS Offline Software
Public Types | Public Member Functions | Private Attributes | List of all members
SG::detail::JaggedVecProxyBase Class Reference

Base class for jagged vector proxies. More...

#include <JaggedVecConversions.h>

Collaboration diagram for SG::detail::JaggedVecProxyBase:

Public Types

using Elt_t = SG::JaggedVecEltBase
 Type of a jagged vector element. More...
 
using Elt_span = std::span< Elt_t >
 A span of elements. More...
 
using index_type = typename Elt_t::index_type
 Type used for indexing into a jagged vector. More...
 

Public Member Functions

 JaggedVecProxyBase (const AuxDataSpanBase &elts, AuxVectorData &container, SG::auxid_t auxid)
 Constructor. More...
 
Elt_telt (size_t elt_index) noexcept
 Return one jagged vector element (non-const). More...
 
const Elt_telt (size_t elt_index) const noexcept
 Return one jagged vector element (const). More...
 
void resize1 (size_t elt_index, index_type n_new)
 Resize one jagged vector element. More...
 
void adjust1 (size_t elt_index, index_type index, int n_add)
 Add or remove payload items from one jagged vector element. More...
 

Private Attributes

Elt_span m_elts
 The elements of the jagged vector. More...
 
AuxVectorDatam_container
 The container holding the variable. More...
 
std::variant< IAuxTypeVector *, SG::auxid_tm_linkedVec
 

Detailed Description

Base class for jagged vector proxies.

Proxies are used for modifying elements of a jagged vector. This base class implements the parts that do not depend on payload type.

Definition at line 95 of file JaggedVecConversions.h.

Member Typedef Documentation

◆ Elt_span

A span of elements.

Definition at line 102 of file JaggedVecConversions.h.

◆ Elt_t

Type of a jagged vector element.

Definition at line 99 of file JaggedVecConversions.h.

◆ index_type

Type used for indexing into a jagged vector.

Definition at line 105 of file JaggedVecConversions.h.

Constructor & Destructor Documentation

◆ JaggedVecProxyBase()

SG::detail::JaggedVecProxyBase::JaggedVecProxyBase ( const AuxDataSpanBase elts,
AuxVectorData container,
SG::auxid_t  auxid 
)

Constructor.

Parameters
eltsThe elements of the jagged vector.
containerThe container holding this variable.
auxidThe aux ID of this variable.

Member Function Documentation

◆ adjust1()

void SG::detail::JaggedVecProxyBase::adjust1 ( size_t  elt_index,
index_type  index,
int  n_add 
)

Add or remove payload items from one jagged vector element.

Parameters
elt_indexThe index of the element to resize.
indexThe index of the payload item within this jagged vector element after the insertion/deletion (in other words, the first element that moves as a result of the change).
n_addThe number of elements to add. May be negative to remove elements.

Definition at line 41 of file JaggedVecConversions.cxx.

42 {
43  // Return right away if there's nothing to do.
44  if (n_add == 0) return;
45 
46  // Find the IAuxTypeVector for the payload variable.
47  IAuxTypeVector* linkedVec;
48  if (m_linkedVec.index() == 0) {
49  // We already have it.
50  linkedVec = std::get<0>(m_linkedVec);
51  }
52  else {
53  // Look it up from the container.
54  SG::auxid_t auxid = std::get<1>(m_linkedVec);
55  linkedVec = m_container.getStore()->linkedVector (auxid);
56 
57  // Remember it to possibly use again.
58  m_linkedVec = linkedVec;
59  }
60 
61  // Indices from the element that we're modifying.
62  Elt_t& e = elt(elt_index);
63  size_t beg = e.begin(elt_index);
64  size_t end = e.end();
65 
66  // Shift the payload items.
67  if (!linkedVec->shift (beg+index, n_add)) {
68  m_container.clearCache (linkedVec->auxid());
69  }
70 
71  // Adjust the indices in the jagged vector elements.
72  // First the element that we're modifying...
73  e = JaggedVecEltBase (end + n_add);
74  // .. then all the remaining elements.
75  std::ranges::for_each (m_elts | std::views::drop (elt_index+1),
76  JaggedVecEltBase::Shift (n_add));
77 }

◆ elt() [1/2]

const Elt_t& SG::detail::JaggedVecProxyBase::elt ( size_t  elt_index) const
noexcept

Return one jagged vector element (const).

Parameters
eltindexThe index of the element.

◆ elt() [2/2]

Elt_t& SG::detail::JaggedVecProxyBase::elt ( size_t  elt_index)
noexcept

Return one jagged vector element (non-const).

Parameters
elt_indexThe index of the element.

◆ resize1()

void SG::detail::JaggedVecProxyBase::resize1 ( size_t  elt_index,
index_type  n_new 
)

Resize one jagged vector element.

Parameters
elt_indexThe index of the element to resize.
n_newThe size of the new element.

Any added payload elemnets are default-initialized.

Parameters
eltindexThe index of the element to resize.
n_newThe size of the new element.

Any added payload elemnets are default-initialized.

Definition at line 25 of file JaggedVecConversions.cxx.

26 {
27  int n_old = elt (elt_index).size (elt_index);
28  adjust1 (elt_index, n_old, static_cast<int>(n_new) - n_old);
29 }

Member Data Documentation

◆ m_container

AuxVectorData& SG::detail::JaggedVecProxyBase::m_container
private

The container holding the variable.

Definition at line 160 of file JaggedVecConversions.h.

◆ m_elts

Elt_span SG::detail::JaggedVecProxyBase::m_elts
private

The elements of the jagged vector.

Definition at line 157 of file JaggedVecConversions.h.

◆ m_linkedVec

std::variant<IAuxTypeVector*, SG::auxid_t> SG::detail::JaggedVecProxyBase::m_linkedVec
private

Definition at line 163 of file JaggedVecConversions.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::detail::JaggedVecProxyBase::adjust1
void adjust1(size_t elt_index, index_type index, int n_add)
Add or remove payload items from one jagged vector element.
Definition: JaggedVecConversions.cxx:41
SG::JaggedVecEltBase::size
size_t size(size_t elt_ndx) const
Return the number of items in this range.
index
Definition: index.py:1
SG::IAuxStore::linkedVector
virtual IAuxTypeVector * linkedVector(SG::auxid_t)
Definition: IAuxStore.h:187
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
SG::detail::JaggedVecProxyBase::m_elts
Elt_span m_elts
The elements of the jagged vector.
Definition: JaggedVecConversions.h:157
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::detail::JaggedVecProxyBase::m_container
AuxVectorData & m_container
The container holding the variable.
Definition: JaggedVecConversions.h:160
SG::detail::JaggedVecProxyBase::m_linkedVec
std::variant< IAuxTypeVector *, SG::auxid_t > m_linkedVec
Definition: JaggedVecConversions.h:163
SG::AuxVectorData::getStore
SG::IAuxStore * getStore()
Return the current store, as a non-const interface.
SG::detail::JaggedVecProxyBase::elt
Elt_t & elt(size_t elt_index) noexcept
Return one jagged vector element (non-const).
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
SG::AuxVectorData::clearCache
void clearCache()
Clear the cached aux data pointers.
SG::detail::JaggedVecProxyBase::Elt_t
SG::JaggedVecEltBase Elt_t
Type of a jagged vector element.
Definition: JaggedVecConversions.h:99
SG::JaggedVecEltBase::Shift
friend struct Shift
Definition: JaggedVecImpl.h:119