ATLAS Offline Software
ELProxy.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  */
13 #ifndef ATHCONTAINERS_ELPROXY_H
14 #define ATHCONTAINERS_ELPROXY_H
15 
16 
21 #include "AthLinks/DataLink.h"
22 #include "AthLinks/ElementLink.h"
23 #include "CxxUtils/range_with_at.h"
25 #include <functional>
26 #include <ranges>
27 #include <concepts>
28 #include <vector>
29 
30 
31 namespace SG { namespace detail {
32 
33 
37 template <class CONT>
39 {
40 public:
42  using Cont_t = CONT;
43 
44 
50 
51 
59  SG::auxid_t auxid,
60  SG::auxid_t linked_auxid);
61 
62 
63 protected:
66 };
67 
68 
72 template <class CONT>
74 {
75 public:
77  using Cont_t = CONT;
78 
84 
85 
86 protected:
89 };
90 
91 
123 template <class BASE>
124 class ELProxyT
125  : public BASE
126 {
127 public:
129  using Cont_t = typename BASE::Cont_t;
130 
133 
135  using PLink_t = SG::PackedLink<Cont_t>;
136 
138  ELProxyT (const ELProxyT&) = delete;
139  ELProxyT& operator= (const ELProxyT&) = delete;
140 
141 
148 
149 
159  ELProxyT (PLink_t& pl, AuxVectorData& container,
160  SG::auxid_t auxid,
161  SG::auxid_t linked_auxid);
162 
163 
167  operator const Link_t() const;
168 
169 
174  const Link_t operator= (const Link_t& link);
175 
176 
183  bool operator== (const Link_t& l) const;
184 
185 
192  bool operator== (const ELProxyT& p) const;
193 
194 
195  // nb. We don't proxy the implicit converison of ElementLink
196  // to a pointer --- that can end up matching in places where we don't
197  // want it to.
198 
199 
200  // Proxy const methods of @c ElementLink.
201 #define ELPROXY(M) auto M() const { return this->m_cnv (m_pl).M(); }
202  ELPROXY(getDataPtr)
203  ELPROXY(getDataNonConstPtr)
204  ELPROXY(getDataLink)
205  ELPROXY(getStorableObjectPointer)
206  ELPROXY(getStorableObjectRef)
207  ELPROXY(cptr)
208  ELPROXY(operator*)
209  ELPROXY(operator->)
210  ELPROXY(operator!)
211  ELPROXY(isvalid)
212  ELPROXY(cachedElement)
213 #ifndef XAOD_STANDALONE
214  ELPROXY(isDefaultIndex)
215 #endif
216  ELPROXY(hasCachedElement)
217  ELPROXY(isDefault)
218  ELPROXY(index)
219  ELPROXY(persIndex)
220  ELPROXY(dataID)
221  ELPROXY(key)
222  ELPROXY(persKey)
223 #ifndef XAOD_STANDALONE
224  ELPROXY(source)
225  ELPROXY(proxy)
226 #endif
227 #undef ELPROXY
228 
229 
230 private:
233 };
234 
235 
236 //***************************************************************************
237 
238 
243 template <class PROXY>
245  : public detail::PackedLinkConverter<typename PROXY::Cont_t>
246 {
247 public:
249  using Link_t = typename PROXY::Link_t;
250  using PLink_t = typename PROXY::PLink_t;
251  using value_type = typename PROXY::Link_t;
252 
253 
258  ELProxyConverter (const Base& cnv);
259 
260 
268  SG::auxid_t auxid,
269  SG::auxid_t linked_auxid);
270 
271 
273  using Base::operator();
274 
275 
280  PROXY operator() (PLink_t& pl);
281 };
282 
283 
286 template <class CONT>
288 
289 
292 template <class CONT>
295 
296 
297 //***************************************************************************
298 
299 
301 template <class CONT, class PLINK_ALLOC>
303 
304 
306 template <class CONT, class PLINK_ALLOC>
309  std::reference_wrapper<detail::ELProxyInSpanConverter<CONT> > >;
310 
311 
328 template <class CONT, class PLINK_ALLOC>
330  : public ELSpanProxyBase<CONT, PLINK_ALLOC>
331 {
332 public:
335 
337  using PLink_t = SG::PackedLink<CONT>;
338 
341 
344 
346  using VElt_t = std::vector<SG::PackedLink<CONT>, PLINK_ALLOC>;
347 
349  using iterator = std::ranges::iterator_t<Base>;
350 
351 
359  ELSpanProxy (VElt_t& velt, AuxVectorData& container,
360  SG::auxid_t auxid,
361  SG::auxid_t linked_auxid);
362 
363 
368  template <ElementLinkRange<CONT> RANGE>
369  void operator= (const RANGE& r);
370 
371 
375  template <class VALLOC>
376  operator std::vector<Link_t, VALLOC>() const;
377 
378 
382  std::vector<Link_t> asVector() const;
383 
384 
388  template <class VALLOC>
389  bool operator== (const std::vector<Link_t, VALLOC>& v) const;
390 
391 
396  void push_back (const Link_t& l);
397 
398 
402  void clear();
403 
404 
410  void resize (size_t n, const Link_t& l = Link_t());
411 
412 
418 
419 
426  void erase (iterator first, iterator last);
427 
428 
434  void insert (iterator pos, const Link_t& l);
435 
436 
443  void insert (iterator pos, size_t n, const Link_t& l);
444 
445 
452  template <CxxUtils::detail::InputValIterator<ElementLink<CONT> > ITERATOR>
453  void insert (iterator pos, ITERATOR first, ITERATOR last);
454 
455 
461  template <ElementLinkRange<CONT> RANGE>
462  void insert_range (iterator pos, const RANGE& range);
463 
464 
469  template <ElementLinkRange<CONT> RANGE>
470  void append_range (const RANGE& range);
471 
472 
476  void pop_back();
477 
478 
484  void assign (size_t n, const Link_t& l);
485 
486 
492  template <CxxUtils::detail::InputValIterator<ElementLink<CONT> > ITERATOR>
493  void assign (ITERATOR first, ITERATOR last);
494 
495 
501  template <ElementLinkRange<CONT> RANGE>
502  void assign_range (const RANGE& range);
503 
504 
505 private:
508 
511 };
512 
513 
514 //***************************************************************************
515 
516 
521 template <class CONT, class PLINK_ALLOC>
523 {
524 public:
526  using VElt_t = typename value_type::VElt_t;
527 
528  /***
529  * @brief Constructor.
530  * @param container Container holding the variables.
531  * @param auxid The ID of the PackedLink variable.
532  * @param linked_auxid The ID of the linked DataLinks.
533  */
535  auxid_t auxid,
536  auxid_t linked_auxid);
537 
538 
544 
545 
546 private:
549 
552 
555 };
556 
557 
558 }} // namespace SG::detail
559 
560 
562 
563 
564 #endif // not ATHCONTAINERS_ELPROXY_H
beamspotman.r
def r
Definition: beamspotman.py:676
SG::detail::ELProxyValBase::m_cnv
PackedLinkConverter< CONT > m_cnv
The contained converter.
Definition: ELProxy.h:65
SG::detail::ELProxyT
Proxy for ElementLink.
Definition: ELProxy.h:126
CxxUtils::span
span(T *ptr, std::size_t sz) -> span< T >
A couple needed deduction guides.
SG::detail::ELProxyConverter::ELProxyConverter
ELProxyConverter(const Base &cnv)
Constructor.
SG::detail::ELSpanProxy::insert
void insert(iterator pos, ITERATOR first, ITERATOR last)
Insert a range of links into this vector of links.
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
SG::detail::ELProxyRefBase
Base class for ELProxyT, with the converter held by reference.
Definition: ELProxy.h:74
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::detail::ELSpanProxy::Link_t
ElementLink< CONT > Link_t
The ElementLink class we resolve to.
Definition: ELProxy.h:340
SG::detail::ELProxyConverter::ELProxyConverter
ELProxyConverter(AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
SG::detail::ELProxyT::operator==
bool operator==(const Link_t &l) const
Equality comparison with ElementLink.
PackedLinkVectorFactory.h
Factory object that creates vectors using AuxTypeVector, specialized for PackedLink.
SG::detail::ELSpanProxy::VElt_t
std::vector< SG::PackedLink< CONT >, PLINK_ALLOC > VElt_t
The vector of @PackedLink that we proxy.
Definition: ELProxy.h:346
index
Definition: index.py:1
SG::detail::ELProxyConverter
Extend PackedLinkConverter with a (non-const) conversion from PackedLink to a proxy object.
Definition: ELProxy.h:246
SG::detail::ELSpanConverter::m_linkedAuxid
auxid_t m_linkedAuxid
The ID of the linked DataLinks.
Definition: ELProxy.h:554
xAODMaker::Cont_t
xAOD::TruthMetaDataContainer Cont_t
Definition: TruthMetaDataTool.cxx:17
SG::detail::PackedLinkConverter
Helper: Convert a PackedLink to an ElementLink and vice-versa.
Definition: PackedLinkConversions.h:120
SG::detail::ELSpanProxy::m_cnv
ELProxyInSpanConverter< CONT > m_cnv
The converter to use for the span.
Definition: ELProxy.h:510
SG::detail::ELSpanProxy::assign
void assign(ITERATOR first, ITERATOR last)
Set this vector of links to a range of links.
detail
Definition: extract_histogram_tag.cxx:14
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
SG::detail::ELSpanProxy::resize
void resize(size_t n, const Link_t &l=Link_t())
Resize this vector of links.
SG::detail::ELProxyT::ELProxyT
ELProxyT(PLink_t &pl, PackedLinkConverter< Cont_t > &cnv)
Constructor.
SG::detail::ELSpanProxy::append_range
void append_range(const RANGE &range)
Append a range of links to the end of this vector of links.
SG::detail::ELProxyRefBase::Cont_t
CONT Cont_t
The Storable object referred to by links.
Definition: ELProxy.h:77
SG::detail::ELProxyT::m_pl
PLink_t & m_pl
The proxied PackedLink.
Definition: ELProxy.h:232
ELProxy.icc
SG::detail::ELProxyT::operator=
ELProxyT & operator=(const ELProxyT &)=delete
SG::detail::ELSpanProxy::assign_range
void assign_range(const RANGE &range)
Set this vector of links to a range of links.
PackedLinkConversions.h
Conversions between PackedLink and ElementLink.
SG::detail::ELSpanProxy::clear
void clear()
Clear this vector of links.
SG::detail::ELSpanProxy::insert
void insert(iterator pos, size_t n, const Link_t &l)
Insert copies of a new link into this vector of links.
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::detail::ELSpanConverter::ELSpanConverter
ELSpanConverter(AuxVectorData &container, auxid_t auxid, auxid_t linked_auxid)
SG::detail::ELSpanConverter::VElt_t
typename value_type::VElt_t VElt_t
Definition: ELProxy.h:526
SG::detail::ELProxyValBase::ELProxyValBase
ELProxyValBase(PackedLinkConverter< CONT > &cnv)
Constructor.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::detail::ELProxyT::ELProxyT
ELProxyT(PLink_t &pl, AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
SG::detail::ELSpanConverter
Converter from a vector of PackedLink to a range of ElementLink proxies.
Definition: ELProxy.h:523
SG::detail::ELSpanProxy::assign
void assign(size_t n, const Link_t &l)
Set this vector of links to copies of a new link.
SG::detail::ELProxyT::ELProxyT
ELProxyT(const ELProxyT &)=delete
Don't allow these proxy objects to be copied.
beamspotman.n
n
Definition: beamspotman.py:731
SG::AuxDataTraits
Allow customizing how aux data types are treated.
Definition: AuxDataTraits.h:40
SG::detail::ELSpanConverter::operator()
value_type operator()(VElt_t &velt) const
Convert from a PackedLink vector to a proxy for the span.
SG::detail::ELProxyT::Cont_t
typename BASE::Cont_t Cont_t
Get the Storable from the base class.
Definition: ELProxy.h:129
SG::detail::ELSpanProxy
Proxy for a span of ElementLinks.
Definition: ELProxy.h:331
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
SG::detail::ELSpanProxy::PLink_t
SG::PackedLink< CONT > PLink_t
The PackedLink class we proxy.
Definition: ELProxy.h:337
AuxDataTraits.h
Allow customizing how aux data types are treated.
SG::detail::ELSpanProxy::insert
void insert(iterator pos, const Link_t &l)
Insert a new link into this vector of links.
SG::detail::ELSpanProxy::PackedLink_span
detail::PackedLink_span< CONT, PLINK_ALLOC > PackedLink_span
A span over PackedLink.
Definition: ELProxy.h:343
SG::detail::ELProxyT::Link_t
ElementLink< Cont_t > Link_t
The ElementLink class we provide.
Definition: ELProxy.h:132
AuxVectorData.h
Manage lookup of vectors of auxiliary data.
SG::detail::ELSpanProxy::push_back
void push_back(const Link_t &l)
Add a new link to this vector of links.
SG::detail::ELProxyConverter::operator()
PROXY operator()(PLink_t &pl)
Produce a proxy object for a given PackedLink.
SG::detail::ELProxyRefBase::m_cnv
PackedLinkConverter< CONT > & m_cnv
Converter reference.
Definition: ELProxy.h:88
SG::detail::ELProxyT::PLink_t
SG::PackedLink< Cont_t > PLink_t
The PackedLink class we proxy.
Definition: ELProxy.h:135
SG::detail::ELSpanConverter::m_container
AuxVectorData & m_container
Container holding the variables.
Definition: ELProxy.h:548
SG::detail::ELSpanProxy::erase
void erase(iterator pos)
Erase one element from this vector of links.
SG::detail::ELSpanProxy::erase
void erase(iterator first, iterator last)
Erase a range of elements from this vector of links.
SG::detail::ELProxyValBase
Base class for ELProxyT, with the converter held by value.
Definition: ELProxy.h:39
SG::detail::ELSpanProxy::operator==
bool operator==(const std::vector< Link_t, VALLOC > &v) const
Equality testing.
SG::detail::ELSpanProxy::iterator
std::ranges::iterator_t< Base > iterator
Iterator type for this range.
Definition: ELProxy.h:349
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::detail::ELSpanProxy::ELSpanProxy
ELSpanProxy(VElt_t &velt, AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
range_with_at.h
Add at() methods to a range class.
python.PyAthena.v
v
Definition: PyAthena.py:154
CxxUtils::range_with_at
Add at() methods to a range class.
Definition: range_with_at.h:33
SG::detail::ELProxyValBase::Cont_t
CONT Cont_t
The Storable object referred to by links.
Definition: ELProxy.h:42
SG::detail::ELSpanConverter::m_auxid
auxid_t m_auxid
The ID of the PackedLink variable.
Definition: ELProxy.h:551
DeMoScan.first
bool first
Definition: DeMoScan.py:536
SG::detail::ELSpanProxy::asVector
std::vector< Link_t > asVector() const
Convert to a vector of ElementLink.
SG::detail::ELSpanProxy::operator=
void operator=(const RANGE &r)
Assign from a range of ElementLink.
ELPROXY
#define ELPROXY(M)
Definition: ELProxy.h:201
copySelective.source
string source
Definition: copySelective.py:32
SG::detail::ELProxyValBase::ELProxyValBase
ELProxyValBase(AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
SG::detail::ELSpanProxy::pop_back
void pop_back()
Remove the last element in this vector of links.
SG::detail::ELSpanProxy::insert_range
void insert_range(iterator pos, const RANGE &range)
Insert a range of links into this vector of links.
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168
SG::detail::PackedLink_span
typename AuxDataTraits< PackedLink< CONT >, PLINK_ALLOC >::span PackedLink_span
A span over PackedLink.
Definition: ELProxy.h:302
SG::detail::ELProxyConverter< CONT >::Link_t
typename PROXY::Link_t Link_t
Definition: ELProxy.h:249
checker_macros.h
Define macros for attributes used to control the static checker.
value_type
Definition: EDM_MasterSearch.h:11
SG::detail::ELProxyRefBase::ELProxyRefBase
ELProxyRefBase(PackedLinkConverter< CONT > &cnv)
Constructor.
SG::detail::ELProxyConverter< CONT >::PLink_t
typename PROXY::PLink_t PLink_t
Definition: ELProxy.h:250
SG::detail::ELSpanProxy::m_velt
VElt_t & m_velt
The vector of PackedLink that we proxy.
Definition: ELProxy.h:507
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37