ATLAS Offline Software
PackedLinkConstAccessor.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  * Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration.
4  */
14 #ifndef ATHCONTAINERS_PACKEDLINKCONSTACCESSOR_H
15 #define ATHCONTAINERS_PACKEDLINKCONSTACCESSOR_H
16 
17 
26 #include "AthLinks/ElementLink.h"
27 #include "AthLinks/DataLink.h"
28 #include "CxxUtils/range_with_at.h"
30 #include <iterator>
31 
32 
33 class IProxyDict;
34 
35 
36 namespace SG {
37 
38 
69 template <class CONT, class ALLOC>
70 class ConstAccessor<SG::PackedLink<CONT>, ALLOC>
72 {
73 public:
74  // Aliases for the types we're dealing with.
76  using PLink_t = SG::PackedLink<CONT>;
78  using DLinkAlloc_t = typename std::allocator_traits<ALLOC>::template rebind_alloc<DLink_t>;
79 
80 
84 
85 
88 
89 
91  using const_span =
94 
95 
98 
101 
104 
105 
112  ConstAccessor (const std::string& name);
113 
114 
122  ConstAccessor (const std::string& name, const std::string& clsname);
123 
124 
132 
133 
138  template <IsConstAuxElement ELT>
139  const Link_t operator() (const ELT& e) const;
140 
141 
149  const Link_t
150  operator() (const AuxVectorData& container, size_t index) const;
151 
152 
157  const PLink_t*
158  getPackedLinkArray (const AuxVectorData& container) const;
159 
160 
165  const DLink_t*
166  getDataLinkArray (const AuxVectorData& container) const;
167 
168 
174  getPackedLinkSpan (const AuxVectorData& container) const;
175 
176 
182  getDataLinkSpan (const AuxVectorData& container) const;
183 
184 
189  const_span
190  getDataSpan (const AuxVectorData& container) const;
191 
192 
193 protected:
202  ConstAccessor (const std::string& name,
203  const std::string& clsname,
204  const SG::AuxVarFlags flags);
205 
206 
212  Link_t
213  resolveLink (const AuxVectorData& container, size_t index) const;
214 };
215 
216 
217 //************************************************************************
218 
219 
253 template <class CONT, class ALLOC, class VALLOC>
254 class ConstAccessor<std::vector<SG::PackedLink<CONT>, VALLOC>, ALLOC>
256 {
257 public:
258  // Aliases for the types we're dealing with.
260  using PLink_t = SG::PackedLink<CONT>;
261  using VElt_t = std::vector<SG::PackedLink<CONT>, VALLOC>;
263  using DLinkAlloc_t = typename std::allocator_traits<ALLOC>::template rebind_alloc<DLink_t>;
264 
268 
271 
272 
276 
277 
280  using const_span =
283 
284 
287 
290 
293 
294 
301  ConstAccessor (const std::string& name);
302 
303 
311  ConstAccessor (const std::string& name, const std::string& clsname);
312 
313 
321 
322 
329  template <IsConstAuxElement ELT>
330  const_elt_span operator() (const ELT& e) const;
331 
332 
343  operator() (const AuxVectorData& container, size_t index) const;
344 
345 
350  const VElt_t*
351  getPackedLinkVectorArray (const AuxVectorData& container) const;
352 
353 
358  const DLink_t*
359  getDataLinkArray (const AuxVectorData& container) const;
360 
361 
366  template <IsConstAuxElement ELT>
368  getPackedLinkSpan (const ELT& e) const;
369 
370 
377  getPackedLinkSpan (const AuxVectorData& container, size_t index) const;
378 
379 
385  getPackedLinkVectorSpan (const AuxVectorData& container) const;
386 
387 
393  getDataLinkSpan (const AuxVectorData& container) const;
394 
395 
400  const_span
401  getDataSpan (const AuxVectorData& container) const;
402 
403 
404 protected:
413  ConstAccessor (const std::string& name,
414  const std::string& clsname,
415  const SG::AuxVarFlags flags);
416 };
417 
418 
419 } // namespace SG
420 
421 
423 
424 
425 #endif // not ATHCONTAINERS_PACKEDLINKCONSTACCESSOR_H
SG::ConstAccessor::element_type
typename AuxDataTraits< T, ALLOC >::element_type element_type
Type the user sees.
Definition: ConstAccessor.h:58
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SG::detail::LinkedVarAccessorBase
Base class usable for accessors for variables with linked variables.
Definition: LinkedVarAccessorBase.h:29
SG::detail::PackedLinkVectorConstConverter
Helper: Convert a vector of PackedLink to a span over ElementLinks.
Definition: PackedLinkConversions.h:75
AuxElementConcepts.h
SG::detail::PackedLinkConstConverter
Helper: Convert a PackedLink to an ElementLink.
Definition: PackedLinkConversions.h:37
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
index
Definition: index.py:1
AthenaPoolTestRead.flags
flags
Definition: AthenaPoolTestRead.py:8
SG::ConstAccessor::auxid
SG::auxid_t auxid() const
Return the aux id for this variable.
SG::ConstAccessor::const_span
typename AuxDataTraits< T, ALLOC >::const_span const_span
A span over elements in the container.
Definition: ConstAccessor.h:69
taskman.template
dictionary template
Definition: taskman.py:317
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
LinkedVarAccessorBase.h
Base class usable for accessors for variables with linked variables.
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:51
range_with_conv.h
Add to a range class conversions to containers.
CxxUtils::span
Simplified version of the C++20 std::span.
Definition: span.h:67
PackedLinkConversions.h
Conversions between PackedLink and ElementLink.
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxDataTraits
Allow customizing how aux data types are treated.
Definition: AuxDataTraits.h:40
vector
Definition: MultiHisto.h:13
PackedLinkImpl.h
Definition of PackedLink type.
AuxDataTraits.h
Allow customizing how aux data types are treated.
PackedLinkConstAccessor.icc
SG::AuxVarFlags
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition: AuxTypes.h:58
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
range_with_at.h
Add at() methods to a range class.
AuxTypes.h
Basic definitions for auxiliary types.
CxxUtils::range_with_at
Add at() methods to a range class.
Definition: range_with_at.h:33
SG::ConstAccessor::operator()
const_reference_type operator()(const ELT &e) const
Fetch the variable for one element, as a const reference.
CxxUtils::range_with_conv
Add to a range class conversions to containers.
Definition: range_with_conv.h:33
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
AuxElement.h
Base class for elements of a container that can have aux data.