ATLAS Offline Software
Loading...
Searching...
No Matches
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-2026 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef ATHCONTAINERS_AUXELEMENTBASE_H
14#define ATHCONTAINERS_AUXELEMENTBASE_H
15
16
20#include "AthLinks/DataLink.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
52namespace SG {
53
54
55class AuxElement;
56class AuxElementData;
57class AuxElementStandaloneData;
58class AuxVectorData_test;
59class AuxVectorBase;
60class AuxVectorBase_test;
61
62
70 : public SG::IAuxElement
71{
72public:
75
76
85
86
98
99
102
103
110
111
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
291private:
292 friend class AuxElement;
293 friend class SG::AuxVectorBase;
294
295
302
303
318
319
329 bool setIndexPrivate (size_t index, const SG::AuxVectorData* container);
330
331
336};
337
338
339//***************************************************************************
340
341
477//coverity[MISSING_MOVE_ASSIGNMENT]
480 : public SG::IAuxElement
481#else
482 : public ConstAuxElement
483#endif
484{
485public:
488
489
498
499
500
511 AuxElement (const AuxElement& other);
512
513
524
525
536 void assign (const AuxElement& other, bool warnUnlocked = false);
537
538
545
546
551
552
557
558
564 using IAuxElement::index;
565
566
568
569 template <class T, class ALLOC = AuxAllocator_t<T> >
571
572 template <class T, class ALLOC = AuxAllocator_t<T> >
574
575 template <class T, class ALLOC = AuxAllocator_t<T> >
577
578
587 template <class T, class ALLOC = AuxAllocator_t<T> >
590 auxdata (const std::string& name);
591
592
602 template <class T, class ALLOC = AuxAllocator_t<T> >
605 auxdata (const std::string& name,
606 const std::string& clsname);
607
608
618 template <class T, class ALLOC = AuxAllocator_t<T> >
621 auxdata (const std::string& name) const;
622
623
634 template <class T, class ALLOC = AuxAllocator_t<T> >
637 auxdata (const std::string& name,
638 const std::string& clsname) const;
639
640
649 template <class T, class ALLOC = AuxAllocator_t<T> >
652 auxdataConst (const std::string& name) const;
653
654
664 template <class T, class ALLOC = AuxAllocator_t<T> >
667 auxdataConst (const std::string& name,
668 const std::string& clsname) const;
669
670
680 template <class T, class ALLOC = AuxAllocator_t<T> >
682 bool isAvailable (const std::string& name,
683 const std::string& clsname = "") const;
684
685
695 template <class T, class ALLOC = AuxAllocator_t<T> >
697 bool isAvailableWritable (const std::string& name,
698 const std::string& clsname = "");
699
700
710 template <class T, class ALLOC = AuxAllocator_t<T> >
712 bool isAvailableWritableAsDecoration (const std::string& name,
713 const std::string& clsname = "") const;
714
715
728 template <class T, class ALLOC = AuxAllocator_t<T> >
731 auxdecor (const std::string& name) const;
732
733
747 template <class T, class ALLOC = AuxAllocator_t<T> >
750 auxdecor (const std::string& name,
751 const std::string& clsname) const;
752
753
760 void makePrivateStore();
761
762
774 template <class U1>
775 void makePrivateStore (const U1& other,
776 bool warnUnlocked = false);
777
778
790 template <class U1>
791 void makePrivateStore (const U1* other,
792 bool warnUnlocked = false);
793
794
801 void releasePrivateStore();
802
803
812 void setStore (const SG::IConstAuxStore* store);
813
814
823 void setStore (SG::IAuxStore* store);
824
825
834 void setStore (const DataLink< SG::IConstAuxStore >& store);
835
836
842
843
849
850
854 bool usingPrivateStore() const;
855
856
860 bool usingStandaloneStore() const;
861
862
870 const SG::IConstAuxStore* getConstStore() const;
871
872
879 SG::IAuxStore* getStore() const;
880
881
888 void clearCache();
889
890
900 const SG::auxid_set_t& getAuxIDs() const;
901
902
911 const SG::auxid_set_t& getDecorIDs() const;
912
913
919 bool hasStore() const;
920
921
927 bool hasNonConstStore() const;
928
929
939 bool clearDecorations() const;
940
941
948 bool trackIndices() const;
949
950
960 static constexpr bool supportsThinning = true;
961
962
963private:
965 friend class SG::AuxVectorBase;
967
968
975
976
991
992
1003
1004
1015 void makePrivateStore1 (const void* other, bool warnUnlocked);
1016
1017
1028 void makePrivateStore1 (const AuxElement* other,
1029 bool warnUnlocked);
1030
1031
1040
1041
1048 void clearAux();
1049
1050
1064 void copyAux (const ConstAuxElement& other,
1065 bool warnUnlocked = false);
1066
1067
1068#ifdef ATHCONTAINERS_R21_COMPAT
1082 void copyAux (const AuxElement& other,
1083 bool warnUnlocked = false);
1084
1085
1090#endif
1091
1092
1100 static void clearAuxHelper (AuxVectorData& container, size_t index);
1101
1102
1118 size_t index,
1119 const ConstAuxElement& other,
1120 bool warnUnlocked);
1121
1122
1123#ifdef ATHCONTAINERS_R21_COMPAT
1139 size_t index,
1140 const AuxElement& other,
1141 bool warnUnlocked);
1142#endif
1143};
1144
1145
1146} // namespace SG
1147
1148
1150
1151
1152#ifndef XAOD_STANDALONE
1153CLASS_DEF (SG::AuxElement, 225182422, 1)
1154#endif // not XAOD_STANDALONE
1155
1156
1157#endif // not ATHCONTAINERS_AUXELEMENTBASE_H
Allow customizing how aux data types are treated.
#define XAOD_AUXDATA_DEPRECATED
Definition AuxElement.h:45
Handle mappings between names and auxid_t.
Manage lookup of vectors of auxiliary data.
Helper class to provide constant type-safe access to aux data.
Helper class to provide type-safe access to aux data.
Exceptions that can be thrown from AthContainers.
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Helper class to provide type-safe access to aux data.
Flag that a class may have auxiliary data associated with it.
#define ATHCONTAINERS_R21_COMPAT
Definition IAuxElement.h:23
Interface for non-const operations on an auxiliary store.
Interface for const operations on an auxiliary store.
Helper class to provide const generic access to aux data.
Helper class to provide type-safe access to aux data.
typename AuxDataTraits< T, ALLOC >::reference_type reference_type
Internal data container for standalone store.
Base class for elements of a container that can have aux data.
Definition AuxElement.h:484
void releasePrivateStoreForDtor()
Out-of-line portion of destructor.
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
~AuxElement()
Destructor.
AuxElementStandaloneData * setStore1(const SG::IConstAuxStore *store)
Set the store associated with this object.
void clearCache()
Clear the cached aux data pointers.
void clearAux()
Clear all aux data associated with this element.
const SG::IConstAuxStore * getConstStore() const
Return the current store, as a const interface.
void makePrivateStore()
Create a new (empty) private store for this object.
ConstAuxElement::TypelessConstAccessor TypelessConstAccessor
Definition AuxElement.h:567
AuxElement & operator=(const AuxElement &other)
Assignment.
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::reference_type auxdata(const std::string &name)
Fetch an aux data variable, as a non-const reference.
void assign(const AuxElement &other, bool warnUnlocked=false)
Assignment.
void copyAux(const ConstAuxElement &other, bool warnUnlocked=false)
Copy aux data from another object.
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.
void setConstStore(const SG::IConstAuxStore *store)
Synonym for setStore with IConstAuxStore.
SG::ConstAccessor< T, ALLOC > ConstAccessor
Definition AuxElement.h:570
AuxElement(SG::AuxVectorData *container, size_t index)
Constructor with explicit container / index.
void makePrivateStore(const U1 *other, bool warnUnlocked=false)
Create a new private store for this object and copy aux data.
static constexpr bool supportsThinning
Mark that this type supports thinning operations.
Definition AuxElement.h:960
friend class SG::AuxVectorBase_test
Definition AuxElement.h:966
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:576
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.
bool hasStore() const
Return true if this object has an associated store.
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdata(const std::string &name) const
Fetch an aux data variable, as a const reference.
void setNonConstStore(SG::IAuxStore *store)
Synonym for setStore with IAuxStore.
bool trackIndices() const
Return true if index tracking is enabled for this object.
bool setIndexPrivate(size_t index, SG::AuxVectorData *container)
Set the index/container for this element.
static void clearAuxHelper(AuxVectorData &container, size_t index)
Clear all aux data associated with an element.
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.
void setIndex(size_t index, SG::AuxVectorData *container)
Set the index/container for this element.
SG::AuxVectorData * container()
Return the container holding this element.
bool usingPrivateStore() const
Test to see if this object is currently using a private store.
bool hasNonConstStore() const
Return true if this object has an associated non-const store.
bool usingStandaloneStore() const
Test to see if this object is currently using a standalone store.
void makePrivateStore(const U1 &other, bool warnUnlocked=false)
Create a new private store for this object and copy aux data.
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.
const SG::auxid_set_t & getDecorIDs() const
Return a set of identifiers for decorations for this object.
void releasePrivateStore()
Release and free any private store associated with this object.
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name) const
Fetch an aux data variable, as a const reference.
friend class SG::ConstAuxElement
Definition AuxElement.h:964
void makePrivateStore1(const void *other, bool warnUnlocked)
Create a new private store for this object and copy aux data.
static void copyAuxHelper(AuxVectorData &container, size_t index, const ConstAuxElement &other, bool warnUnlocked)
Copy aux data from another object.
AuxElement(const AuxElement &other)
Copy Constructor.
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::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:573
bool clearDecorations() const
Clear all decorations.
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::IAuxStore * getStore() const
Return the current store, as a non-const interface.
const SG::AuxVectorData * container() const
Return the container holding this element.
AuxElement()
Default constructor.
XAOD_AUXDATA_DEPRECATED bool isAvailableWritable(const std::string &name, const std::string &clsname="")
Check if an aux variable is available for writing.
Manage index tracking and synchronization of auxiliary data.
Manage lookup of vectors of auxiliary data.
Helper class to provide constant type-safe access to aux data.
typename AuxDataTraits< T, ALLOC >::const_reference_type const_reference_type
Const part of AuxElement.
Definition AuxElement.h:71
SG::TypelessConstAccessor TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition AuxElement.h:127
ConstAuxElement(const SG::AuxVectorData *container, size_t index)
Constructor with explicit container / index.
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.
const SG::AuxVectorData * m_container
The container of which this object is an element.
Definition AuxElement.h:335
friend class AuxElement
Definition AuxElement.h:292
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.
ConstAuxElement()
Default constructor.
void setIndex(size_t index, const SG::AuxVectorData *container)
Set the index/container for this element.
const SG::auxid_set_t & getDecorIDs() const
Return a set of identifiers for decorations for this object.
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::Decorator< T, ALLOC > Decorator
class to provide type-safe access to aux data.
Definition AuxElement.h:135
SG::ConstAccessor< T, ALLOC > ConstAccessor
Helper class to provide type-safe access to aux data.
Definition AuxElement.h:131
XAOD_AUXDATA_DEPRECATED ConstAccessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name) const
Fetch an aux data variable, as a const reference.
~ConstAuxElement()
Destructor.
bool setIndexPrivate(size_t index, const SG::AuxVectorData *container)
Set the index/container for this element.
const SG::AuxVectorData * container() const
Return the container holding this element.
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
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.
ConstAuxElement(const ConstAuxElement &other)
Copy Constructor.
void releasePrivateStoreForDtor()
Out-of-line portion of destructor.
ConstAuxElement & operator=(const ConstAuxElement &other)=delete
No assignment to a const element.
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.
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.
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
typename AuxDataTraits< T, ALLOC >::reference_type reference_type
Definition Decorator.h:62
Flag that a class may have auxiliary data associated with it.
Definition IAuxElement.h:51
size_t index() const
Return the index of this element within its container.
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
Interface for const operations on an auxiliary store.
Helper class to provide const generic access to aux data.
A set of aux data identifiers.
Definition AuxTypes.h:47
Define likely/unlikely macros for branch prediction.
Forward declaration.
Definition index.py:1
Simplified version of the C++20 std::span.