ATLAS Offline Software
Loading...
Searching...
No Matches
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 */
11
12
13#ifndef ATHCONTAINERS_ELPROXY_H
14#define ATHCONTAINERS_ELPROXY_H
15
16
21#include "AthLinks/DataLink.h"
22#include "AthLinks/ElementLink.h"
25#include <functional>
26#include <ranges>
27#include <concepts>
28#include <vector>
29
30
31namespace SG { namespace detail {
32
33
37template <class CONT>
39{
40public:
42 using Cont_t = CONT;
43
44
50
51
59 SG::auxid_t auxid,
60 SG::auxid_t linked_auxid);
61
62
63protected:
66};
67
68
72template <class CONT>
74{
75public:
77 using Cont_t = CONT;
78
84
85
86protected:
89};
90
91
123template <class BASE>
125 : public BASE
126{
127public:
129 using Cont_t = typename BASE::Cont_t;
130
133
136
138 ELProxyT (const ELProxyT&) = delete;
139 ELProxyT& operator= (const ELProxyT&) = delete;
140
141
148
149
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)
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
230private:
233};
234
235
236//***************************************************************************
237
238
243template <class PROXY>
245 : public detail::PackedLinkConverter<typename PROXY::Cont_t>
246{
247public:
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
281};
282
283
286template <class CONT>
288
289
292template <class CONT>
295
296
297//***************************************************************************
298
299
301template <class CONT, class PLINK_ALLOC>
302using PackedLink_span = typename AuxDataTraits<PackedLink<CONT>, PLINK_ALLOC>::span;
303
304
306template <class CONT, class PLINK_ALLOC>
309 std::reference_wrapper<detail::ELProxyInSpanConverter<CONT> > >;
310
311
328template <class CONT, class PLINK_ALLOC>
330 : public ELSpanProxyBase<CONT, PLINK_ALLOC>
331{
332public:
335
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
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
417 void erase (iterator pos);
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
505private:
508
511};
512
513
514//***************************************************************************
515
516
521template <class CONT, class PLINK_ALLOC>
523{
524public:
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
546private:
549
552
555};
556
557
558}} // namespace SG::detail
559
560
562
563
564#endif // not ATHCONTAINERS_ELPROXY_H
Allow customizing how aux data types are treated.
Manage lookup of vectors of auxiliary data.
#define ELPROXY(M)
Definition ELProxy.h:201
Conversions between PackedLink and ElementLink.
Factory object that creates vectors using AuxTypeVector, specialized for PackedLink.
Define macros for attributes used to control the static checker.
Allow customizing how aux data types are treated.
Manage lookup of vectors of auxiliary data.
Extend PackedLinkConverter with a (non-const) conversion from PackedLink to a proxy object.
Definition ELProxy.h:246
typename PROXY::PLink_t PLink_t
Definition ELProxy.h:250
typename PROXY::Link_t value_type
Definition ELProxy.h:251
ELProxyConverter(AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
typename PROXY::Link_t Link_t
Definition ELProxy.h:249
detail::PackedLinkConverter< typename PROXY::Cont_t > Base
Definition ELProxy.h:248
ELProxyConverter(const Base &cnv)
Constructor.
PROXY operator()(PLink_t &pl)
Produce a proxy object for a given PackedLink.
CONT Cont_t
The Storable object referred to by links.
Definition ELProxy.h:77
PackedLinkConverter< CONT > & m_cnv
Converter reference.
Definition ELProxy.h:88
ELProxyRefBase(PackedLinkConverter< CONT > &cnv)
Constructor.
Proxy for ElementLink.
Definition ELProxy.h:126
ELProxyT(const ELProxyT &)=delete
Don't allow these proxy objects to be copied.
typename detail::ELProxyValBase< CONT >::Cont_t Cont_t
Definition ELProxy.h:129
ELProxyT(PLink_t &pl, AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
bool operator==(const Link_t &l) const
Equality comparison with ElementLink.
ELProxyT & operator=(const ELProxyT &)=delete
ELProxyT(PLink_t &pl, PackedLinkConverter< Cont_t > &cnv)
Constructor.
CONT Cont_t
The Storable object referred to by links.
Definition ELProxy.h:42
ELProxyValBase(AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
PackedLinkConverter< CONT > m_cnv
The contained converter.
Definition ELProxy.h:65
ELProxyValBase(PackedLinkConverter< CONT > &cnv)
Constructor.
ELSpanConverter(AuxVectorData &container, auxid_t auxid, auxid_t linked_auxid)
ELSpanProxy< CONT, VALLOC > value_type
Definition ELProxy.h:525
typename value_type::VElt_t VElt_t
Definition ELProxy.h:526
value_type operator()(VElt_t &velt) const
Convert from a PackedLink vector to a proxy for the span.
Proxy for a span of ElementLinks.
Definition ELProxy.h:331
void insert(iterator pos, ITERATOR first, ITERATOR last)
Insert a range of links into this vector of links.
std::vector< SG::PackedLink< CONT >, VALLOC > VElt_t
Definition ELProxy.h:346
void clear()
Clear this vector of links.
void assign(ITERATOR first, ITERATOR last)
Set this vector of links to a range of links.
bool operator==(const std::vector< Link_t, VALLOC > &v) const
Equality testing.
detail::PackedLink_span< CONT, VALLOC > PackedLink_span
Definition ELProxy.h:343
void insert(iterator pos, const Link_t &l)
Insert a new link into this vector of links.
void assign(size_t n, const Link_t &l)
Set this vector of links to copies of a new link.
ELProxyInSpanConverter< CONT > m_cnv
Definition ELProxy.h:510
void push_back(const Link_t &l)
Add a new link to this vector of links.
std::ranges::iterator_t< Base > iterator
Definition ELProxy.h:349
void pop_back()
Remove the last element in this vector of links.
void append_range(const RANGE &range)
Append a range of links to the end of this vector of links.
std::vector< Link_t > asVector() const
Convert to a vector of ElementLink.
SG::PackedLink< CONT > PLink_t
Definition ELProxy.h:337
ELSpanProxyBase< CONT, VALLOC > Base
Definition ELProxy.h:334
void resize(size_t n, const Link_t &l=Link_t())
Resize this vector of links.
void assign_range(const RANGE &range)
Set this vector of links to a range of links.
void erase(iterator first, iterator last)
Erase a range of elements from this vector of links.
void insert(iterator pos, size_t n, const Link_t &l)
Insert copies of a new link into this vector of links.
void operator=(const RANGE &r)
Assign from a range of ElementLink.
void erase(iterator pos)
Erase one element from this vector of links.
void insert_range(iterator pos, const RANGE &range)
Insert a range of links into this vector of links.
ELSpanProxy(VElt_t &velt, AuxVectorData &container, SG::auxid_t auxid, SG::auxid_t linked_auxid)
Constructor.
Helper: Convert a PackedLink to an ElementLink and vice-versa.
int r
Definition globals.cxx:22
range_with_at< std::ranges::transform_view< SPAN, XFORM > > transform_view_with_at
Helper to add at() methods to a transform_view.
detail::ELProxyT< detail::ELProxyRefBase< CONT > > ELProxyInSpan
Proxy holding the converter by reference — meant to be used when we have a proxy as a member of a spa...
Definition ELProxy.h:287
CxxUtils::transform_view_with_at< PackedLink_span< CONT, PLINK_ALLOC >, std::reference_wrapper< detail::ELProxyInSpanConverter< CONT > > > ELSpanProxyBase
A range transforming a span over PackedLink to ElementLink proxies.
Definition ELProxy.h:307
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.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Definition index.py:1
Add at() methods to a range class.