ATLAS Offline Software
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 */
14 #ifndef ATHCONTAINERS_AUXVECTORBASE_H
15 #define ATHCONTAINERS_AUXVECTORBASE_H
16 
17 
28 #include <vector>
29 
30 
31 namespace SG {
32 
33 
97  : public AuxVectorData
98 {
99 public:
101  template <class T> using span = typename AuxDataTraits<T>::span;
102  template <class T> using const_span = typename AuxDataTraits<T>::const_span;
103 
104 
114  AuxVectorBase();
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 
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 
318 protected:
332  template <class DVL>
334  SG::IndexTrackingPolicy indexTrackingPolicy);
335 
336 
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,
515  SG::AuxElement* a,
516  SG::AuxElement* b,
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 
559 private:
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 
838 private:
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
874 #include "AthenaKernel/CLASS_DEF.h"
875 CLASS_DEF( SG::AuxVectorBase, 33347479, 1 )
876 #endif
877 
878 
880 
881 
882 #endif // not DATAMODEL_AUXVECTORBASE_H
SGTest::store
TestStore store
Definition: TestStore.cxx:23
SG::AuxVectorBase::shift1
void shift1(const std::false_type &, DVL &cont, size_t pos, ptrdiff_t offs)
Shift the elements of the container.
SG::AuxVectorBase::setIndices1
void setIndices1(const std::true_type &, ForwardIterator beg, ForwardIterator end, size_t first)
Set container/index for all elements within a range.
SG::AuxVectorBase::getConstDataSpan
const_span< T > getConstDataSpan(const std::string &name) const
Return a span over an aux data item.
SG::AuxVectorBase::initAuxVectorBase
void initAuxVectorBase(SG::OwnershipPolicy ownPolicy, SG::IndexTrackingPolicy indexTrackingPolicy)
Initialize index tracking mode.
fitman.sz
sz
Definition: fitman.py:527
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::AuxVectorBase::resortAux
void resortAux(size_t index, ForwardIterator beg, ForwardIterator end)
Reset indices / reorder aux data after elements have been permuted.
SG::AuxVectorBase::ResortAuxHelper::m_imap
std::vector< size_t > m_imap
Definition: AuxVectorBase.h:853
SG::AuxVectorBase::clearIndex1
void clearIndex1(const std::false_type &, ForwardIterator elt)
Clear the container / index for element elt.
SG::AuxVectorBase::ResortAuxHelper::m_auxids
std::vector< SG::auxid_t > m_auxids
Definition: AuxVectorBase.h:856
IndexTrackingPolicy.h
Describes the possible index tracking policies.
index
Definition: index.py:1
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
SG::AuxVectorBase::ResortAuxHelper::m_vec
AuxVectorBase & m_vec
Definition: AuxVectorBase.h:851
SG::AuxVectorBase::ResortAuxHelper::m_index
size_t m_index
Definition: AuxVectorBase.h:852
SG::AuxVectorBase::ResortAuxHelper::m_auxdata
std::vector< void * > m_auxdata
Definition: AuxVectorBase.h:855
SG::AuxVectorBase::const_span
typename AuxDataTraits< T >::const_span const_span
Definition: AuxVectorBase.h:102
exceptions.h
Exceptions that can be thrown from AthContainers.
SG::AuxVectorBase::setStore
void setStore(SG::IAuxStore *store)
Set the store associated with this object.
Definition: AuxVectorBase.cxx:96
SG::AuxVectorBase::setIndexForResort
void setIndexForResort(SG::AuxElement *elt, size_t idx)
ATHCONTAINERS_ASSERT.h
An overridable variant of assert.
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
SG::AuxVectorBase::getDataSpan
span< T > getDataSpan(const std::string &name)
Return a span over an aux data item.
SG::AuxVectorBase::moveAux
void moveAux(size_t index, const void *p, bool clear=false, bool skipDestClear=false)
Set index on an element and copy auxiliary data.
SG::AuxVectorBase::ResortAuxHelper::ResortAuxHelper
ResortAuxHelper()
SG::AuxVectorBase::ResortAuxHelper::m_rmap
std::vector< size_t > m_rmap
Definition: AuxVectorBase.h:854
SG::AuxVectorData::isAvailableWritable
bool isAvailableWritable(auxid_t id)
Test to see if a variable is available for writing.
SG::AuxVectorBase::~AuxVectorBase
virtual ~AuxVectorBase()
Destructor.
Definition: AuxVectorBase.cxx:63
SG::AuxVectorBase::moveAux1
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.
SG::AuxVectorBase
Manage index tracking and synchronization of auxiliary data.
Definition: AuxVectorBase.h:98
CxxUtils::span
Simplified version of the C++20 std::span.
Definition: span.h:67
SG::AuxVectorBase::resortAux1
void resortAux1(const std::false_type &, size_t index, ForwardIterator beg, ForwardIterator end)
Reset indices / reorder aux data after elements have been permuted.
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
SG::AuxVectorBase::clearIndices1
void clearIndices1(const std::false_type &, ForwardIterator, ForwardIterator)
Clear the container / index for a range of elements.
SG::AuxVectorBase::supportsThinning
static constexpr bool supportsThinning
Mark that this type supports thinning operations.
Definition: AuxVectorBase.h:315
SG::AuxVectorData::isAvailable
bool isAvailable(auxid_t id) const
Test to see if a variable exists in the store.
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
SG::AuxVectorBase::setNonConstStore
void setNonConstStore(SG::IAuxStore *store)
Synonym for setStore with IAuxStore.
SG::AuxVectorBase::swapElementsAux
void swapElementsAux(size_t aindex, size_t bindex, SG::AuxElement *a, SG::AuxElement *b, AuxVectorBase *bcont)
Swap indices and auxiliary data between two elements.
Definition: AuxVectorBase.cxx:257
SG::AuxVectorBase::operator=
AuxVectorBase & operator=(AuxVectorBase &&rhs)
Move assignment.
Definition: AuxVectorBase.cxx:50
SG::AuxVectorBase::resize
void resize(size_t size)
Resize the aux data associated with this container.
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::AuxVectorBase::clearIndex
void clearIndex(ForwardIterator elt)
Clear the container / index for element elt.
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxVectorBase::getDataSpan
const_span< T > getDataSpan(const std::string &name) const
Return a span over an aux data item.
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::AuxVectorBase::resortAux1
void resortAux1(const std::true_type &, size_t index, ForwardIterator a, ForwardIterator b)
Reset indices / reorder aux data after elements have been permuted.
SG::AuxVectorBase::getDecorationSpan
span< T > getDecorationSpan(const std::string &name) const
Return a span over an aux data item for a decoration.
SG::AuxVectorBase::getDataArrayForResort
void * getDataArrayForResort(SG::auxid_t auxid)
SG::AuxVectorBase::reserve
void reserve(size_t size)
Change the capacity of the aux data associated with this container.
AuxDataTraits.h
Allow customizing how aux data types are treated.
OwnershipPolicy.h
SG::AuxVectorBase::reserve1
void reserve1(const std::false_type &, size_t size)
Change the capacity of the aux data associated with this container.
AuxVectorData.h
Manage lookup of vectors of auxiliary data.
SG::AuxVectorBase::resize1
void resize1(const std::false_type &, size_t size)
Resize the aux data associated with this container.
SG::AuxVectorBase::moveAux
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.
SG::AuxVectorBase::setIndices
void setIndices(ForwardIterator beg, ForwardIterator end, size_t first=0)
Set container/index for all elements within a range.
SG::AuxVectorBase::m_trackIndices
bool m_trackIndices
Flag if index tracking is enabled.
Definition: AuxVectorBase.h:866
SG::AuxVectorBase::initAuxVectorBase1
void initAuxVectorBase1(const std::false_type &, SG::OwnershipPolicy, SG::IndexTrackingPolicy)
Initialize index tracking mode — no-auxdata specialization.
Definition: AuxVectorBase.cxx:132
SG::AuxVectorBase::isAvailableWritable
bool isAvailableWritable(const std::string &name, const std::string &clsname="")
Test to see if a variable is available for writing.
WriteBchToCool.beg
beg
Definition: WriteBchToCool.py:69
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SG::AuxVectorBase::moveAux1
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.
SG::AuxVectorBase::ResortAuxHelper::resortElement
void resortElement(size_t idx, SG::AuxElement *elt)
Definition: AuxVectorBase.cxx:340
AuxStore_traits.h
Associate AuxStore classes with EDM container classes.
SG::AuxVectorBase::moveAux
void moveAux(size_t index, SG::AuxElement *p, bool clear=false, bool skipDestClear=false)
Set index on an element and copy auxiliary data.
Definition: AuxVectorBase.cxx:223
SG::AuxVectorBase::ResortAuxHelper
Helper to factor out template-independent part of resortAux.
Definition: AuxVectorBase.h:845
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::AuxVectorBase::isAvailable
bool isAvailable(const std::string &name, const std::string &clsname="") const
Test to see if a variable exists in the store.
SG::AuxVectorBase::clearIndices1
void clearIndices1(const std::true_type &, ForwardIterator beg, ForwardIterator end)
Clear the container / index for a range of elements.
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::AuxVectorBase::setIndices1
void setIndices1(const std::false_type &, ForwardIterator beg, ForwardIterator end, size_t first)
Set container/index for all elements within a range.
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::AuxVectorBase::clearIndex1
void clearIndex1(const std::true_type &, ForwardIterator elt)
Clear the container / index for element elt.
VKalVrtAthena::varHolder_detail::clear
void clear(T &var)
Definition: NtupleVars.h:48
SG::AuxVectorBase::AuxVectorBase
AuxVectorBase()
Default constructor.
Definition: AuxVectorBase.cxx:29
SG::AuxVectorBase::shift1
void shift1(const std::true_type &, DVL &cont, size_t pos, ptrdiff_t offs)
Shift the elements of the container.
SG::AuxVectorBase::setConstStore
void setConstStore(const SG::IConstAuxStore *store)
Synonym for setStore with IConstAuxStore.
SG::AuxVectorBase::span
typename AuxDataTraits< T >::span span
Spans over auxiliary variables.
Definition: AuxVectorBase.h:101
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
DeMoScan.first
bool first
Definition: DeMoScan.py:536
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
IAuxStore.h
Interface for non-const operations on an auxiliary store.
SG::AuxVectorBase::clearIndices
void clearIndices(ForwardIterator beg, ForwardIterator end)
Clear the container / index for a range of elements.
SG::AuxVectorBase::swap
void swap(AuxVectorBase &other)
Swap with another container.
AuxVectorBase.icc
SG::AuxVectorData::isAvailableWritableAsDecoration
bool isAvailableWritableAsDecoration(auxid_t id) const
Test to see if a variable is available for writing as a decoration.
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
SG::AuxVectorBase::trackIndices
bool trackIndices() const
Return true if index tracking is enabled for this container.
SG::AuxVectorBase::shift
void shift(DVL &cont, size_t pos, ptrdiff_t offs)
Shift the elements of the container.
SG::AuxVectorBase::swapElementsAux
void swapElementsAux(size_t aindex, size_t bindex, const void *a, const void *b, AuxVectorBase *bcont)
Swap indices and auxiliary data between two elements.
CLASS_DEF.h
macros to associate a CLID to a type
SG::IndexTrackingPolicy
IndexTrackingPolicy
Definition: IndexTrackingPolicy.h:37
AuxElement.h
Base class for elements of a container that can have aux data.
SG::AuxVectorBase::isAvailableWritableAsDecoration
bool isAvailableWritableAsDecoration(const std::string &name, const std::string &clsname="") const
Test to see if a variable is available for writing as a decoration.