ATLAS Offline Software
Loading...
Searching...
No Matches
PackedLinkDecorator.icc
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration.
3 */
4/**
5 * @file PackedLinkDecorator.icc
6 * @author scott snyder <snyder@bnl.gov>
7 * @date Nov, 2023
8 * @brief Helper class to provide type-safe access to aux data,
9 * specialized for @c PackedLink.
10 */
11
12#include "AthContainers/AuxElement.h"
13#include "AthContainers/AuxTypeRegistry.h"
14#include "AthContainers/exceptions.h"
15
16
17namespace SG {
18
19
20/**
21 * @brief Constructor.
22 * @param name Name of this aux variable.
23 *
24 * The name -> auxid lookup is done here.
25 */
26template <class CONT, class ALLOC>
27inline
28Decorator<PackedLink<CONT>, ALLOC>::Decorator (const std::string& name)
29 : Decorator (name, "", SG::AuxVarFlags::None)
30{
31}
32
33
34/**
35 * @brief Constructor.
36 * @param name Name of this aux variable.
37 * @param clsname The name of its associated class. May be blank.
38 *
39 * The name -> auxid lookup is done here.
40 */
41template <class CONT, class ALLOC>
42inline
43Decorator<PackedLink<CONT>, ALLOC>::Decorator (const std::string& name,
44 const std::string& clsname)
45 : Decorator (name, clsname, SG::AuxVarFlags::None)
46{
47}
48
49
50/**
51 * @brief Constructor taking an auxid directly.
52 * @param auxid ID for this auxiliary variable.
53 *
54 * Will throw @c SG::ExcAuxTypeMismatch if the types don't match.
55 */
56template <class CONT, class ALLOC>
57inline
58Decorator<PackedLink<CONT>, ALLOC>::Decorator (const SG::auxid_t auxid)
59{
60 AuxTypeRegistry& r = AuxTypeRegistry::instance();
61 m_auxid = auxid;
62 r.checkAuxID<PLink_t, ALLOC> (m_auxid);
63 m_linkedAuxid = r.linkedVariable (m_auxid);
64 if (m_linkedAuxid == static_cast<uint32_t>(null_auxid)) {
65 throw SG::ExcNoLinkedVar (auxid, typeid (CONT));
66 // cppcheck-suppress missingReturn; false positive
67 }
68}
69
70
71/**
72 * @brief Constructor.
73 * @param name Name of this aux variable.
74 * @param clsname The name of its associated class. May be blank.
75 * @param flags Optional flags qualifying the type. See AuxTypeRegistry.
76 *
77 * The name -> auxid lookup is done here.
78 */
79template <class CONT, class ALLOC>
80inline
81Decorator<PackedLink<CONT>, ALLOC>::Decorator
82 (const std::string& name,
83 const std::string& clsname,
84 const SG::AuxVarFlags flags)
85{
86 AuxTypeRegistry& r = AuxTypeRegistry::instance();
87 m_linkedAuxid = r.getAuxID<DLink_t, DLinkAlloc_t> (AuxTypeRegistry::linkedName (name),
88 clsname,
89 flags | AuxVarFlags::Linked);
90 m_auxid = r.getAuxID<PLink_t, ALLOC> (name, clsname, flags, m_linkedAuxid);
91}
92
93
94/**
95 * @brief Fetch the variable for one element.
96 * @param e The element for which to fetch the variable.
97 *
98 * Will return an @c ElementLink proxy, which may be converted to
99 * or assigned from an @c ElementLink.
100 *
101 * If the container is locked, this will allow fetching only variables
102 * that do not yet exist (in which case they will be marked as decorations)
103 * or variables already marked as decorations.
104 */
105template <class CONT, class ALLOC>
106template <IsConstAuxElement ELT>
107inline
108auto
109Decorator<PackedLink<CONT>, ALLOC>::operator() (const ELT& e) const -> ELProxy
110{
111 assert (e.container() != 0);
112 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&> (*e.container());
113 return ELProxy (e.container()->template getDecoration<PLink_t> (this->m_auxid, e.index()),
114 container_nc,
115 this->m_auxid,
116 this->m_linkedAuxid);
117}
118
119
120/**
121 * @brief Fetch the variable for one element.
122 * @param container The container from which to fetch the variable.
123 * @param index The index of the desired element.
124 *
125 * This allows retrieving aux data by container / index.
126 *
127 * Will return an @c ElementLink proxy, which may be converted to
128 * or assigned from an @c ElementLink.
129 *
130 * If the container is locked, this will allow fetching only variables
131 * that do not yet exist (in which case they will be marked as decorations)
132 * or variables already marked as decorations.
133 */
134template <class CONT, class ALLOC>
135inline
136auto
137Decorator<PackedLink<CONT>, ALLOC>::operator() (const AuxVectorData& container,
138 size_t index) const
139 -> ELProxy
140{
141 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&> (container);
142 return ELProxy (container.template getDecoration<PLink_t> (this->m_auxid, index),
143 container_nc, this->m_auxid, this->m_linkedAuxid);
144}
145
146
147/**
148 * @brief Set the variable for one element.
149 * @param e The element for which to set the variable.
150 * @param l The @c ElementLink to set.
151 */
152template <class CONT, class ALLOC>
153template <IsConstAuxElement ELT>
154inline
155void Decorator<PackedLink<CONT>, ALLOC>::set (const ELT& e,
156 const Link_t& l) const
157{
158 set (*e.container(), e.index(), l);
159}
160
161
162/**
163 * @brief Set the variable for one element.
164 * @param container The container for which to set the variable.
165 * @param index The index of the desired element.
166 * @param l The @c ElementLink to set.
167 */
168template <class CONT, class ALLOC>
169inline
170void Decorator<PackedLink<CONT>, ALLOC>::set (const AuxVectorData& container,
171 size_t index,
172 const Link_t& l) const
173{
174 // Have to do this before creating the converter.
175 PLink_t& ll = container.template getDecoration<PLink_t> (this->m_auxid, index);
176 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&> (container);
177 detail::PackedLinkConverter<CONT> cnv (container_nc,
178 this->m_auxid,
179 this->m_linkedAuxid);
180 cnv.set (ll, l);
181}
182
183
184/**
185 * @brief Get a pointer to the start of the array of @c PackedLinks.
186 * @param container The container from which to fetch the variable.
187 */
188template <class CONT, class ALLOC>
189inline
190auto
191Decorator<PackedLink<CONT>, ALLOC>::getPackedLinkArray (const AuxVectorData& container) const
192 -> const PLink_t*
193{
194 return reinterpret_cast<const PLink_t*> (container.getDataArray (m_auxid));
195}
196
197
198/**
199 * @brief Get a pointer to the start of the linked array of @c DataLinks.
200 * @param container The container from which to fetch the variable.
201 */
202template <class CONT, class ALLOC>
203inline
204auto
205Decorator<PackedLink<CONT>, ALLOC>::getDataLinkArray (const AuxVectorData& container) const
206 -> const DLink_t*
207{
208 return reinterpret_cast<const DLink_t*>
209 (container.getDataArray (m_linkedAuxid));
210}
211
212
213/**
214 * @brief Get a pointer to the start of the array of @c PackedLinks,
215 * as a decoration.
216 * @param container The container from which to fetch the variable.
217 *
218 * If the container is locked, this will allow fetching only variables
219 * that do not yet exist (in which case they will be marked as decorations)
220 * or variables already marked as decorations.
221 */
222template <class CONT, class ALLOC>
223inline
224auto
225Decorator<PackedLink<CONT>, ALLOC>::getPackedLinkDecorArray (const AuxVectorData& container) const
226 -> PLink_t*
227{
228 return reinterpret_cast<PLink_t*> (container.getDecorationArray (m_auxid));
229}
230
231
232/**
233 * @brief Get a pointer to the start of the linked array of @c DataLinks,
234 * as a decoration.
235 * @param container The container from which to fetch the variable.
236 *
237 * If the container is locked, this will allow fetching only variables
238 * that do not yet exist (in which case they will be marked as decorations)
239 * or variables already marked as decorations.
240 */
241template <class CONT, class ALLOC>
242inline
243auto
244Decorator<PackedLink<CONT>, ALLOC>::getDataLinkDecorArray (const AuxVectorData& container) const
245 -> DLink_t*
246{
247 return reinterpret_cast<DLink_t*> (container.getDecorationArray (m_linkedAuxid));
248}
249
250
251/**
252 * @brief Get a span over the array of @c PackedLinks.
253 * @param container The container from which to fetch the variable.
254 */
255template <class CONT, class ALLOC>
256inline
257auto
258Decorator<PackedLink<CONT>, ALLOC>::getPackedLinkSpan (const AuxVectorData& container) const
259 -> const_PackedLink_span
260{
261 const SG::AuxDataSpanBase sp = *container.getDataSpan (m_auxid);
262 return const_PackedLink_span (reinterpret_cast<const PLink_t*>(sp.beg), sp.size);
263}
264
265
266/**
267 * @brief Get a span over the array of @c DataLinks.
268 * @param container The container from which to fetch the variable.
269 */
270template <class CONT, class ALLOC>
271inline
272auto
273Decorator<PackedLink<CONT>, ALLOC>::getDataLinkSpan (const AuxVectorData& container) const
274 -> const_DataLink_span
275{
276 const AuxDataSpanBase sp = *container.getDataSpan (m_linkedAuxid);
277 return const_DataLink_span (reinterpret_cast<const DLink_t*>(sp.beg),
278 sp.size);
279}
280
281
282/**
283 * @brief Get a span of @c ElementLinks.
284 * @param container The container from which to fetch the variable.
285 */
286template <class CONT, class ALLOC>
287inline
288auto
289Decorator<PackedLink<CONT>, ALLOC>::getDataSpan (const AuxVectorData& container) const
290 -> const_span
291{
292 return const_span (getPackedLinkSpan(container),
293 ConstConverter_t (*container.getDataSpan (m_linkedAuxid)));
294}
295
296
297/**
298 * @brief Get a span over the array of @c PackedLinks, as a decoration.
299 * @param container The container from which to fetch the variable.
300 *
301 * If the container is locked, this will allow fetching only variables
302 * that do not yet exist (in which case they will be marked as decorations)
303 * or variables already marked as decorations.
304 */
305template <class CONT, class ALLOC>
306inline
307auto
308Decorator<PackedLink<CONT>, ALLOC>::getPackedLinkDecorSpan (const AuxVectorData& container) const
309 -> PackedLink_span
310{
311 // nb. AuxVectorData::getDataSpan is suitable only for const;
312 // getDecorationArray may throw if the container is empty.
313 size_t sz = container.size_v();
314 PLink_t* beg = nullptr;
315 if (sz) {
316 beg = reinterpret_cast<PLink_t*>
317 (container.getDecorationArray (this->m_auxid));
318 }
319 return PackedLink_span (beg, sz);
320}
321
322
323/**
324 * @brief Get a span over the array of @c DataLinks, as a decoration.
325 * @param container The container from which to fetch the variable.
326 *
327 * If the container is locked, this will allow fetching only variables
328 * that do not yet exist (in which case they will be marked as decorations)
329 * or variables already marked as decorations.
330 */
331template <class CONT, class ALLOC>
332inline
333auto
334Decorator<PackedLink<CONT>, ALLOC>::getDataLinkDecorSpan (const AuxVectorData& container) const
335 -> DataLink_span
336{
337 const AuxDataSpanBase sp = *container.getDataSpan (this->m_linkedAuxid);
338 if (sp.size > 0) {
339 // Accessibility check. ??? Can we get rid of this?
340 (void)container.getDecorationArray (this->m_linkedAuxid);
341 }
342 return DataLink_span (reinterpret_cast<DLink_t*>(sp.beg), sp.size);
343}
344
345
346/**
347 * @brief Get a span of @c ElementLink proxies, as a decoration.
348 * @param container The container from which to fetch the variable.
349 *
350 * The proxies may be converted to or assigned from @c ElementLink.
351 *
352 * If the container is locked, this will allow fetching only variables
353 * that do not yet exist (in which case they will be marked as decorations)
354 * or variables already marked as decorations.
355 */
356template <class CONT, class ALLOC>
357inline
358auto
359Decorator<PackedLink<CONT>, ALLOC>::getDecorationSpan (const AuxVectorData& container) const
360 -> span
361{
362 PackedLink_span pspan = getPackedLinkDecorSpan(container);
363 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&> (container);
364 return span (pspan,
365 detail::PackedLinkConverter<CONT> (container_nc,
366 this->m_auxid,
367 this->m_linkedAuxid));
368}
369
370
371/**
372 * @brief Test to see if this variable exists in the store and is writable.
373 * @param e An element of the container in which to test the variable.
374 */
375template <class CONT, class ALLOC>
376template <IsConstAuxElement ELT>
377inline
378bool
379Decorator<PackedLink<CONT>, ALLOC>::isAvailableWritable (const ELT& e) const
380{
381 return e.container() &&
382 e.container()->isAvailableWritableAsDecoration (m_auxid) &&
383 e.container()->isAvailableWritableAsDecoration (m_linkedAuxid);
384}
385
386
387/**
388 * @brief Test to see if this variable exists in the store and is writable.
389 * @param c The container in which to test the variable.
390 */
391template <class CONT, class ALLOC>
392inline
393bool
394Decorator<PackedLink<CONT>, ALLOC>::isAvailableWritable (const AuxVectorData& c) const
395{
396 return c.isAvailableWritableAsDecoration (m_auxid) &&
397 c.isAvailableWritableAsDecoration (m_linkedAuxid);
398}
399
400
401//************************************************************************
402
403
404// To make the declarations a bit more readable.
405#define DECORATOR Decorator<std::vector<PackedLink<CONT>, VALLOC>, ALLOC>
406
407
408/**
409 * @brief Constructor.
410 * @param name Name of this aux variable.
411 *
412 * The name -> auxid lookup is done here.
413 */
414template <class CONT, class ALLOC, class VALLOC>
415inline
416DECORATOR::Decorator (const std::string& name)
417 : Decorator (name, "", SG::AuxVarFlags::None)
418{
419}
420
421
422/**
423 * @brief Constructor.
424 * @param name Name of this aux variable.
425 * @param clsname The name of its associated class. May be blank.
426 *
427 * The name -> auxid lookup is done here.
428 */
429template <class CONT, class ALLOC, class VALLOC>
430inline
431DECORATOR::Decorator (const std::string& name,
432 const std::string& clsname)
433 : Decorator (name, clsname, SG::AuxVarFlags::None)
434{
435}
436
437
438/**
439 * @brief Constructor taking an auxid directly.
440 * @param auxid ID for this auxiliary variable.
441 *
442 * Will throw @c SG::ExcAuxTypeMismatch if the types don't match.
443 */
444template <class CONT, class ALLOC, class VALLOC>
445inline
446DECORATOR::Decorator (const SG::auxid_t auxid)
447{
448 AuxTypeRegistry& r = AuxTypeRegistry::instance();
449 m_auxid = auxid;
450 r.checkAuxID<VElt_t, ALLOC> (m_auxid);
451 m_linkedAuxid = r.linkedVariable (m_auxid);
452 if (m_linkedAuxid == static_cast<uint32_t>(null_auxid)) {
453 throw SG::ExcNoLinkedVar (auxid, typeid (CONT));
454 }
455}
456/**
457 * @brief Constructor.
458 * @param name Name of this aux variable.
459 * @param clsname The name of its associated class. May be blank.
460 * @param flags Optional flags qualifying the type. See AuxTypeRegistry.
461 *
462 * The name -> auxid lookup is done here.
463 */
464template <class CONT, class ALLOC, class VALLOC>
465inline
466DECORATOR::Decorator (const std::string& name,
467 const std::string& clsname,
468 const SG::AuxVarFlags flags)
469{
470 AuxTypeRegistry& r = AuxTypeRegistry::instance();
471 m_linkedAuxid = r.getAuxID<DLink_t, DLinkAlloc_t> (AuxTypeRegistry::linkedName (name),
472 clsname,
473 flags | AuxVarFlags::Linked);
474 m_auxid = r.getAuxID<VElt_t, ALLOC> (name, clsname, flags, m_linkedAuxid);
475}
476
477
478/**
479 * @brief Fetch the variable for one element.
480 * @param e The element for which to fetch the variable.
481 *
482 * This will return a range of @c ElementLink proxies.
483 * These proxies may be converted to or assigned from @c ElementLink.
484 *
485 * If the container is locked, this will allow fetching only variables
486 * that do not yet exist (in which case they will be marked as decorations)
487 * or variables already marked as decorations.
488 */
489template <class CONT, class ALLOC, class VALLOC>
490template <IsConstAuxElement ELT>
491auto
492DECORATOR::operator() (const ELT& e) const
493 -> elt_span
494{
495 assert (e.container() != 0);
496 // This has be to called before making the ELSpanProxyHelper.
497 VElt_t* veltArr = getPackedLinkVectorDecorArray(*e.container());
498 AuxVectorData& container_nc ATLAS_THREAD_SAFE = *const_cast<AuxVectorData*>(e.container());
499 return elt_span (veltArr[e.index()], container_nc,
500 this->m_auxid,
501 this->m_linkedAuxid);
502}
503
504
505/**
506 * @brief Fetch the variable for one element.
507 * @param container The container from which to fetch the variable.
508 * @param index The index of the desired element.
509 *
510 * This allows retrieving aux data by container / index.
511 *
512 * This will return a range of @c ElementLink proxies.
513 * These proxies may be converted to or assigned from @c ElementLink.
514 *
515 * If the container is locked, this will allow fetching only variables
516 * that do not yet exist (in which case they will be marked as decorations)
517 * or variables already marked as decorations.
518 */
519template <class CONT, class ALLOC, class VALLOC>
520auto
521DECORATOR::operator() (const AuxVectorData& container,
522 size_t index) const
523 -> elt_span
524{
525 // This has be to called before making the ELSpanProxyHelper.
526 VElt_t* veltArr = getPackedLinkVectorDecorArray(container);
527 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&>(container);
528 return elt_span (veltArr[index], container_nc,
529 this->m_auxid,
530 this->m_linkedAuxid);
531}
532
533
534/**
535 * @brief Set the variable for one element.
536 * @param e The element for which to set the variable.
537 * @param r The variable value to set, as a range over @c ElementLink.
538 */
539template <class CONT, class ALLOC, class VALLOC>
540template <IsConstAuxElement ELT, detail::ElementLinkRange<CONT> RANGE>
541void DECORATOR::set (const ELT& e, const RANGE& r) const
542{
543 set (*e.container(), e.index(), r);
544}
545
546
547/**
548 * @brief Set the variable for one element.
549 * @param container The container from which to fetch the variable.
550 * @param index The index of the desired element.
551 * @param r The variable value to set, as a range over @c ElementLink.
552 */
553template <class CONT, class ALLOC, class VALLOC>
554template <detail::ElementLinkRange<CONT> RANGE>
555void DECORATOR::set (const AuxVectorData& container,
556 size_t index,
557 const RANGE& r) const
558{
559 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&> (container);
560 detail::PackedLinkConverter<CONT> cnv (container_nc,
561 this->m_auxid,
562 this->m_linkedAuxid);
563 VElt_t& velt = container.template getDecoration<VElt_t> (this->m_auxid, index);
564 cnv.set (velt, r);
565}
566
567
568/**
569 * @brief Get a pointer to the start of the array of vectors of @c PackedLinks.
570 * @param container The container from which to fetch the variable.
571 */
572template <class CONT, class ALLOC, class VALLOC>
573inline
574auto
575DECORATOR::getPackedLinkVectorArray (const AuxVectorData& container) const
576 -> const VElt_t*
577{
578 return reinterpret_cast<const VElt_t*>
579 (container.getDataArray (m_auxid));
580}
581
582
583/**
584 * @brief Get a pointer to the start of the linked array of @c DataLinks.
585 * @param container The container from which to fetch the variable.
586 */
587template <class CONT, class ALLOC, class VALLOC>
588inline
589auto
590DECORATOR::getDataLinkArray (const AuxVectorData& container) const
591 -> const DLink_t*
592{
593 return reinterpret_cast<const DLink_t*>
594 (container.getDataArray (m_linkedAuxid));
595}
596
597
598/**
599 * @brief Get a pointer to the start of the array of vectors of @c PackedLinks,
600 * as a decoration.
601 * @param container The container from which to fetch the variable.
602 */
603template <class CONT, class ALLOC, class VALLOC>
604inline
605auto
606DECORATOR::getPackedLinkVectorDecorArray (const AuxVectorData& container) const
607 -> VElt_t*
608{
609 return reinterpret_cast<VElt_t*> (container.getDecorationArray (m_auxid));
610}
611
612
613/**
614 * @brief Get a pointer to the start of the linked array of @c DataLinks,
615 * as a decoration.
616 * @param container The container from which to fetch the variable.
617 */
618template <class CONT, class ALLOC, class VALLOC>
619inline
620auto
621DECORATOR::getDataLinkDecorArray (const AuxVectorData& container) const
622 -> DLink_t*
623{
624 return reinterpret_cast<DLink_t*> (container.getDecorationArray (m_linkedAuxid));
625}
626
627
628/**
629 * @brief Get a span over the vector of @c PackedLinks for a given element.
630 * @param e The element for which to fetch the variable.
631 */
632template <class CONT, class ALLOC, class VALLOC>
633template <IsConstAuxElement ELT>
634inline
635auto
636DECORATOR::getPackedLinkSpan (const ELT& e) const
637 -> const_PackedLink_span
638{
639 auto elt = reinterpret_cast<const VElt_t*>
640 (e.container()->getDataArray (this->m_auxid)) + e.index();
641 return const_PackedLink_span (elt->data(), elt->size());
642}
643
644
645/**
646 * @brief Get a span over the vector of @c PackedLinks for a given element.
647 * @param container The container from which to fetch the variable.
648 * @param index The index of the desired element.
649 */
650template <class CONT, class ALLOC, class VALLOC>
651inline
652auto
653DECORATOR::getPackedLinkSpan (const AuxVectorData& container, size_t index) const
654 -> const_PackedLink_span
655{
656 auto elt = reinterpret_cast<const VElt_t*>
657 (container.getDataArray (this->m_auxid)) + index;
658 return const_PackedLink_span (elt->data(), elt->size());
659}
660
661
662/**
663 * @brief Get a span over the vector of @c PackedLinks for a given element.
664 * @param container The container from which to fetch the variable.
665 * @param index The index of the desired element.
666 */
667template <class CONT, class ALLOC, class VALLOC>
668inline
669auto
670DECORATOR::getPackedLinkSpan (AuxVectorData& container, size_t index) const
671 -> PackedLink_span
672{
673 auto elt = reinterpret_cast<VElt_t*>
674 (container.getDataArray (this->m_auxid)) + index;
675 return PackedLink_span (elt->data(), elt->size());
676}
677
678
679/**
680 * @brief Get a span over the vectors of @c PackedLinks.
681 * @param container The container from which to fetch the variable.
682 */
683template <class CONT, class ALLOC, class VALLOC>
684inline
685auto
686DECORATOR::getPackedLinkVectorSpan (const AuxVectorData& container) const
687 -> const_PackedLinkVector_span
688{
689 auto beg = reinterpret_cast<const VElt_t*>
690 (container.getDataArray (m_auxid));
691 return const_PackedLinkVector_span (beg, container.size_v());
692}
693
694
695/**
696 * @brief Get a span over the array of @c DataLinks.
697 * @param container The container from which to fetch the variable.
698 */
699template <class CONT, class ALLOC, class VALLOC>
700inline
701auto
702DECORATOR::getDataLinkSpan (const AuxVectorData& container) const
703 -> const_DataLink_span
704{
705 const AuxDataSpanBase* sp = container.getDataSpan (m_linkedAuxid);
706 return const_DataLink_span (reinterpret_cast<const DLink_t*>(sp->beg),
707 sp->size);
708}
709
710
711/**
712 * @brief Get a span over spans of @c ElementLinks.
713 * @param container The container from which to fetch the variable.
714 */
715template <class CONT, class ALLOC, class VALLOC>
716inline
717auto
718DECORATOR::getDataSpan (const AuxVectorData& container) const
719 -> const_span
720{
721 const_PackedLinkVector_span pvspan = getPackedLinkVectorSpan(container);
722 return const_span (pvspan,
723 ConstVectorTransform_t (*container.getDataSpan (m_linkedAuxid)));
724}
725
726
727/**
728 * @brief Get a span over the vector of @c PackedLinks for a given element,
729 * as a decoration.
730 * @param e The element for which to fetch the variable.
731 *
732 * If the container is locked, this will allow fetching only variables
733 * that do not yet exist (in which case they will be marked as decorations)
734 * or variables already marked as decorations.
735 */
736template <class CONT, class ALLOC, class VALLOC>
737template <IsConstAuxElement ELT>
738inline
739auto
740DECORATOR::getPackedLinkDecorSpan (const ELT& e) const
741 -> PackedLink_span
742{
743 auto elt = reinterpret_cast<VElt_t*>
744 (e.container()->getDecorationArray (this->m_auxid)) + e.index();
745 return PackedLink_span (elt->data(), elt->size());
746}
747
748
749/**
750 * @brief Get a span over the vector of @c PackedLinks for a given element,
751 * as a decoration.
752 * @param container The container from which to fetch the variable.
753 * @param index The index of the desired element.
754 *
755 * If the container is locked, this will allow fetching only variables
756 * that do not yet exist (in which case they will be marked as decorations)
757 * or variables already marked as decorations.
758 */
759template <class CONT, class ALLOC, class VALLOC>
760inline
761auto
762DECORATOR::getPackedLinkDecorSpan (const AuxVectorData& container, size_t index) const
763 -> PackedLink_span
764{
765 auto elt = reinterpret_cast<VElt_t*>
766 (container.getDecorationArray (this->m_auxid)) + index;
767 return PackedLink_span (elt->data(), elt->size());
768}
769
770
771/**
772 * @brief Get a span over the vectors of @c PackedLinks,
773 * as a decoration.
774 * @param container The container from which to fetch the variable.
775 *
776 * If the container is locked, this will allow fetching only variables
777 * that do not yet exist (in which case they will be marked as decorations)
778 * or variables already marked as decorations.
779 */
780template <class CONT, class ALLOC, class VALLOC>
781inline
782auto
783DECORATOR::getPackedLinkVectorDecorSpan (const AuxVectorData& container) const
784 -> PackedLinkVector_span
785{
786 auto beg = reinterpret_cast<VElt_t*>
787 (container.getDecorationArray (m_auxid));
788 return PackedLinkVector_span (beg, container.size_v());
789}
790
791
792/**
793 * @brief Get a span over the array of @c DataLinks, as a decoration.
794 * @param container The container from which to fetch the variable.
795 *
796 * If the container is locked, this will allow fetching only variables
797 * that do not yet exist (in which case they will be marked as decorations)
798 * or variables already marked as decorations.
799 */
800template <class CONT, class ALLOC, class VALLOC>
801inline
802auto
803DECORATOR::getDataLinkDecorSpan (const AuxVectorData& container) const
804 -> DataLink_span
805{
806 (void)container.getDecorationArray (this->m_linkedAuxid); // check for locking
807 const AuxDataSpanBase* sp = container.getDataSpan (m_linkedAuxid);
808 return DataLink_span (reinterpret_cast<DLink_t*>(sp->beg), sp->size);
809}
810
811
812/**
813 * @brief Get a span over spans of @c ElementLink proxies,
814 * as a decoration.
815 * @param container The container from which to fetch the variable.
816 *
817 * The individual proxies may be converted to or assigned from @c ElementLink.
818 * Each element may also be assigned from a range of @c ElementLink,
819 * or converted to a vector of @c ElementLink.
820 *
821 * If the container is locked, this will allow fetching only variables
822 * that do not yet exist (in which case they will be marked as decorations)
823 * or variables already marked as decorations.
824 */
825template <class CONT, class ALLOC, class VALLOC>
826inline
827auto
828DECORATOR::getDecorationSpan (const AuxVectorData& container) const
829 -> span
830{
831 PackedLinkVector_span pvspan = getPackedLinkVectorDecorSpan(container);
832 AuxVectorData& container_nc ATLAS_THREAD_SAFE = const_cast<AuxVectorData&> (container);
833 return span (pvspan,
834 ELSpanConverter (container_nc,
835 this->m_auxid,
836 this->m_linkedAuxid));
837}
838
839
840/**
841 * @brief Test to see if this variable exists in the store and is writable.
842 * @param e An element of the container in which to test the variable.
843 */
844template <class CONT, class ALLOC, class VALLOC>
845template <IsConstAuxElement ELT>
846inline
847bool
848DECORATOR::isAvailableWritable (const ELT& e) const
849{
850 return e.container() &&
851 e.container()->isAvailableWritableAsDecoration (m_auxid) &&
852 e.container()->isAvailableWritableAsDecoration (m_linkedAuxid);
853}
854
855
856/**
857 * @brief Test to see if this variable exists in the store and is writable.
858 * @param c The container in which to test the variable.
859 */
860template <class CONT, class ALLOC, class VALLOC>
861inline
862bool
863DECORATOR::isAvailableWritable (const AuxVectorData& c) const
864{
865 return c.isAvailableWritableAsDecoration (m_auxid) &&
866 c.isAvailableWritableAsDecoration (m_linkedAuxid);
867}
868
869
870#undef DECORATOR
871
872
873} // namespace SG