ATLAS Offline Software
Loading...
Searching...
No Matches
AuxVectorBase.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/*
4 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5*/
12
13
14#ifndef ATHCONTAINERS_AUXVECTORBASE_H
15#define ATHCONTAINERS_AUXVECTORBASE_H
16
17
28#include <vector>
29
30
31namespace SG {
32
33
97 : public AuxVectorData
98{
99public:
101 template <class T> using span = typename AuxDataTraits<T>::span;
102 template <class T> using const_span = typename AuxDataTraits<T>::const_span;
103
104
115
116
122
123
129
130
134 virtual ~AuxVectorBase();
135
136
140 bool trackIndices() const;
141
142
156 void setStore (SG::IAuxStore* store);
157
158
169 void setStore (const SG::IConstAuxStore* store);
170
171
182 void setStore (const DataLink< SG::IConstAuxStore >& store);
183
184
190
191
197
198
199 // Templated versions of isAvailable, etc.
200 // We put them here rather than in AuxVectorData so that AuxVectorData.h
201 // doesn't need to include AuxTypeRegistry.h. Otherwise we get a
202 // a cyclic header dependency:
203 // AuxTypeRegistry -> AuxTypeVectorFactory -> AuxVectorData -> AuxTypeRegistry
204
208
209
215 template <class T>
216 bool isAvailable (const std::string& name,
217 const std::string& clsname = "") const;
218
219
225 template <class T>
226 bool isAvailableWritable (const std::string& name,
227 const std::string& clsname = "");
228
229
235 template <class T>
236 bool isAvailableWritableAsDecoration (const std::string& name,
237 const std::string& clsname = "") const;
238
239
251 template <class T>
252 span<T> getDataSpan (const std::string& name);
253
254
266 template <class T>
267 const_span<T> getDataSpan (const std::string& name) const;
268
269
281 template <class T>
282 const_span<T> getConstDataSpan (const std::string& name) const;
283
284
302 template <class T>
303 span<T> getDecorationSpan (const std::string& name) const;
304
305
315 static constexpr bool supportsThinning = true;
316
317
318protected:
332 template <class DVL>
334 SG::IndexTrackingPolicy indexTrackingPolicy);
335
336
341 void swap (AuxVectorBase& other);
342
343
356 template <class ForwardIterator>
357 void setIndices (ForwardIterator beg,
358 ForwardIterator end,
359 size_t first = 0);
360
361
369 template <class ForwardIterator>
370 void clearIndex (ForwardIterator elt);
371
372
381 template <class ForwardIterator>
382 void clearIndices (ForwardIterator beg, ForwardIterator end);
383
384
391 template <class DVL>
392 void resize (size_t size);
393
394
401 template <class DVL>
402 void reserve (size_t size);
403
404
430 template <class DVL>
431 void shift (DVL& cont, size_t pos, ptrdiff_t offs);
432
433
450 void moveAux (size_t index, SG::AuxElement* p,
451 bool clear = false,
452 bool skipDestClear = false);
453
454
469
470
485 void moveAuxNoClear (size_t /*index*/, const void* /*p*/);
486
487
502 void moveAux (size_t index, const void* p, bool clear = false,
503 bool skipDestClear = false);
504
505
527 template <class ForwardIterator>
528 void moveAux (size_t index, ForwardIterator beg, ForwardIterator end,
529 bool clear = false,
530 bool skipDestClear = false);
531
532
546 void swapElementsAux (size_t aindex,
547 size_t bindex,
550 AuxVectorBase* bcont);
551
552
565 void swapElementsAux (size_t aindex,
566 size_t bindex,
567 const void* a,
568 const void* b,
569 AuxVectorBase* bcont);
570
571
586 template <class ForwardIterator>
587 void resortAux (size_t index,
588 ForwardIterator beg,
589 ForwardIterator end);
590
591
592private:
602 void initAuxVectorBase1 (const std::false_type&,
603 SG::OwnershipPolicy /*ownPolicy*/,
604 SG::IndexTrackingPolicy /*indexTrackingPolicy*/);
605
606
616 void initAuxVectorBase1 (const std::true_type&,
617 SG::OwnershipPolicy ownPolicy,
618 SG::IndexTrackingPolicy indexTrackingPolicy);
619
620
630 template <class ForwardIterator>
631 void setIndices1 (const std::false_type&,
632 ForwardIterator beg,
633 ForwardIterator end,
634 size_t first);
635
636
647 template <class ForwardIterator>
648 void setIndices1 (const std::true_type&,
649 ForwardIterator beg,
650 ForwardIterator end,
651 size_t first);
652
653
661 template <class ForwardIterator>
662 void clearIndex1 (const std::false_type&, ForwardIterator elt);
663
664
671 template <class ForwardIterator>
672 void clearIndex1 (const std::true_type&, ForwardIterator elt);
673
674
682 template <class ForwardIterator>
683 void clearIndices1 (const std::false_type&,
684 ForwardIterator,
685 ForwardIterator);
686
687
695 template <class ForwardIterator>
696 void clearIndices1 (const std::true_type&,
697 ForwardIterator beg,
698 ForwardIterator end);
699
700
701
708 void resize1 (const std::false_type&, size_t size);
709
710
717 void resize1 (const std::true_type&, size_t size);
718
719
726 void reserve1 (const std::false_type&, size_t size);
727
728
735 void reserve1 (const std::true_type&, size_t size);
736
737
746 template <class DVL>
747 void shift1 (const std::false_type&,
748 DVL& cont, size_t pos, ptrdiff_t offs);
749
750
778 template <class DVL>
779 void shift1 (const std::true_type&,
780 DVL& cont, size_t pos, ptrdiff_t offs);
781
782
798 template <class ForwardIterator>
799 void moveAux1 (const std::false_type&,
800 size_t index,
801 ForwardIterator beg,
802 ForwardIterator end,
803 bool clear = false,
804 bool skipDestClear = false);
805
806
827 template <class ForwardIterator>
828 void moveAux1 (const std::true_type&,
829 size_t index,
830 ForwardIterator beg,
831 ForwardIterator end,
832 bool clear = false,
833 bool skipDestClear = false);
834
835
844 template <class ForwardIterator>
845 void resortAux1 (const std::false_type&,
846 size_t index,
847 ForwardIterator beg,
848 ForwardIterator end);
849
850
864 template <class ForwardIterator>
865 void resortAux1 (const std::true_type&,
866 size_t index,
867 ForwardIterator a,
868 ForwardIterator b);
869
870
871private:
878 {
879 public:
880 ResortAuxHelper (size_t sz, size_t index, AuxVectorBase& vec);
881 void resortElement (size_t idx, SG::AuxElement* elt);
882
883 private:
885 size_t m_index;
886 std::vector<size_t> m_imap;
887 std::vector<size_t> m_rmap;
888 std::vector<void*> m_auxdata;
889 std::vector<SG::auxid_t> m_auxids;
890
892 };
894 void setIndexForResort (SG::AuxElement* elt, size_t idx);
895 friend class ResortAuxHelper;
896
897
900};
901
902
903} // namespace SG
904
905
906#ifndef XAOD_STANDALONE
908CLASS_DEF( SG::AuxVectorBase, 33347479, 1 )
909#endif
910
911
913
914
915#endif // not DATAMODEL_AUXVECTORBASE_H
An overridable variant of assert.
Allow customizing how aux data types are treated.
Base class for elements of a container that can have aux data.
Associate AuxStore classes with EDM container classes.
Handle mappings between names and auxid_t.
Manage lookup of vectors of auxiliary data.
std::vector< size_t > vec
Exceptions that can be thrown from AthContainers.
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Interface for non-const operations on an auxiliary store.
Describes the possible index tracking policies.
static Double_t sz
static Double_t a
CxxUtils::span< container_value_type > span
CxxUtils::span< const container_value_type > const_span
Base class for elements of a container that can have aux data.
Definition AuxElement.h:484
Helper to factor out template-independent part of resortAux.
std::vector< SG::auxid_t > m_auxids
ResortAuxHelper(size_t sz, size_t index, AuxVectorBase &vec)
Set up for resorting.
void resortElement(size_t idx, SG::AuxElement *elt)
Manage index tracking and synchronization of auxiliary data.
const_span< T > getDataSpan(const std::string &name) const
Return a span over an aux data item.
AuxVectorBase()
Default constructor.
void moveAux(size_t index, SG::AuxElement *p, bool clear=false, bool skipDestClear=false)
Set index on an element and copy auxiliary data.
void clearIndex1(const std::true_type &, ForwardIterator elt)
Clear the container / index for element elt.
void initAuxVectorBase1(const std::false_type &, SG::OwnershipPolicy, SG::IndexTrackingPolicy)
Initialize index tracking mode — no-auxdata specialization.
static constexpr bool supportsThinning
Mark that this type supports thinning operations.
void swap(AuxVectorBase &other)
Swap with another container.
void clearIndices1(const std::true_type &, ForwardIterator beg, ForwardIterator end)
Clear the container / index for a range of elements.
void clearIndex(ForwardIterator elt)
Clear the container / index for element elt.
void setIndices1(const std::false_type &, ForwardIterator beg, ForwardIterator end, size_t first)
Set container/index for all elements within a range.
void * getDataArrayForResort(SG::auxid_t auxid)
bool isAvailableWritableAsDecoration(const std::string &name, const std::string &clsname="") const
Test to see if a variable is available for writing as a decoration.
void swapElementsAux(size_t aindex, size_t bindex, SG::AuxElement *a, SG::AuxElement *b, AuxVectorBase *bcont)
Swap indices and auxiliary data between two elements.
void setIndexForResort(SG::AuxElement *elt, size_t idx)
span< T > getDecorationSpan(const std::string &name) const
Return a span over an aux data item for a decoration.
void swapElementsAux(size_t aindex, size_t bindex, const void *a, const void *b, AuxVectorBase *bcont)
Swap indices and auxiliary data between two elements.
bool m_trackIndices
Flag if index tracking is enabled.
void setNonConstStore(SG::IAuxStore *store)
Synonym for setStore with IAuxStore.
void resize(size_t size)
Resize the aux data associated with this container.
void setStore(SG::IAuxStore *store)
Set the store associated with this object.
void moveAux1(const std::false_type &, size_t index, ForwardIterator beg, ForwardIterator end, bool clear=false, bool skipDestClear=false)
Set index on a range of elements and copy auxiliary data.
void resize1(const std::false_type &, size_t size)
Resize the aux data associated with this container.
void setIndices1(const std::true_type &, ForwardIterator beg, ForwardIterator end, size_t first)
Set container/index for all elements within a range.
void moveAuxNoClear(size_t, const void *)
Set index on an element and copy auxiliary data, specialized for the case of no clearing (and inlined...
void moveAux(size_t index, const void *p, bool clear=false, bool skipDestClear=false)
Set index on an element and copy auxiliary data.
void moveAux(size_t index, ForwardIterator beg, ForwardIterator end, bool clear=false, bool skipDestClear=false)
Set index on a range of elements and copy auxiliary data.
void resortAux1(const std::true_type &, size_t index, ForwardIterator a, ForwardIterator b)
Reset indices / reorder aux data after elements have been permuted.
span< T > getDataSpan(const std::string &name)
Return a span over an aux data item.
void shift1(const std::false_type &, DVL &cont, size_t pos, ptrdiff_t offs)
Shift the elements of the container.
void setConstStore(const SG::IConstAuxStore *store)
Synonym for setStore with IConstAuxStore.
virtual ~AuxVectorBase()
Destructor.
void reserve(size_t size)
Change the capacity of the aux data associated with this container.
void shift(DVL &cont, size_t pos, ptrdiff_t offs)
Shift the elements of the container.
void resortAux1(const std::false_type &, size_t index, ForwardIterator beg, ForwardIterator end)
Reset indices / reorder aux data after elements have been permuted.
void clearIndex1(const std::false_type &, ForwardIterator elt)
Clear the container / index for element elt.
bool isAvailable(const std::string &name, const std::string &clsname="") const
Test to see if a variable exists in the store.
AuxVectorBase & operator=(AuxVectorBase &&rhs)
Move assignment.
void shift1(const std::true_type &, DVL &cont, size_t pos, ptrdiff_t offs)
Shift the elements of the container.
typename AuxDataTraits< T >::span span
Spans over auxiliary variables.
typename AuxDataTraits< T >::const_span const_span
void moveAux1(const std::true_type &, size_t index, ForwardIterator beg, ForwardIterator end, bool clear=false, bool skipDestClear=false)
Set index on a range of elements and copy auxiliary data.
void reserve1(const std::false_type &, size_t size)
Change the capacity of the aux data associated with this container.
void clearIndices(ForwardIterator beg, ForwardIterator end)
Clear the container / index for a range of elements.
const_span< T > getConstDataSpan(const std::string &name) const
Return a span over an aux data item.
bool trackIndices() const
Return true if index tracking is enabled for this container.
bool isAvailableWritable(const std::string &name, const std::string &clsname="")
Test to see if a variable is available for writing.
void resortAux(size_t index, ForwardIterator beg, ForwardIterator end)
Reset indices / reorder aux data after elements have been permuted.
void setIndices(ForwardIterator beg, ForwardIterator end, size_t first=0)
Set container/index for all elements within a range.
void initAuxVectorBase(SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy indexTrackingPolicy)
Initialize index tracking mode.
void clearIndices1(const std::false_type &, ForwardIterator, ForwardIterator)
Clear the container / index for a range of elements.
void moveAuxNoClear(size_t index, SG::AuxElement *p)
Set index on an element and copy auxiliary data, specialized for the case of no clearing (and inlined...
bool isAvailableWritableAsDecoration(auxid_t id) const
Test to see if a variable is available for writing as a decoration.
bool isAvailable(auxid_t id) const
Test to see if a variable exists in the store.
AuxVectorData()
Constructor.
bool isAvailableWritable(auxid_t id)
Test to see if a variable is available for writing.
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
Interface for const operations on an auxiliary store.
Forward declaration.
OwnershipPolicy
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27
Definition index.py:1