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-2025 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
479 : public SG::IAuxElement
480#else
481 : public ConstAuxElement
482#endif
483{
484public:
487
488
497
498
499
510 AuxElement (const AuxElement& other);
511
512
523
524
535 void assign (const AuxElement& other, bool warnUnlocked = false);
536
537
544
545
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
833 void setStore (const DataLink< SG::IConstAuxStore >& store);
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
962private:
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
1081 void copyAux (const AuxElement& other,
1082 bool warnUnlocked = false);
1083
1084
1089#endif
1090
1091
1099 static void clearAuxHelper (AuxVectorData& container, size_t index);
1100
1101
1117 size_t index,
1118 const ConstAuxElement& other,
1119 bool warnUnlocked);
1120
1121
1122#ifdef ATHCONTAINERS_R21_COMPAT
1138 size_t index,
1139 const AuxElement& other,
1140 bool warnUnlocked);
1141#endif
1142};
1143
1144
1145} // namespace SG
1146
1147
1149
1150
1151#ifndef XAOD_STANDALONE
1152CLASS_DEF (SG::AuxElement, 225182422, 1)
1153#endif // not XAOD_STANDALONE
1154
1155
1156#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:483
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:566
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:569
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:959
friend class SG::AuxVectorBase_test
Definition AuxElement.h:965
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
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:963
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:572
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.