ATLAS Offline Software
Loading...
Searching...
No Matches
PackedLinkDecorator.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-2026 CERN for the benefit of the ATLAS collaboration.
4 */
12
13
14#ifndef ATHCONTAINERS_PACKEDLINKDECORATOR_H
15#define ATHCONTAINERS_PACKEDLINKDECORATOR_H
16
17
29#include "AthLinks/DataLink.h"
31#include <ranges>
32#include <string>
33#include <typeinfo>
34#include <iterator>
35
36
37namespace SG {
38
39
74template <class CONT, class ALLOC>
75class Decorator<PackedLink<CONT>, ALLOC>
77{
78public:
79 // Aliases for the types we're dealing with.
80 using Link_t = ElementLink<CONT>;
81 using PLink_t = SG::PackedLink<CONT>;
82 using DLink_t = DataLink<CONT>;
83 using DLinkAlloc_t = typename std::allocator_traits<ALLOC>::template rebind_alloc<DLink_t>;
84
85
87 using const_PackedLink_span = typename AuxDataTraits<PackedLink<CONT>, ALLOC>::const_span;
88 using const_DataLink_span = typename AuxDataTraits<DataLink<CONT>, DLinkAlloc_t>::const_span;
89 using PackedLink_span = typename AuxDataTraits<PackedLink<CONT>, ALLOC>::span;
90 using DataLink_span = typename AuxDataTraits<DataLink<CONT>, DLinkAlloc_t>::span;
91
92
94 using ConstConverter_t = detail::PackedLinkConstConverter<CONT>;
95
96
98 using const_span = std::ranges::transform_view<const_PackedLink_span,
99 ConstConverter_t>;
100
101
103 using ELProxy = detail::ELProxyT<detail::ELProxyValBase<CONT> >;
104
105
108 using span = std::ranges::transform_view<PackedLink_span,
110
111
113 using element_type = Link_t;
114
116 using reference_type = ELProxy;
117
119 using const_reference_type = element_type;
120
123 using rhs_const_reference_type = const Link_t&;
124
126 using container_pointer_type = void;
127 using const_container_pointer_type = void;
128
129
136 Decorator (const std::string& name);
137
138
146 Decorator (const std::string& name, const std::string& clsname);
147
148
156
157
169 template <IsConstAuxElement ELT>
170 ELProxy operator() (const ELT& e) const;
171
172
187 ELProxy
188 operator() (const AuxVectorData& container, size_t index) const;
189
190
196 template <IsConstAuxElement ELT>
197 void set (const ELT& e, const element_type& l) const;
198
199
206 void set (const AuxVectorData& container, size_t index, const Link_t& x) const;
207
208
213 const PLink_t*
215
216
221 const DLink_t*
223
224
234 PLink_t*
236
237
247 DLink_t*
249
250
255 const_PackedLink_span
257
258
263 const_DataLink_span
265
266
272 getDataSpan (const AuxVectorData& container) const;
273
274
283 PackedLink_span
285
286
295 DataLink_span
297
298
309 span
311
312
317 template <IsConstAuxElement ELT>
318 bool isAvailableWritable (const ELT& e) const;
319
320
325 bool isAvailableWritable (const AuxVectorData& c) const;
326
327
328protected:
337 Decorator (const std::string& name,
338 const std::string& clsname,
339 const SG::AuxVarFlags flags);
340};
341
342
343//************************************************************************
344
345
391template <class CONT, class ALLOC, class VALLOC>
392class Decorator<std::vector<PackedLink<CONT>, VALLOC>, ALLOC>
393 : public detail::LinkedVarAccessorBase
394{
395public:
396 // Aliases for the types we're dealing with.
398 using PLink_t = SG::PackedLink<CONT>;
399 using VElt_t = std::vector<SG::PackedLink<CONT>, VALLOC>;
400 using DLink_t = DataLink<CONT>;
401 using DLinkAlloc_t = typename std::allocator_traits<ALLOC>::template rebind_alloc<DLink_t>;
402
404 using const_PackedLinkVector_span = typename AuxDataTraits<VElt_t, ALLOC>::const_span;
405 using const_DataLink_span = typename AuxDataTraits<DataLink<CONT>, DLinkAlloc_t>::const_span;
406 using PackedLinkVector_span = typename AuxDataTraits<VElt_t, ALLOC>::span;
407 using DataLink_span = typename AuxDataTraits<DataLink<CONT>, DLinkAlloc_t>::span;
408
410 using const_PackedLink_span = typename AuxDataTraits<PackedLink<CONT>, VALLOC>::const_span;
411 using PackedLink_span = typename AuxDataTraits<PackedLink<CONT>, VALLOC>::span;
412
413
415 using ConstVectorTransform_t = detail::PackedLinkVectorConstConverter<CONT>;
416
419 using const_span = std::ranges::transform_view<const_PackedLinkVector_span,
420 ConstVectorTransform_t>;
421
422
425
426
430 using span = std::ranges::transform_view<PackedLinkVector_span,
432
433
436
439
443
444
451 Decorator (const std::string& name);
452
453
461 Decorator (const std::string& name, const std::string& clsname);
462
463
471
472
484 template <IsConstAuxElement ELT>
485 elt_span operator() (const ELT& e) const;
486
487
503 operator() (const AuxVectorData& container, size_t index) const;
504
505
511 template <IsConstAuxElement ELT, detail::ElementLinkRange<CONT> RANGE>
512 void set (const ELT& e, const RANGE& x) const;
513
514
521 template <detail::ElementLinkRange<CONT> RANGE>
522 void set (const AuxVectorData& container, size_t index, const RANGE& r) const;
523
524
529 const VElt_t*
531
532
537 const DLink_t*
539
540
546 VElt_t*
548
549
555 DLink_t*
557
558
563 template <IsConstAuxElement ELT>
564 const_PackedLink_span
565 getPackedLinkSpan (const ELT& e) const;
566
567
573 const_PackedLink_span
575
576
582 PackedLink_span
584
585
590 const_PackedLinkVector_span
592
593
598 const_DataLink_span
600
601
607 getDataSpan (const AuxVectorData& container) const;
608
609
619 template <IsConstAuxElement ELT>
620 PackedLink_span
621 getPackedLinkDecorSpan (const ELT& e) const;
622
623
634 PackedLink_span
636
637
647 PackedLinkVector_span
649
650
659 DataLink_span
661
662
676 span
678
679
684 template <IsConstAuxElement ELT>
685 bool isAvailableWritable (const ELT& e) const;
686
687
692 bool isAvailableWritable (const AuxVectorData& e) const;
693
694
695protected:
704 Decorator (const std::string& name,
705 const std::string& clsname,
706 const SG::AuxVarFlags flags);
707};
708
709
710} // namespace SG
711
712
714
715
716
717#endif // not ATHCONTAINERS_PACKEDLINKDECORATOR_H
Allow customizing how aux data types are treated.
Handle mappings between names and auxid_t.
Basic definitions for auxiliary types.
Manage lookup of vectors of auxiliary data.
Helper class to provide type-safe access to aux data.
Helpers for proxying ElementLink for PackedLink accessors.
Flag that a class may have auxiliary data associated with it.
ElementLink< xAOD::TruthParticleContainer > Link_t
Helper class to provide constant type-safe access to aux data, specialized for PackedLink.
Definition of PackedLink type.
Factory object that creates vectors using AuxTypeVector, specialized for PackedLink.
#define x
Define macros for attributes used to control the static checker.
CxxUtils::span< container_value_type > span
CxxUtils::span< const container_value_type > const_span
Manage lookup of vectors of auxiliary data.
Converter from a vector of PackedLink to a range of ElementLink proxies.
Definition ELProxy.h:523
Proxy for a span of ElementLinks.
Definition ELProxy.h:331
Base class usable for accessors for variables with linked variables.
int r
Definition globals.cxx:22
detail::ELProxyConverter< detail::ELProxyInSpan< CONT > > ELProxyInSpanConverter
Converter producing a proxy — meant to be used when we have a proxy as a member of a span.
Definition ELProxy.h:293
typename AuxDataTraits< PackedLink< CONT >, PLINK_ALLOC >::span PackedLink_span
A span over PackedLink.
Definition ELProxy.h:302
Forward declaration.
detail::ELSpanConverter< CONT, VALLOC > ELSpanConverter
Transform a span over vector of PackedLink to a span over span over ElementLink proxies.
AuxVarFlags
Additional flags to qualify an auxiliary variable.
Definition AuxTypes.h:58
PackedLink_span getPackedLinkDecorSpan(const AuxVectorData &container) const
Get a span over the array of PackedLinks, as a decoration.
std::ranges::transform_view< const_PackedLinkVector_span, ConstVectorTransform_t > const_span
Helper class to provide constant type-safe access to aux data, specialized for a vector of PackedLink...
DataLink_span getDataLinkDecorSpan(const AuxVectorData &container) const
Get a span over the array of DataLinks, as a decoration.
const_PackedLinkVector_span getPackedLinkVectorSpan(const AuxVectorData &container) const
Get a span over the vectors of PackedLinks.
detail::ELSpanProxy< CONT, VALLOC > elt_span
Presents a vector of PackedLink as a range of ElementLink proxies.
std::ranges::transform_view< PackedLinkVector_span, ELSpanConverter > span
const_PackedLink_span getPackedLinkSpan(const AuxVectorData &container) const
Get a span over the array of PackedLinks.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
SG::auxid_t auxid() const
Return the aux id for this variable.
const PLink_t * getPackedLinkArray(const AuxVectorData &container) const
Get a pointer to the start of the array of PackedLinks.
void set(const ELT &e, const element_type &x) const
Set the variable for one element.
const_DataLink_span getDataLinkSpan(const AuxVectorData &container) const
Get a span over the array of DataLinks.
reference_type operator()(const ELT &e) const
Fetch the variable for one element, as a non-const reference.
PackedLinkVector_span getPackedLinkVectorDecorSpan(const AuxVectorData &container) const
Get a span over the vectors of PackedLinks, as a decoration.
void const_container_pointer_type
DLink_t * getDataLinkDecorArray(const AuxVectorData &container) const
Get a pointer to the start of the linked array of DataLinks, as a decoration.
elt_span reference_type
Type referencing an item.
const SG::AuxVectorData * container() const
Return the container holding this element.
XAOD_AUXDATA_DEPRECATED bool isAvailableWritable(const std::string &name, const std::string &clsname="")
Check if an aux variable is available for writing.
VElt_t * getPackedLinkVectorDecorArray(const AuxVectorData &container) const
Get a pointer to the start of the array of vectors of PackedLinks, as a decoration.
PLink_t * getPackedLinkDecorArray(const AuxVectorData &container) const
Get a pointer to the start of the array of PackedLinks, as a decoration.
const_span getDataSpan(const AuxVectorData &container) const
Get a span over the auxiliary data array.
elt_span element_type
Type the user sees.
const DLink_t * getDataLinkArray(const AuxVectorData &container) const
Get a pointer to the start of the linked array of DataLinks.
const VElt_t * getPackedLinkVectorArray(const AuxVectorData &container) const
Get a pointer to the start of the array of vectors of PackedLinks.
span getDecorationSpan(const AuxVectorData &container) const
Get a span over the auxiliary data array.
void container_pointer_type
Not supported.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Definition index.py:1
STL namespace.