ATLAS Offline Software
AuxElement.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 */
13 #ifndef ATHCONTAINERS_AUXELEMENTBASE_H
14 #define ATHCONTAINERS_AUXELEMENTBASE_H
15 
16 
20 #include "AthLinks/DataLink.h"
26 #include "AthContainers/Accessor.h"
30 #include "CxxUtils/span.h"
31 #include <cstddef>
32 
33 
34 // In non-analysis builds, warn about uses of auxdata/auxdecor.
35 // @c XAOD_DEPRECATE_AUXDATA may be set directly to override this; for example,
36 // in unit tests.
37 #ifndef XAOD_DEPRECATE_AUXDATA
38 # if defined(XAOD_ANALYSIS)
39 # define XAOD_DEPRECATE_AUXDATA 0
40 # else
41 # define XAOD_DEPRECATE_AUXDATA 1
42 # endif
43 #endif
44 #if XAOD_DEPRECATE_AUXDATA
45 # define XAOD_AUXDATA_DEPRECATED [[deprecated("auxdata/auxdecor are deprecated in non-analysis builds. Use SG::ConstAccessor/SG::Accessor/SG::Decorator instead.")]]
46 #else
47 # define XAOD_AUXDATA_DEPRECATED
48 #endif
49 
50 
51 
52 namespace SG {
53 
54 
55 class AuxElement;
56 class AuxElementData;
57 class AuxElementStandaloneData;
58 class AuxVectorData_test;
59 class AuxVectorBase;
60 class AuxVectorBase_test;
61 
62 
70  : public SG::IAuxElement
71 {
72 public:
75 
76 
85 
86 
98 
99 
102 
103 
110 
111 
115  const SG::AuxVectorData* container() const;
116 
117 
123  using IAuxElement::index;
124 
125 
128 
130  template <class T, class ALLOC = AuxAllocator_t<T> >
132 
134  template <class T, class ALLOC = AuxAllocator_t<T> >
136 
137 
147  template <class T, class ALLOC = AuxAllocator_t<T> >
150  auxdata (const std::string& name) const;
151 
152 
163  template <class T, class ALLOC = AuxAllocator_t<T> >
166  auxdata (const std::string& name,
167  const std::string& clsname) const;
168 
169 
178  template <class T, class ALLOC = AuxAllocator_t<T> >
181  auxdataConst (const std::string& name) const;
182 
183 
193  template <class T, class ALLOC = AuxAllocator_t<T> >
196  auxdataConst (const std::string& name,
197  const std::string& clsname) const;
198 
199 
209  template <class T, class ALLOC = AuxAllocator_t<T> >
211  bool isAvailable (const std::string& name,
212  const std::string& clsname = "") const;
213 
214 
224  template <class T, class ALLOC = AuxAllocator_t<T> >
226  bool isAvailableWritableAsDecoration (const std::string& name,
227  const std::string& clsname = "") const;
228 
229 
242  template <class T, class ALLOC = AuxAllocator_t<T> >
245  auxdecor (const std::string& name) const;
246 
247 
261  template <class T, class ALLOC = AuxAllocator_t<T> >
264  auxdecor (const std::string& name,
265  const std::string& clsname) const;
266 
267 
277  const SG::auxid_set_t& getAuxIDs() const;
278 
279 
288  const SG::auxid_set_t& getDecorIDs() const;
289 
290 
291 private:
292  friend class AuxElement;
293  friend class SG::AuxVectorBase;
294 
295 
302 
303 
317  void setIndex (size_t index, const SG::AuxVectorData* container);
318 
319 
329  bool setIndexPrivate (size_t index, const SG::AuxVectorData* container);
330 
331 
336 };
337 
338 
339 //***************************************************************************
340 
341 
479  : public SG::IAuxElement
480 #else
481  : public ConstAuxElement
482 #endif
483 {
484 public:
487 
488 
497 
498 
499 
511 
512 
523 
524 
535  void assign (const AuxElement& other, bool warnUnlocked = false);
536 
537 
544 
545 
549  const SG::AuxVectorData* container() const;
550 
551 
556 
557 
563  using IAuxElement::index;
564 
565 
567 
568  template <class T, class ALLOC = AuxAllocator_t<T> >
570 
571  template <class T, class ALLOC = AuxAllocator_t<T> >
573 
574  template <class T, class ALLOC = AuxAllocator_t<T> >
576 
577 
586  template <class T, class ALLOC = AuxAllocator_t<T> >
589  auxdata (const std::string& name);
590 
591 
601  template <class T, class ALLOC = AuxAllocator_t<T> >
604  auxdata (const std::string& name,
605  const std::string& clsname);
606 
607 
617  template <class T, class ALLOC = AuxAllocator_t<T> >
620  auxdata (const std::string& name) const;
621 
622 
633  template <class T, class ALLOC = AuxAllocator_t<T> >
636  auxdata (const std::string& name,
637  const std::string& clsname) const;
638 
639 
648  template <class T, class ALLOC = AuxAllocator_t<T> >
651  auxdataConst (const std::string& name) const;
652 
653 
663  template <class T, class ALLOC = AuxAllocator_t<T> >
666  auxdataConst (const std::string& name,
667  const std::string& clsname) const;
668 
669 
679  template <class T, class ALLOC = AuxAllocator_t<T> >
681  bool isAvailable (const std::string& name,
682  const std::string& clsname = "") const;
683 
684 
694  template <class T, class ALLOC = AuxAllocator_t<T> >
696  bool isAvailableWritable (const std::string& name,
697  const std::string& clsname = "");
698 
699 
709  template <class T, class ALLOC = AuxAllocator_t<T> >
711  bool isAvailableWritableAsDecoration (const std::string& name,
712  const std::string& clsname = "") const;
713 
714 
727  template <class T, class ALLOC = AuxAllocator_t<T> >
730  auxdecor (const std::string& name) const;
731 
732 
746  template <class T, class ALLOC = AuxAllocator_t<T> >
749  auxdecor (const std::string& name,
750  const std::string& clsname) const;
751 
752 
759  void makePrivateStore();
760 
761 
773  template <class U1>
774  void makePrivateStore (const U1& other,
775  bool warnUnlocked = false);
776 
777 
789  template <class U1>
790  void makePrivateStore (const U1* other,
791  bool warnUnlocked = false);
792 
793 
800  void releasePrivateStore();
801 
802 
811  void setStore (const SG::IConstAuxStore* store);
812 
813 
822  void setStore (SG::IAuxStore* store);
823 
824 
834 
835 
841 
842 
848 
849 
853  bool usingPrivateStore() const;
854 
855 
859  bool usingStandaloneStore() const;
860 
861 
869  const SG::IConstAuxStore* getConstStore() const;
870 
871 
878  SG::IAuxStore* getStore() const;
879 
880 
887  void clearCache();
888 
889 
899  const SG::auxid_set_t& getAuxIDs() const;
900 
901 
910  const SG::auxid_set_t& getDecorIDs() const;
911 
912 
918  bool hasStore() const;
919 
920 
926  bool hasNonConstStore() const;
927 
928 
938  bool clearDecorations() const;
939 
940 
947  bool trackIndices() const;
948 
949 
959  static constexpr bool supportsThinning = true;
960 
961 
962 private:
963  friend class SG::ConstAuxElement;
964  friend class SG::AuxVectorBase;
966 
967 
974 
975 
990 
991 
1002 
1003 
1014  void makePrivateStore1 (const void* other, bool warnUnlocked);
1015 
1016 
1027  void makePrivateStore1 (const AuxElement* other,
1028  bool warnUnlocked);
1029 
1030 
1039 
1040 
1047  void clearAux();
1048 
1049 
1063  void copyAux (const ConstAuxElement& other,
1064  bool warnUnlocked = false);
1065 
1066 
1067 #ifdef ATHCONTAINERS_R21_COMPAT
1068 
1081  void copyAux (const AuxElement& other,
1082  bool warnUnlocked = false);
1083 
1084 
1089 #endif
1090 };
1091 
1092 
1093 } // namespace SG
1094 
1095 
1097 
1098 
1099 #ifndef XAOD_STANDALONE
1100 CLASS_DEF (SG::AuxElement, 225182422, 1)
1101 #endif // not XAOD_STANDALONE
1102 
1103 
1104 #endif // not ATHCONTAINERS_AUXELEMENTBASE_H
SG::AuxElement::trackIndices
bool trackIndices() const
Return true if index tracking is enabled for this object.
SG::AuxElement::setConstStore
void setConstStore(const SG::IConstAuxStore *store)
Synonym for setStore with IConstAuxStore.
SGTest::store
TestStore store
Definition: TestStore.cxx:23
SG::ConstAuxElement::getAuxIDs
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.
Definition: AuxElement.cxx:153
SG::AuxElement::auxdecor
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
IAuxElement.h
Flag that a class may have auxiliary data associated with it.
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
SG::ConstAuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
index
Definition: index.py:1
SG::ConstAuxElement::auxdata
XAOD_AUXDATA_DEPRECATED ConstAccessor< T, ALLOC >::const_reference_type auxdata(const std::string &name, const std::string &clsname) const
Fetch an aux data variable, as a const reference.
SG::AuxElement
Base class for elements of a container that can have aux data.
Definition: AuxElement.h:483
SG::AuxElement::makePrivateStore
void makePrivateStore(const U1 &other, bool warnUnlocked=false)
Create a new private store for this object and copy aux data.
SG::ConstAuxElement::m_container
const SG::AuxVectorData * m_container
The container of which this object is an element.
Definition: AuxElement.h:335
SG::ConstAuxElement::isAvailable
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
exceptions.h
Exceptions that can be thrown from AthContainers.
SG::ConstAuxElement::auxdataConst
XAOD_AUXDATA_DEPRECATED ConstAccessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name) const
Fetch an aux data variable, as a const reference.
SG::AuxElement::hasNonConstStore
bool hasNonConstStore() const
Return true if this object has an associated non-const store.
Definition: AuxElement.cxx:411
SG::TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition: TypelessConstAccessor.h:44
SG::AuxElement::assign
void assign(const AuxElement &other, bool warnUnlocked=false)
Assignment.
SG::AuxElement::usingStandaloneStore
bool usingStandaloneStore() const
Test to see if this object is currently using a standalone store.
Definition: AuxElement.cxx:290
SG::ConstAuxElement::setIndexPrivate
bool setIndexPrivate(size_t index, const SG::AuxVectorData *container)
Set the index/container for this element.
Definition: AuxElement.cxx:97
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition: ConstAccessor.h:55
likely.h
Define likely/unlikely macros for branch prediction.
SG::AuxElement::auxdata
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::reference_type auxdata(const std::string &name)
Fetch an aux data variable, as a non-const reference.
SG::ConstAuxElement::ConstAuxElement
ConstAuxElement()
Default constructor.
SG::ConstAuxElement::auxdata
XAOD_AUXDATA_DEPRECATED ConstAccessor< T, ALLOC >::const_reference_type auxdata(const std::string &name) const
Fetch an aux data variable, as a const reference.
SG::AuxElement::isAvailable
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
SG::AuxVectorBase
Manage index tracking and synchronization of auxiliary data.
Definition: AuxVectorBase.h:98
SG::AuxElement::getStore
SG::IAuxStore * getStore() const
Return the current store, as a non-const interface.
Definition: AuxElement.cxx:319
SG::IAuxElement
Flag that a class may have auxiliary data associated with it.
Definition: IAuxElement.h:51
SG::ConstAuxElement::isAvailableWritableAsDecoration
XAOD_AUXDATA_DEPRECATED bool isAvailableWritableAsDecoration(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for writing as a decoration.
SG::ConstAccessor::const_reference_type
typename AuxDataTraits< T, ALLOC >::const_reference_type const_reference_type
Type referencing an item.
Definition: ConstAccessor.h:62
SG::IAuxElement::index
size_t index() const
Return the index of this element within its container.
SG::AuxElement::setIndex
void setIndex(size_t index, SG::AuxVectorData *container)
Set the index/container for this element.
SG::AuxElement::auxdataConst
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name, const std::string &clsname) const
Fetch an aux data variable, as a const reference.
SG::ConstAuxElement::auxdataConst
XAOD_AUXDATA_DEPRECATED ConstAccessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name, const std::string &clsname) const
Fetch an aux data variable, as a const reference.
SG::AuxElement::releasePrivateStoreForDtor
void releasePrivateStoreForDtor()
Out-of-line portion of destructor.
Definition: AuxElement.cxx:441
SG::AuxElement::AuxElement
AuxElement(const AuxElement &other)
Copy Constructor.
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
SG::AuxElement::setStore
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
Definition: AuxElement.cxx:241
span.h
Simplified version of the C++20 std::span.
SG::AuxElement::copyAux
void copyAux(const ConstAuxElement &other, bool warnUnlocked=false)
Copy aux data from another object.
Definition: AuxElement.cxx:607
SG::AuxElement::clearAux
void clearAux()
Clear all aux data associated with this element.
Definition: AuxElement.cxx:580
SG::AuxElement::AuxElement
AuxElement()
Default constructor.
SG::AuxElement::usingPrivateStore
bool usingPrivateStore() const
Test to see if this object is currently using a private store.
Definition: AuxElement.cxx:280
SG::Accessor::reference_type
typename AuxDataTraits< T, ALLOC >::reference_type reference_type
Type referencing an item.
Definition: Control/AthContainers/AthContainers/Accessor.h:71
SG::AuxElement::setIndexPrivate
bool setIndexPrivate(size_t index, SG::AuxVectorData *container)
Set the index/container for this element.
Definition: AuxElement.cxx:505
SG::ConstAuxElement::getDecorIDs
const SG::auxid_set_t & getDecorIDs() const
Return a set of identifiers for decorations for this object.
Definition: AuxElement.cxx:172
SG::AuxElement::releasePrivateStore
void releasePrivateStore()
Release and free any private store associated with this object.
Definition: AuxElement.cxx:210
AuxDataTraits.h
Allow customizing how aux data types are treated.
SG::AuxElement::AuxVectorBase_test
friend class SG::AuxVectorBase_test
Definition: AuxElement.h:965
XAOD_AUXDATA_DEPRECATED
#define XAOD_AUXDATA_DEPRECATED
Definition: AuxElement.h:45
SG::AuxElement::makePrivateStore
void makePrivateStore(const U1 *other, bool warnUnlocked=false)
Create a new private store for this object and copy aux data.
SG::ConstAuxElement::TypelessConstAccessor
SG::TypelessConstAccessor TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition: AuxElement.h:127
SG::AuxElement::clearDecorations
bool clearDecorations() const
Clear all decorations.
Definition: AuxElement.cxx:428
SG::AuxElement::getAuxIDs
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.
Definition: AuxElement.cxx:355
SG::ConstAuxElement::~ConstAuxElement
~ConstAuxElement()
Destructor.
AuxVectorData.h
Manage lookup of vectors of auxiliary data.
SG::ConstAuxElement
Const part of AuxElement.
Definition: AuxElement.h:71
SG::AuxElement::isAvailableWritableAsDecoration
XAOD_AUXDATA_DEPRECATED bool isAvailableWritableAsDecoration(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for writing as a decoration.
SG::AuxElement::clearCache
void clearCache()
Clear the cached aux data pointers.
Definition: AuxElement.cxx:339
SG::AuxElement::auxdecor
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name, const std::string &clsname) const
Fetch an aux decoration, as a non-const reference.
SG::AuxElement::auxdata
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdata(const std::string &name, const std::string &clsname) const
Fetch an aux data variable, as a const reference.
SG::Decorator::reference_type
typename AuxDataTraits< T, ALLOC >::reference_type reference_type
Type referencing an item.
Definition: Decorator.h:62
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TypelessConstAccessor.h
Helper class to provide const generic access to aux data.
Accessor.h
Helper class to provide type-safe access to aux data.
SG::ConstAuxElement::auxdecor
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
SG::AuxElement::makePrivateStore1
void makePrivateStore1(const void *other, bool warnUnlocked)
Create a new private store for this object and copy aux data.
SG::AuxElementStandaloneData
Internal data container for standalone store.
Definition: AuxElement.cxx:66
SG::AuxElement::operator=
AuxElement & operator=(const AuxElement &other)
Assignment.
SG::AuxElement::getConstStore
const SG::IConstAuxStore * getConstStore() const
Return the current store, as a const interface.
Definition: AuxElement.cxx:304
ATHCONTAINERS_R21_COMPAT
#define ATHCONTAINERS_R21_COMPAT
Definition: IAuxElement.h:23
SG::AuxElement::isAvailableWritable
XAOD_AUXDATA_DEPRECATED bool isAvailableWritable(const std::string &name, const std::string &clsname="")
Check if an aux variable is available for writing.
SG::ConstAuxElement::operator=
ConstAuxElement & operator=(const ConstAuxElement &other)=delete
No assignment to a const element.
SG::IAuxStore
Interface for non-const operations on an auxiliary store.
Definition: IAuxStore.h:48
SG::AuxElement::getDecorIDs
const SG::auxid_set_t & getDecorIDs() const
Return a set of identifiers for decorations for this object.
Definition: AuxElement.cxx:378
SG::AuxElement::hasStore
bool hasStore() const
Return true if this object has an associated store.
Definition: AuxElement.cxx:398
AuxElement.icc
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
SG::AuxElement::container
SG::AuxVectorData * container()
Return the container holding this element.
SG::AuxElement::setNonConstStore
void setNonConstStore(SG::IAuxStore *store)
Synonym for setStore with IAuxStore.
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:67
SG::ConstAuxElement::ConstAuxElement
ConstAuxElement(const SG::AuxVectorData *container, size_t index)
Constructor with explicit container / index.
SG::AuxElement::supportsThinning
static constexpr bool supportsThinning
Mark that this type supports thinning operations.
Definition: AuxElement.h:959
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
IAuxStore.h
Interface for non-const operations on an auxiliary store.
SG::AuxElement::auxdataConst
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name) const
Fetch an aux data variable, as a const reference.
SG::auxid_set_t
A set of aux data identifiers.
Definition: AuxTypes.h:47
SG::AuxElement::~AuxElement
~AuxElement()
Destructor.
SG::AuxVectorData
Manage lookup of vectors of auxiliary data.
Definition: AuxVectorData.h:168
SG::ConstAuxElement::releasePrivateStoreForDtor
void releasePrivateStoreForDtor()
Out-of-line portion of destructor.
Definition: AuxElement.cxx:80
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
SG::ConstAuxElement::ConstAuxElement
ConstAuxElement(const ConstAuxElement &other)
Copy Constructor.
IConstAuxStore.h
Interface for const operations on an auxiliary store.
SG::AuxElement::AuxElement
AuxElement(SG::AuxVectorData *container, size_t index)
Constructor with explicit container / index.
SG::IConstAuxStore
Interface for const operations on an auxiliary store.
Definition: IConstAuxStore.h:64
SG::ConstAuxElement::setIndex
void setIndex(size_t index, const SG::AuxVectorData *container)
Set the index/container for this element.
Decorator.h
Helper class to provide type-safe access to aux data.
SG::AuxElement::setStore1
AuxElementStandaloneData * setStore1(const SG::IConstAuxStore *store)
Set the store associated with this object.
Definition: AuxElement.cxx:461
SG::ConstAuxElement::auxdecor
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name, const std::string &clsname) const
Fetch an aux decoration, as a non-const reference.
SG::AuxElement::auxdata
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::reference_type auxdata(const std::string &name, const std::string &clsname)
Fetch an aux data variable, as a non-const reference.
SG::AuxElement::auxdata
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdata(const std::string &name) const
Fetch an aux data variable, as a const reference.