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 
280 private:
281  friend class AuxElement;
282  friend class SG::AuxVectorBase;
283 
284 
291 
292 
306  void setIndex (size_t index, const SG::AuxVectorData* container);
307 
308 
318  bool setIndexPrivate (size_t index, const SG::AuxVectorData* container);
319 
320 
325 };
326 
327 
328 //***************************************************************************
329 
330 
468  : public SG::IAuxElement
469 #else
470  : public ConstAuxElement
471 #endif
472 {
473 public:
476 
477 
486 
487 
488 
500 
501 
512 
513 
520 
521 
525  const SG::AuxVectorData* container() const;
526 
527 
532 
533 
539  using IAuxElement::index;
540 
541 
543 
544  template <class T, class ALLOC = AuxAllocator_t<T> >
546 
547  template <class T, class ALLOC = AuxAllocator_t<T> >
549 
550  template <class T, class ALLOC = AuxAllocator_t<T> >
552 
553 
562  template <class T, class ALLOC = AuxAllocator_t<T> >
565  auxdata (const std::string& name);
566 
567 
577  template <class T, class ALLOC = AuxAllocator_t<T> >
580  auxdata (const std::string& name,
581  const std::string& clsname);
582 
583 
593  template <class T, class ALLOC = AuxAllocator_t<T> >
596  auxdata (const std::string& name) const;
597 
598 
609  template <class T, class ALLOC = AuxAllocator_t<T> >
612  auxdata (const std::string& name,
613  const std::string& clsname) const;
614 
615 
624  template <class T, class ALLOC = AuxAllocator_t<T> >
627  auxdataConst (const std::string& name) const;
628 
629 
639  template <class T, class ALLOC = AuxAllocator_t<T> >
642  auxdataConst (const std::string& name,
643  const std::string& clsname) const;
644 
645 
655  template <class T, class ALLOC = AuxAllocator_t<T> >
657  bool isAvailable (const std::string& name,
658  const std::string& clsname = "") const;
659 
660 
670  template <class T, class ALLOC = AuxAllocator_t<T> >
672  bool isAvailableWritable (const std::string& name,
673  const std::string& clsname = "");
674 
675 
685  template <class T, class ALLOC = AuxAllocator_t<T> >
687  bool isAvailableWritableAsDecoration (const std::string& name,
688  const std::string& clsname = "") const;
689 
690 
703  template <class T, class ALLOC = AuxAllocator_t<T> >
706  auxdecor (const std::string& name) const;
707 
708 
722  template <class T, class ALLOC = AuxAllocator_t<T> >
725  auxdecor (const std::string& name,
726  const std::string& clsname) const;
727 
728 
735  void makePrivateStore();
736 
737 
748  template <class U1>
749  void makePrivateStore (const U1& other);
750 
751 
762  template <class U1>
763  void makePrivateStore (const U1* other);
764 
765 
772  void releasePrivateStore();
773 
774 
783  void setStore (const SG::IConstAuxStore* store);
784 
785 
794  void setStore (SG::IAuxStore* store);
795 
796 
806 
807 
813 
814 
820 
821 
825  bool usingPrivateStore() const;
826 
827 
831  bool usingStandaloneStore() const;
832 
833 
841  const SG::IConstAuxStore* getConstStore() const;
842 
843 
850  SG::IAuxStore* getStore() const;
851 
852 
859  void clearCache();
860 
861 
871  const SG::auxid_set_t& getAuxIDs() const;
872 
873 
879  bool hasStore() const;
880 
881 
887  bool hasNonConstStore() const;
888 
889 
899  bool clearDecorations() const;
900 
901 
908  bool trackIndices() const;
909 
910 
920  static constexpr bool supportsThinning = true;
921 
922 
923 private:
924  friend class SG::ConstAuxElement;
925  friend class SG::AuxVectorBase;
927 
928 
935 
936 
951 
952 
963 
964 
974  void makePrivateStore1 (const void*);
975 
976 
986  void makePrivateStore1 (const AuxElement* other);
987 
988 
997 
998 
1005  void clearAux();
1006 
1007 
1020  void copyAux (const ConstAuxElement& other);
1021 
1022 
1023 #ifdef ATHCONTAINERS_R21_COMPAT
1024 
1036  void copyAux (const AuxElement& other);
1037 
1038 
1043 #endif
1044 };
1045 
1046 
1047 } // namespace SG
1048 
1049 
1051 
1052 
1053 #ifndef XAOD_STANDALONE
1054 CLASS_DEF (SG::AuxElement, 225182422, 1)
1055 #endif // not XAOD_STANDALONE
1056 
1057 
1058 #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.
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:71
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:152
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:472
SG::AuxElement::copyAux
void copyAux(const ConstAuxElement &other)
Copy aux data from another object.
Definition: AuxElement.cxx:561
SG::ConstAuxElement::m_container
const SG::AuxVectorData * m_container
The container of which this object is an element.
Definition: AuxElement.h:324
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:368
SG::TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition: TypelessConstAccessor.h:44
SG::AuxElement::usingStandaloneStore
bool usingStandaloneStore() const
Test to see if this object is currently using a standalone store.
Definition: AuxElement.cxx:270
SG::ConstAuxElement::setIndexPrivate
bool setIndexPrivate(size_t index, const SG::AuxVectorData *container)
Set the index/container for this element.
Definition: AuxElement.cxx:96
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:299
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:398
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:221
span.h
Simplified version of the C++20 std::span.
SG::AuxElement::clearAux
void clearAux()
Clear all aux data associated with this element.
Definition: AuxElement.cxx:535
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:260
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:462
SG::AuxElement::makePrivateStore
void makePrivateStore(const U1 &other)
Create a new private store for this object and copy aux data.
SG::AuxElement::makePrivateStore1
void makePrivateStore1(const void *)
Create a new private store for this object and copy aux data.
SG::AuxElement::releasePrivateStore
void releasePrivateStore()
Release and free any private store associated with this object.
Definition: AuxElement.cxx:190
AuxDataTraits.h
Allow customizing how aux data types are treated.
SG::AuxElement::AuxVectorBase_test
friend class SG::AuxVectorBase_test
Definition: AuxElement.h:926
XAOD_AUXDATA_DEPRECATED
#define XAOD_AUXDATA_DEPRECATED
Definition: AuxElement.h:45
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:385
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:335
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::makePrivateStore
void makePrivateStore(const U1 *other)
Create a new private store for this object and copy aux data.
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:319
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:221
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:172
SG::AuxElementStandaloneData
Internal data container for standalone store.
Definition: AuxElement.cxx:65
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:284
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::hasStore
bool hasStore() const
Return true if this object has an associated store.
Definition: AuxElement.cxx:355
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:64
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:920
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:79
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:418
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.