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-2024 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 void moveAux (size_t index, const void* p, bool clear = false,
470 bool skipDestClear = false);
471
472
494 template <class ForwardIterator>
495 void moveAux (size_t index, ForwardIterator beg, ForwardIterator end,
496 bool clear = false,
497 bool skipDestClear = false);
498
499
513 void swapElementsAux (size_t aindex,
514 size_t bindex,
517 AuxVectorBase* bcont);
518
519
532 void swapElementsAux (size_t aindex,
533 size_t bindex,
534 const void* a,
535 const void* b,
536 AuxVectorBase* bcont);
537
538
553 template <class ForwardIterator>
554 void resortAux (size_t index,
555 ForwardIterator beg,
556 ForwardIterator end);
557
558
559private:
569 void initAuxVectorBase1 (const std::false_type&,
570 SG::OwnershipPolicy /*ownPolicy*/,
571 SG::IndexTrackingPolicy /*indexTrackingPolicy*/);
572
573
583 void initAuxVectorBase1 (const std::true_type&,
584 SG::OwnershipPolicy ownPolicy,
585 SG::IndexTrackingPolicy indexTrackingPolicy);
586
587
597 template <class ForwardIterator>
598 void setIndices1 (const std::false_type&,
599 ForwardIterator beg,
600 ForwardIterator end,
601 size_t first);
602
603
614 template <class ForwardIterator>
615 void setIndices1 (const std::true_type&,
616 ForwardIterator beg,
617 ForwardIterator end,
618 size_t first);
619
620
628 template <class ForwardIterator>
629 void clearIndex1 (const std::false_type&, ForwardIterator elt);
630
631
638 template <class ForwardIterator>
639 void clearIndex1 (const std::true_type&, ForwardIterator elt);
640
641
649 template <class ForwardIterator>
650 void clearIndices1 (const std::false_type&,
651 ForwardIterator,
652 ForwardIterator);
653
654
662 template <class ForwardIterator>
663 void clearIndices1 (const std::true_type&,
664 ForwardIterator beg,
665 ForwardIterator end);
666
667
668
675 void resize1 (const std::false_type&, size_t size);
676
677
684 void resize1 (const std::true_type&, size_t size);
685
686
693 void reserve1 (const std::false_type&, size_t size);
694
695
702 void reserve1 (const std::true_type&, size_t size);
703
704
713 template <class DVL>
714 void shift1 (const std::false_type&,
715 DVL& cont, size_t pos, ptrdiff_t offs);
716
717
745 template <class DVL>
746 void shift1 (const std::true_type&,
747 DVL& cont, size_t pos, ptrdiff_t offs);
748
749
765 template <class ForwardIterator>
766 void moveAux1 (const std::false_type&,
767 size_t index,
768 ForwardIterator beg,
769 ForwardIterator end,
770 bool clear = false,
771 bool skipDestClear = false);
772
773
794 template <class ForwardIterator>
795 void moveAux1 (const std::true_type&,
796 size_t index,
797 ForwardIterator beg,
798 ForwardIterator end,
799 bool clear = false,
800 bool skipDestClear = false);
801
802
811 template <class ForwardIterator>
812 void resortAux1 (const std::false_type&,
813 size_t index,
814 ForwardIterator beg,
815 ForwardIterator end);
816
817
831 template <class ForwardIterator>
832 void resortAux1 (const std::true_type&,
833 size_t index,
834 ForwardIterator a,
835 ForwardIterator b);
836
837
838private:
845 {
846 public:
847 ResortAuxHelper (size_t sz, size_t index, AuxVectorBase& vec);
848 void resortElement (size_t idx, SG::AuxElement* elt);
849
850 private:
852 size_t m_index;
853 std::vector<size_t> m_imap;
854 std::vector<size_t> m_rmap;
855 std::vector<void*> m_auxdata;
856 std::vector<SG::auxid_t> m_auxids;
857
859 };
861 void setIndexForResort (SG::AuxElement* elt, size_t idx);
862 friend class ResortAuxHelper;
863
864
867};
868
869
870} // namespace SG
871
872
873#ifndef XAOD_STANDALONE
875CLASS_DEF( SG::AuxVectorBase, 33347479, 1 )
876#endif
877
878
880
881
882#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:483
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 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.
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