ATLAS Offline Software
Loading...
Searching...
No Matches
SG::AuxElement Class Reference

Base class for elements of a container that can have aux data. More...

#include <AuxElement.h>

Inherits SG::ConstAuxElement.

Inherited by D3PDTest::Obj5, DMTest::AllocTest_v1, DMTest::AllocTest_v1, DMTest::CLinks_v1, DMTest::C_v1, DMTest::G_v1, DMTest::G_v1, DMTest::H_v1, DMTest::H_v1, DMTest::H_v2, DMTest::JVec_v1, DMTest::PLinks_v1, DMTest::P_v1, FPGATrackSimHit, TrigNavTest::TestB, xAOD::AFPData_v1, xAOD::AFPSiHit_v1, xAOD::AFPSiHit_v2, xAOD::AFPSiHitsCluster_v1, xAOD::AFPToFHit_v1, xAOD::AFPToFTrack_v1, xAOD::AFPTrack_v1, xAOD::AFPTrack_v2, xAOD::AFPVertex_v1, xAOD::ALFAData_v1, xAOD::BCMRawData_v1, xAOD::BTagVertex_v1, xAOD::BTagging_v1, xAOD::BunchConf_v1, xAOD::CMMCPHits_v1, xAOD::CMMEtSums_v1, xAOD::CMMJetHits_v1, xAOD::CMMRoI_v1, xAOD::CMXCPHits_v1, xAOD::CMXCPTob_v1, xAOD::CMXEtSums_v1, xAOD::CMXJetHits_v1, xAOD::CMXJetTob_v1, xAOD::CMXRoI_v1, xAOD::CPMHits_v1, xAOD::CPMRoI_v1, xAOD::CPMTobRoI_v1, xAOD::CPMTower_v1, xAOD::CPMTower_v2, xAOD::CTPResult_v1, xAOD::CaloRings_v1, xAOD::CutBookkeeper_v1, xAOD::EmTauRoI_v1, xAOD::EmTauRoI_v2, xAOD::EnergySumRoI_v1, xAOD::EnergySumRoI_v2, xAOD::EventInfo_v1, xAOD::EventShape_v1, xAOD::ExampleElectron_v1, xAOD::FileMetaData_v1, xAOD::ForwardEventInfo_v1, xAOD::HIEventShape_v1, xAOD::HIEventShape_v2, xAOD::IParticle, xAOD::JEMEtSums_v1, xAOD::JEMEtSums_v2, xAOD::JEMHits_v1, xAOD::JEMRoI_v1, xAOD::JEMTobRoI_v1, xAOD::JetElement_v1, xAOD::JetElement_v2, xAOD::JetEtRoI_v1, xAOD::JetRoI_v1, xAOD::JetRoI_v2, xAOD::KLFitterResult, xAOD::L1TopoRawData_v1, xAOD::L1TopoSimResults_v1, xAOD::LumiBlockRange_v1, xAOD::MBTSModule_v1, xAOD::MissingETAssociation_v1, xAOD::MissingETComponent_v1, xAOD::MissingET_v1, xAOD::MuonRoI_v1, xAOD::MuonSegment_v1, xAOD::MuonSimHit_v1, xAOD::NRPCRDO_v1, xAOD::NSWMMTPRDO_v1, xAOD::NSWTPRDO_v1, xAOD::RODHeader_v1, xAOD::RODHeader_v2, xAOD::RingSetConf_v1, xAOD::RingSet_v1, xAOD::RoiDescriptorStore_v1, xAOD::SCTRawHitValidation_v1, xAOD::SlowMuon_v1, xAOD::SpacePoint_v1, xAOD::TrackJacobian_v1, xAOD::TrackMeasurementValidation_v1, xAOD::TrackMeasurement_v1, xAOD::TrackParameters_v1, xAOD::TrackParticleClusterAssociation_v1, xAOD::TrackStateValidation_v1, xAOD::TrackState_v1, xAOD::TrackSummary_v1, xAOD::TrackSurface_v1, xAOD::TrigBphys_v1, xAOD::TrigCaloCluster_v1, xAOD::TrigComposite_v1, xAOD::TrigDecision_v1, xAOD::TrigHisto2D_v1, xAOD::TrigMissingET_v1, xAOD::TrigNavigation_v1, xAOD::TrigPassBits_v1, xAOD::TrigRNNOutput_v1, xAOD::TrigRNNOutput_v2, xAOD::TrigRingerRings_v1, xAOD::TrigRingerRings_v2, xAOD::TrigSpacePointCounts_v1, xAOD::TrigT2MbtsBits_v1, xAOD::TrigT2ZdcSignals_v1, xAOD::TrigTrackCounts_v1, xAOD::TrigVertexCounts_v1, xAOD::TriggerMenuJson_v1, xAOD::TriggerMenu_v1, xAOD::TriggerTower_v1, xAOD::TruthEventBase_v1, xAOD::TruthMetaData_v1, xAOD::TruthVertex_v1, xAOD::UncalibratedMeasurement_v1, xAOD::Vertex_v1, xAOD::ZdcModule_v1, xAOD::eFexEMRoI_v1, xAOD::eFexTauRoI_v1, xAOD::eFexTower_v1, xAOD::gFexGlobalRoI_v1, xAOD::gFexJetRoI_v1, xAOD::gFexTower_v1, xAOD::jFexFwdElRoI_v1, xAOD::jFexLRJetRoI_v1, xAOD::jFexMETRoI_v1, xAOD::jFexSRJetRoI_v1, xAOD::jFexSumETRoI_v1, xAOD::jFexTauRoI_v1, and xAOD::jFexTower_v1.

Collaboration diagram for SG::AuxElement:

Public Types

using TypelessConstAccessor = ConstAuxElement::TypelessConstAccessor
template<class T, class ALLOC = AuxAllocator_t<T>>
using ConstAccessor = SG::ConstAccessor<T, ALLOC>
template<class T, class ALLOC = AuxAllocator_t<T>>
using Accessor = SG::Accessor<T, ALLOC>
template<class T, class ALLOC = AuxAllocator_t<T>>
using Decorator = SG::Decorator<T, ALLOC>

Public Member Functions

 AuxElement ()
 Default constructor.
 AuxElement (SG::AuxVectorData *container, size_t index)
 Constructor with explicit container / index.
 AuxElement (const AuxElement &other)
 Copy Constructor.
AuxElementoperator= (const AuxElement &other)
 Assignment.
void assign (const AuxElement &other, bool warnUnlocked=false)
 Assignment.
 ~AuxElement ()
 Destructor.
const SG::AuxVectorDatacontainer () const
 Return the container holding this element.
SG::AuxVectorDatacontainer ()
 Return the container holding this element.
template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::reference_type auxdata (const std::string &name)
 Fetch an aux data variable, as a non-const reference.
template<class T, class ALLOC = AuxAllocator_t<T>>
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.
template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdata (const std::string &name) const
 Fetch an aux data variable, as a const reference.
template<class T, class ALLOC = AuxAllocator_t<T>>
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.
template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type auxdataConst (const std::string &name) const
 Fetch an aux data variable, as a const reference.
template<class T, class ALLOC = AuxAllocator_t<T>>
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.
template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED bool isAvailable (const std::string &name, const std::string &clsname="") const
 Check if an aux variable is available for reading.
template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED bool isAvailableWritable (const std::string &name, const std::string &clsname="")
 Check if an aux variable is available for writing.
template<class T, class ALLOC = AuxAllocator_t<T>>
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.
template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type auxdecor (const std::string &name) const
 Fetch an aux decoration, as a non-const reference.
template<class T, class ALLOC = AuxAllocator_t<T>>
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.
void makePrivateStore ()
 Create a new (empty) private store for this object.
template<class U1>
void makePrivateStore (const U1 &other, bool warnUnlocked=false)
 Create a new private store for this object and copy aux data.
template<class U1>
void makePrivateStore (const U1 *other, bool warnUnlocked=false)
 Create a new private store for this object and copy aux data.
void releasePrivateStore ()
 Release and free any private store associated with this object.
void setStore (const SG::IConstAuxStore *store)
 Set the store associated with this object.
void setStore (SG::IAuxStore *store)
 Set the store associated with this object.
void setStore (const DataLink< SG::IConstAuxStore > &store)
 Set the store associated with this object.
void setConstStore (const SG::IConstAuxStore *store)
 Synonym for setStore with IConstAuxStore.
void setNonConstStore (SG::IAuxStore *store)
 Synonym for setStore with IAuxStore.
bool usingPrivateStore () const
 Test to see if this object is currently using a private store.
bool usingStandaloneStore () const
 Test to see if this object is currently using a standalone store.
const SG::IConstAuxStoregetConstStore () const
 Return the current store, as a const interface.
SG::IAuxStoregetStore () const
 Return the current store, as a non-const interface.
void clearCache ()
 Clear the cached aux data pointers.
const SG::auxid_set_tgetAuxIDs () const
 Return a set of identifiers for existing data items for this object.
const SG::auxid_set_tgetDecorIDs () const
 Return a set of identifiers for decorations for this object.
bool hasStore () const
 Return true if this object has an associated store.
bool hasNonConstStore () const
 Return true if this object has an associated non-const store.
bool clearDecorations () const
 Clear all decorations.
bool trackIndices () const
 Return true if index tracking is enabled for this object.
size_t index () const
 Return the index of this element within its container.

Static Public Attributes

static constexpr bool supportsThinning = true
 Mark that this type supports thinning operations.

Protected Member Functions

bool noPrivateData () const
 True if this element has no private data.
bool havePrivateData () const
 True if this element currently has private data.
bool hadPrivateData () const
 True if this element had private data before it was added to its current container.

Private Types

enum class  PrivateStoreState : uint8_t { NO_PRIVATE = 0 , HAVE_PRIVATE = 1 , HAD_PRIVATE = 2 }
 The current private data state. More...

Private Member Functions

void releasePrivateStoreForDtor ()
 Out-of-line portion of destructor.
void setIndex (size_t index, SG::AuxVectorData *container)
 Set the index/container for this element.
bool setIndexPrivate (size_t index, SG::AuxVectorData *container)
 Set the index/container for this element.
void makePrivateStore1 (const void *other, bool warnUnlocked)
 Create a new private store for this object and copy aux data.
void makePrivateStore1 (const AuxElement *other, bool warnUnlocked)
 Create a new private store for this object and copy aux data.
AuxElementStandaloneDatasetStore1 (const SG::IConstAuxStore *store)
 Set the store associated with this object.
void clearAux ()
 Clear all aux data associated with this element.
void copyAux (const ConstAuxElement &other, bool warnUnlocked=false)
 Copy aux data from another object.
void setNoPrivateData ()
 Record that this element does not have private data.
void setHavePrivateData ()
 Record that this element currently has private data.
void setHadPrivateData ()
 Record that this element used to have private data.

Static Private Member Functions

static void clearAuxHelper (AuxVectorData &container, size_t index)
 Clear all aux data associated with an element.
static void copyAuxHelper (AuxVectorData &container, size_t index, const ConstAuxElement &other, bool warnUnlocked)
 Copy aux data from another object.

Private Attributes

const SG::AuxVectorDatam_container
 The container of which this object is an element.
size_t m_index
 The index of this element within its container.
PrivateStoreState m_privateStoreState

Friends

class SG::ConstAuxElement
class SG::AuxVectorBase
class SG::AuxVectorBase_test

Detailed Description

Base class for elements of a container that can have aux data.

Classes that want to have associated auxiliary data should derive from this class. (It is also possible to use this class directly, if you want a container that only stores auxiliary data.)

The first thing that happens when you derive from AuxElement is that when an object is inserted into a DataVector, the vector will maintain information in the object telling were it is within the vector. For example:

v[1] = new SG::AuxElement;
assert (v[1]->index() == 1);
assert (v[1]=>container() == &v);
Derived DataVector<T>.
Definition DataVector.h:795
Base class for elements of a container that can have aux data.
Definition AuxElement.h:484
const SG::AuxVectorData * container() const
Return the container holding this element.
size_t index() const
Return the index of this element within its container.

As long as you don't use DataVector::stdcont or use unsafe casts, DataVector will correctly maintain this information.

When an object deriving from AuxElement is in a DataVector it may have auxiliary data associated with it; that is, named data objects of arbitrary type. The recommended way of accessing auxiliary data is through the Accessor and ConstAccessor classes, which cache the lookup between the aux data item name and its internal representation. The difference between these two is that ConstAccessor allows only const access to the element, while Accessor, which derives from it, allows non-const access as well. A given name must always have the same type, no matter where it is used (even across different classes); otherwise, an exception will be thrown. To help prevent conflicts between different classes, aux data item names may be optionally qualified with a class name. Here's an example of using ConstAccessor:

// Only need to do this once.
SG::ConstAccessor<int> vint1 ("myInt");
...
const Myclass* m = ...;
int x = vint1 (*m);
#define x
Helper class to provide constant type-safe access to aux data.

The auxdata methods can be used as a shortcut for this, but that's not recommended for anything for which performance is an issue.

You can also define getters/setters in your class:

class Myclass {
...
int get_x() const
{ const static SG::ConstAccessor<int> acc ("x", "Myclass");
return acc (*this); }
int& get_x()
{ const static SG::Accessor<int> acc ("x", "Myclass");
return acc (*this); }
Helper class to provide type-safe access to aux data.

In addition, one sometimes wants to add additional auxiliary data to an existing const container; for example, after a container has been retrieved from StoreGate. This is called ‘decoration’, and is handled by the Decorator object, which is much like Accessor and ConstAccessor. The difference is that Decorator can take a const container and return a non-const, modifiable reference. If the container has been locked by calling StoreGateSvc::setConst, then this is allowed only if this is a new auxiliary item, in which case it is marked as a decoration, or if it is already marked as a decoration. This prevents changing existing variables in a locked container. An auxdecor method is also available, analogous to auxdata.

In addition to the above, the class TypelessConstAccessor is a non-templated class that allows access to auxiliary data items directly as a void *. This is useful for code which operates on auxiliary data generically; it shouldn't really be used in other contexts.

Normally, an object can have auxiliary data only when it is part of a container. But sometimes it is useful to be able to associate aux data with an object before it has been added to a container. You can enable this by creating a ‘private store’ for the object with makePrivateStore. This can optionally take an argument from which aux data should be copied. (Using a private store adds overhead, which is why it is not enabled by default.) Example:

class Myclass : public SG::AuxElement { ... };
...
SG::Accessor<int> myint ("myint");
const Myclass* m = new Myclass;
m->makePrivateStore();
myint(*m) = 10;
v.push_back(m);
assert (myint(v[0]) == 10);

When an object with a private store is added to a container, the aux data is copied to the container and the private store is released. However, the fact that we had a private store is remembered; if the object is later removed from the container, the private store will be remade, and the aux data will be copied back from the container to the private store. To explicitly release the private store (so that it won't come back automatically), call releasePrivateStore.

If you add makePrivateStore calls to the constructors of your class, then you should be able to treat aux data as if it were part of the object itself; the required copying will be handled automatically.

class Myclass : public SG::AuxElement
{
public:
Myclass() { makePrivateStore(); }
Myclass(const Myclass* other) { makePrivateStore(other); }
void makePrivateStore()
Create a new (empty) private store for this object.

The SG::AuxElementComplete template class may be helpful in setting this up.

It is also possible to associate one of these objects with an external aux data store. This is the ‘standalone’ mode. To do this, use the setStore methods, exactly as you would for a container that has aux data. setStore will throw an exception if the object is a member of a container or has a private store.

This class should not have any virtual methods (to avoid forcing derived classes to have a vtable).

Definition at line 478 of file AuxElement.h.

Member Typedef Documentation

◆ Accessor

template<class T, class ALLOC = AuxAllocator_t<T>>
using SG::AuxElement::Accessor = SG::Accessor<T, ALLOC>

Definition at line 573 of file AuxElement.h.

◆ ConstAccessor

template<class T, class ALLOC = AuxAllocator_t<T>>
using SG::AuxElement::ConstAccessor = SG::ConstAccessor<T, ALLOC>

Definition at line 570 of file AuxElement.h.

◆ Decorator

template<class T, class ALLOC = AuxAllocator_t<T>>
using SG::AuxElement::Decorator = SG::Decorator<T, ALLOC>

Definition at line 576 of file AuxElement.h.

◆ TypelessConstAccessor

Member Enumeration Documentation

◆ PrivateStoreState

enum class SG::IAuxElement::PrivateStoreState : uint8_t
strongprivateinherited

The current private data state.

Enumerator
NO_PRIVATE 
HAVE_PRIVATE 
HAD_PRIVATE 

Definition at line 131 of file IAuxElement.h.

132 {
133 NO_PRIVATE = 0,
134 HAVE_PRIVATE = 1,
135 HAD_PRIVATE = 2,
136 };

Constructor & Destructor Documentation

◆ AuxElement() [1/3]

SG::AuxElement::AuxElement ( )

Default constructor.

◆ AuxElement() [2/3]

SG::AuxElement::AuxElement ( SG::AuxVectorData * container,
size_t index )

Constructor with explicit container / index.

Parameters
containerContainer of which this element will be a part.
indexIndex of this element within the container.

This does not make any changes to aux data.

◆ AuxElement() [3/3]

SG::AuxElement::AuxElement ( const AuxElement & other)

Copy Constructor.

Parameters
otherObject being copied.

We do not copy the container/index — the new object is not yet in a container!

In the case of constructing an object with a private store, makePrivateStore will take care of copying the aux data.

◆ ~AuxElement()

SG::AuxElement::~AuxElement ( )

Destructor.

Any private store is deleted.

Member Function Documentation

◆ assign()

void SG::AuxElement::assign ( const AuxElement & other,
bool warnUnlocked = false )

Assignment.

Parameters
otherThe object from which we're assigning.
warnUnlockedIf true, then warn when we skip unlocked decorations.

We don't copy container/index, as assignment doesn't change where this object is. However, if we have aux data, then we copy aux data if we're copying from an object that also has it; otherwise, if we're copying from an object with no aux data, then we clear ours.

◆ auxdata() [1/4]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::reference_type SG::AuxElement::auxdata ( const std::string & name)

Fetch an aux data variable, as a non-const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ auxdata() [2/4]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type SG::AuxElement::auxdata ( const std::string & name) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor or ConstAccessor classes.

◆ auxdata() [3/4]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::reference_type SG::AuxElement::auxdata ( const std::string & name,
const std::string & clsname )

Fetch an aux data variable, as a non-const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ auxdata() [4/4]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type SG::AuxElement::auxdata ( const std::string & name,
const std::string & clsname ) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor or ConstAccessor classes.

◆ auxdataConst() [1/2]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type SG::AuxElement::auxdataConst ( const std::string & name) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the ConstAccessor class.

◆ auxdataConst() [2/2]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Accessor< T, ALLOC >::const_reference_type SG::AuxElement::auxdataConst ( const std::string & name,
const std::string & clsname ) const

Fetch an aux data variable, as a const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the ConstAccessor class.

◆ auxdecor() [1/2]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type SG::AuxElement::auxdecor ( const std::string & name) const

Fetch an aux decoration, as a non-const reference.

Parameters
nameName of the aux variable.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ auxdecor() [2/2]

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED Decorator< T, ALLOC >::reference_type SG::AuxElement::auxdecor ( const std::string & name,
const std::string & clsname ) const

Fetch an aux decoration, as a non-const reference.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

If the container is locked, this will allow fetching only variables that do not yet exist (in which case they will be marked as decorations) or variables already marked as decorations.

◆ clearAux()

void SG::AuxElement::clearAux ( )
private

Clear all aux data associated with this element.

If this object has no associated store, this does nothing. If the associated aux data is const, this throws ExcConstAuxData.

Definition at line 567 of file AuxElement.cxx.

568{
569 if (!m_container) return;
571}
static void clearAuxHelper(AuxVectorData &container, size_t index)
Clear all aux data associated with an element.
const SG::AuxVectorData * m_container
The container of which this object is an element.
Definition AuxElement.h:335

◆ clearAuxHelper()

void SG::AuxElement::clearAuxHelper ( AuxVectorData & container,
size_t index )
staticprivate

Clear all aux data associated with an element.

Parameters
containerContainer of the element.
indexIndex of this element within the container.

If the associated aux data is const, this throws ExcConstAuxData.

Definition at line 626 of file AuxElement.cxx.

627{
628 if (!container.hasStore()) return;
629 if (!container.hasNonConstStore()) {
630 throw SG::ExcConstAuxData ("clearAux", SG::null_auxid);
631 }
632
633 SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
634 for (SG::auxid_t auxid : container.getWritableAuxIDs()) {
635 r.clear (auxid, container, index, 1);
636 }
637}
static AuxTypeRegistry & instance()
Return the singleton registry instance.
int r
Definition globals.cxx:22
static const auxid_t null_auxid
To signal no aux data item.
Definition AuxTypes.h:30
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27

◆ clearCache()

void SG::AuxElement::clearCache ( )

Clear the cached aux data pointers.

You should call this any time something changes in the aux store that could invalidate the vector pointers.

Definition at line 339 of file AuxElement.cxx.

340{
341 if (container())
343}
void clearCache()
Clear the cached aux data pointers.

◆ clearDecorations()

bool SG::AuxElement::clearDecorations ( ) const

Clear all decorations.

Erase all decorations from an associated store, restoring the state to when lock was called.

Returns true if there were any decorations that were cleared, false if the store did not contain any decorations.

Definition at line 415 of file AuxElement.cxx.

416{
417 if (havePrivateData())
418 return m_container->clearDecorations();
419 return false;
420}
bool havePrivateData() const
True if this element currently has private data.

◆ container() [1/2]

SG::AuxVectorData * SG::AuxElement::container ( )

Return the container holding this element.

◆ container() [2/2]

const SG::AuxVectorData * SG::AuxElement::container ( ) const

Return the container holding this element.

◆ copyAux()

void SG::AuxElement::copyAux ( const ConstAuxElement & other,
bool warnUnlocked = false )
private

Copy aux data from another object.

Parameters
otherThe object from which to copy.
warnUnlockedIf true, then warn when we skip unlocked decorations.

If this object has no associated store, this does nothing. If the associated aux data is const, this throws ExcConstAuxData.

All aux data items from other are copied to this object. Any aux data items associated with this object that are not present in other are cleared. (If other has no aux data, then all aux data items for this object are cleared.)

Definition at line 587 of file AuxElement.cxx.

589{
590 if (!m_container) return;
591 copyAuxHelper (*container(), index(), other, warnUnlocked);
592}
static void copyAuxHelper(AuxVectorData &container, size_t index, const ConstAuxElement &other, bool warnUnlocked)
Copy aux data from another object.

◆ copyAuxHelper()

void SG::AuxElement::copyAuxHelper ( AuxVectorData & container,
size_t index,
const ConstAuxElement & other,
bool warnUnlocked )
staticprivate

Copy aux data from another object.

Parameters
containerContainer of the element.
indexIndex of this element within the container.
otherThe object from which to copy.
warnUnlockedIf true, then warn when we skip unlocked decorations.

If the associated aux data is const, this throws ExcConstAuxData.

All aux data items from other are copied to this object. Any aux data items associated with this object that are not present in other are cleared. (If other has no aux data, then all aux data items for this object are cleared.)

Definition at line 654 of file AuxElement.cxx.

658{
659 if (!container.hasStore()) return;
660 if (!container.hasNonConstStore())
661 throw SG::ExcConstAuxData ("copyAux");
662
663 const SG::AuxVectorData* ocont = other.container();
664
665 if (!ocont || !ocont->hasStore()) {
667 return;
668 }
669
670#ifndef XAOD_STANDALONE
671 const SG::auxid_set_t& other_decors = ocont->getDecorIDs();
672#endif
673 SG::auxid_set_t other_ids = ocont->getAuxIDs();
674
675 size_t oindex = other.index();
676 SG::AuxTypeRegistry& r = SG::AuxTypeRegistry::instance();
677
678 for (SG::auxid_t auxid : other_ids) {
679#ifndef XAOD_STANDALONE
680 if (other_decors.test (auxid)) {
681 // Don't copy decorations --- another thread may be modifying them.
682 other_ids.reset (auxid);
683 // Warn if we skip a decoration (except for mcEventWeights,
684 // for which this is expected).
685 if (warnUnlocked && r.getName(auxid) != "mcEventWeights") {
686 std::ostringstream ss;
687 ss << "skipped unlocked decoration " << r.getName(auxid)
688 << " (" << auxid << ")";
689 ATHCONTAINERS_WARNING("copyAux", ss.str());
690 }
691 }
692 else
693#endif
694 if (!r.isLinked (auxid)) {
695 r.copy (auxid, container, index, *ocont, oindex, 1);
696 }
697 }
698
699 for (SG::auxid_t auxid : container.getWritableAuxIDs()) {
700 if (!other_ids.test (auxid)) {
701 r.clear (auxid, container, index, 1);
702 }
703 }
704}
static Double_t ss
bool test(bit_t bit) const
Test to see if a bit is set.
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items in store associated with this object.
const SG::auxid_set_t & getDecorIDs() const
Return a set of identifiers for decorations for this object.
bool hasStore() const
Return true if this object has an associated store.
#define ATHCONTAINERS_WARNING(ctx, msg)
Definition error.h:57

◆ getAuxIDs()

const SG::auxid_set_t & SG::AuxElement::getAuxIDs ( ) const

Return a set of identifiers for existing data items for this object.

If this object has a private or standalone store, then information from that will be returned. Otherwise, if this element is part of a container, then information for the container will be returned. Otherwise, return an empty set.

Definition at line 355 of file AuxElement.cxx.

356{
357#ifdef ATHCONTAINERS_R21_COMPAT
358 if (havePrivateData())
359 return m_container->getConstStore()->getAuxIDs();
360 if (container())
361 return container()->getAuxIDs();
362 static const SG::auxid_set_t null_set;
363 return null_set;
364#else
366#endif
367}
const SG::auxid_set_t & getAuxIDs() const
Return a set of identifiers for existing data items for this object.

◆ getConstStore()

const SG::IConstAuxStore * SG::AuxElement::getConstStore ( ) const

Return the current store, as a const interface.

This will be non-zero if either a const or non-const store is associated with this object. This will fetch either a private or standalone store.

Definition at line 304 of file AuxElement.cxx.

305{
306 if (havePrivateData()) {
307 return m_container->getConstStore();
308 }
309 return 0;
310}

◆ getDecorIDs()

const SG::auxid_set_t & SG::AuxElement::getDecorIDs ( ) const

Return a set of identifiers for decorations for this object.

   If this object has a private or standalone store, then information
   from that will be returned.  Otherwise, if this element
   is part of a container, then information for the container
   will be returned.  Otherwise, return an empty set.

Definition at line 378 of file AuxElement.cxx.

379{
380#ifdef ATHCONTAINERS_R21_COMPAT
381 if (havePrivateData())
382 return m_container->getConstStore()->getDecorIDs();
383 if (container())
384 return container()->getDecorIDs();
385 static const SG::auxid_set_t null_set;
386 return null_set;
387#else
389#endif
390}
const SG::auxid_set_t & getDecorIDs() const
Return a set of identifiers for decorations for this object.

◆ getStore()

SG::IAuxStore * SG::AuxElement::getStore ( ) const

Return the current store, as a non-const interface.

This will be non-zero if a non-const store is associated with this object. This will fetch either a private or standalone store.

Definition at line 319 of file AuxElement.cxx.

320{
321 if (havePrivateData()) {
322#ifdef ATHCONTAINERS_R21_COMPAT
323 SG::AuxVectorData* container_nc ATLAS_THREAD_SAFE = m_container;
324#else
325 SG::AuxVectorData* container_nc ATLAS_THREAD_SAFE = const_cast<SG::AuxVectorData*>(container());
326#endif
327 return container_nc->getStore();
328 }
329 return 0;
330}
#define ATLAS_THREAD_SAFE

◆ hadPrivateData()

bool SG::IAuxElement::hadPrivateData ( ) const
protectedinherited

True if this element had private data before it was added to its current container.

◆ hasNonConstStore()

bool SG::AuxElement::hasNonConstStore ( ) const

Return true if this object has an associated non-const store.

This will be true for either a private or standalone store.

Definition at line 398 of file AuxElement.cxx.

399{
400 if (havePrivateData())
401 return m_container->hasNonConstStore();
402 return false;
403}

◆ hasStore()

bool SG::AuxElement::hasStore ( ) const

Return true if this object has an associated store.

This will be true for either a private or standalone store.

◆ havePrivateData()

bool SG::IAuxElement::havePrivateData ( ) const
protectedinherited

True if this element currently has private data.

◆ index()

size_t SG::IAuxElement::index ( ) const

Return the index of this element within its container.

Inherited from IAuxElement.

◆ isAvailable()

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED bool SG::AuxElement::isAvailable ( const std::string & name,
const std::string & clsname = "" ) const

Check if an aux variable is available for reading.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ isAvailableWritable()

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED bool SG::AuxElement::isAvailableWritable ( const std::string & name,
const std::string & clsname = "" )

Check if an aux variable is available for writing.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ isAvailableWritableAsDecoration()

template<class T, class ALLOC = AuxAllocator_t<T>>
XAOD_AUXDATA_DEPRECATED bool SG::AuxElement::isAvailableWritableAsDecoration ( const std::string & name,
const std::string & clsname = "" ) const

Check if an aux variable is available for writing as a decoration.

Parameters
nameName of the aux variable.
clsnameThe name of the associated class. May be blank.

This method has to translate from the aux data name to the internal representation each time it is called. Using this method inside of loops is discouraged; instead use the Accessor class.

◆ makePrivateStore() [1/3]

void SG::AuxElement::makePrivateStore ( )

Create a new (empty) private store for this object.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

Definition at line 192 of file AuxElement.cxx.

193{
194 if (m_container) {
195 throw SG::ExcBadPrivateStore ("store already exists");
196 }
197
198 m_container = new SG::AuxElementPrivateData;
201}
void setIndex(size_t index)
Set the index of this element within its container.
void setHavePrivateData()
Record that this element currently has private data.

◆ makePrivateStore() [2/3]

template<class U1>
void SG::AuxElement::makePrivateStore ( const U1 & other,
bool warnUnlocked = false )

Create a new private store for this object and copy aux data.

Parameters
otherThe object from which aux data should be copied.
warnUnlockedIf true, then warn when we skip unlocked decorations.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

If other is an object that has aux data, then those data will be copied; otherwise, nothing will be done.

◆ makePrivateStore() [3/3]

template<class U1>
void SG::AuxElement::makePrivateStore ( const U1 * other,
bool warnUnlocked = false )

Create a new private store for this object and copy aux data.

Parameters
otherThe object from which aux data should be copied.
warnUnlockedIf true, then warn when we skip unlocked decorations.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

If other is an object that has aux data, then those data will be copied; otherwise, nothing will be done.

◆ makePrivateStore1() [1/2]

void SG::AuxElement::makePrivateStore1 ( const AuxElement * other,
bool warnUnlocked )
private

Create a new private store for this object and copy aux data.

Parameters
otherThe object from which aux data should be copied.
warnUnlockedIf true, then warn when we skip unlocked decorations.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

This overload handles the case where other does have aux data.

Definition at line 552 of file AuxElement.cxx.

554{
556 if (other)
557 this->copyAux (*other, warnUnlocked);
558}
void copyAux(const ConstAuxElement &other, bool warnUnlocked=false)
Copy aux data from another object.

◆ makePrivateStore1() [2/2]

void SG::AuxElement::makePrivateStore1 ( const void * other,
bool warnUnlocked )
private

Create a new private store for this object and copy aux data.

Parameters
otherThe object from which aux data should be copied.
warnUnlockedIf true, then warn when we skip unlocked decorations.

ExcBadPrivateStore will be thrown if this object is already associated with a store.

This overload handles the case where other does not have aux data.

◆ noPrivateData()

bool SG::IAuxElement::noPrivateData ( ) const
protectedinherited

True if this element has no private data.

◆ operator=()

AuxElement & SG::AuxElement::operator= ( const AuxElement & other)

Assignment.

Parameters
otherThe object from which we're assigning.

We don't copy container/index, as assignment doesn't change where this object is. However, if we have aux data, then we copy aux data if we're copying from an object that also has it; otherwise, if we're copying from an object with no aux data, then we clear ours.

◆ releasePrivateStore()

void SG::AuxElement::releasePrivateStore ( )

Release and free any private store associated with this object.

ExcBadPrivateStore will be thrown if this object does not have a private store.

Definition at line 210 of file AuxElement.cxx.

211{
212 if (hadPrivateData()) {
213 // We had a private store, but it was released because this object
214 // was added to a container. Just forget about it.
216 return;
217 }
218
219 if (!havePrivateData() ||
220 !m_container ||
221 typeid(*m_container) != typeid(AuxElementPrivateData))
222 {
223 throw SG::ExcBadPrivateStore ("no private store exists");
224 }
225
228 delete m_container;
229 m_container = 0;
230}
bool hadPrivateData() const
True if this element had private data before it was added to its current container.
void setNoPrivateData()
Record that this element does not have private data.

◆ releasePrivateStoreForDtor()

void SG::AuxElement::releasePrivateStoreForDtor ( )
private

Out-of-line portion of destructor.

Delete a private store if we have one.

Definition at line 428 of file AuxElement.cxx.

429{
430#ifdef ATHCONTAINERS_R21_COMPAT
431 if (havePrivateData()) {
432 delete m_container;
433 }
434#else
436#endif
437}
void releasePrivateStoreForDtor()
Out-of-line portion of destructor.

◆ setConstStore()

void SG::AuxElement::setConstStore ( const SG::IConstAuxStore * store)

Synonym for setStore with IConstAuxStore.

Parameters
storeThe new store.

◆ setHadPrivateData()

void SG::IAuxElement::setHadPrivateData ( )
privateinherited

Record that this element used to have private data.

◆ setHavePrivateData()

void SG::IAuxElement::setHavePrivateData ( )
privateinherited

Record that this element currently has private data.

◆ setIndex()

void SG::AuxElement::setIndex ( size_t index,
SG::AuxVectorData * container )
private

Set the index/container for this element.

Parameters
indexThe index of this object within the container.
containerThe container holding this object. May be null if this object is being removed from a container.

Usually this simply sets the index and container members of this object. However, in the case where this object has an associated private store, then we need to deal with releasing the store if the object is being added to a container, or making a new store if the object is being removed from a container.

◆ setIndexPrivate()

bool SG::AuxElement::setIndexPrivate ( size_t index,
SG::AuxVectorData * container )
private

Set the index/container for this element.

Parameters
indexThe index of this object within the container.
containerThe container holding this object. May be null if this object is being removed from a container.

This is called from setIndex when we have a private store to deal with.

Definition at line 492 of file AuxElement.cxx.

493{
494#ifdef ATHCONTAINERS_R21_COMPAT
495 if (hadPrivateData()) {
496 // We had a private store, but it was released because we were added
497 // to a container.
498
499 if (container == 0) {
500 // We're being moved out of the container. Make a new private
501 // store, copy the data, and switch to it.
502 auto privateData = new SG::AuxElementPrivateData;
503 AuxElement to (privateData, 0);
504 to.copyAux (*this);
507 m_container = privateData;
508 return true;
509 }
510 }
511 else if (havePrivateData() &&
512 typeid(*m_container) == typeid(AuxElementPrivateData))
513 {
514 // We currently have a private store.
515
516 if (container != 0 && container != m_container) {
517 // We're being added to a container.
518 // Aux data has already been copied.
519 // Release private store.
522 delete m_container;
524 return false;
525 }
526 }
527 else {
528 // We have a standalone store.
529 throw SG::ExcBadPrivateStore ("Attempt to add/remove a standalone object "
530 "from a container.");
531 }
532
535 return false;
536#else
538#endif
539}
AuxElement()
Default constructor.
bool setIndexPrivate(size_t index, const SG::AuxVectorData *container)
Set the index/container for this element.
void setHadPrivateData()
Record that this element used to have private data.
CONT to(RANGE &&r)
Definition ranges.h:39

◆ setNonConstStore()

void SG::AuxElement::setNonConstStore ( SG::IAuxStore * store)

Synonym for setStore with IAuxStore.

Parameters
storeThe new store.

◆ setNoPrivateData()

void SG::IAuxElement::setNoPrivateData ( )
privateinherited

Record that this element does not have private data.

◆ setStore() [1/3]

void SG::AuxElement::setStore ( const DataLink< SG::IConstAuxStore > & store)

Set the store associated with this object.

Parameters
storeThe new store.

If store is nonzero, this adds a standalone store to the object. The object must not be in a container and must not have a private store. If store is zero, this removes a standalone store.

Parameters
storeLink to the new store.

Definition at line 269 of file AuxElement.cxx.

270{
271 AuxElementStandaloneData* data = setStore1 (store);
272 if (store)
273 data->setStore (store);
274}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
AuxElementStandaloneData * setStore1(const SG::IConstAuxStore *store)
Set the store associated with this object.

◆ setStore() [2/3]

void SG::AuxElement::setStore ( const SG::IConstAuxStore * store)

Set the store associated with this object.

Parameters
storeThe new store.

If store is nonzero, this adds a standalone store to the object. The object must not be in a container and must not have a private store. If store is zero, this removes a standalone store.

Definition at line 241 of file AuxElement.cxx.

242{
243 AuxElementStandaloneData* data = setStore1 (store);
244 if (store)
245 data->setStore (store);
246}

◆ setStore() [3/3]

void SG::AuxElement::setStore ( SG::IAuxStore * store)

Set the store associated with this object.

Parameters
storeThe new store.

If store is nonzero, this adds a standalone store to the object. The object must not be in a container and must not have a private store. If store is zero, this removes a standalone store.

Definition at line 257 of file AuxElement.cxx.

258{
259 AuxElementStandaloneData* data = setStore1 (store);
260 if (store)
261 data->setStore (store);
262}

◆ setStore1()

AuxElementStandaloneData * SG::AuxElement::setStore1 ( const SG::IConstAuxStore * store)
private

Set the store associated with this object.

Parameters
storeThe new store.

Helper for setStore. Creates the AuxElementStandaloneData object if needed and returns it.

Parameters
storeThe new store.

Helper for setStore. Creates the @x AuxElementStandaloneData object if needed and returns it.

Definition at line 448 of file AuxElement.cxx.

449{
450 if (store) {
451 // Want this object be standalone.
452 if (!m_container) {
453 // Not in a container (and no private store). Make a new object.
454 AuxElementStandaloneData* data = new AuxElementStandaloneData;
457 return data;
458 }
459 if (usingStandaloneStore()) {
460 // Standalone --- return existing object.
461 return static_cast<AuxElementStandaloneData*> (container());
462 }
463 // Otherwise, it's an error.
464 throw ExcBadPrivateStore ("Attempt to attach a standalone store to an "
465 "object in a container or with a private store.");
466 }
467
468 else {
469 // Getting rid of a standalone store.
470 if (usingStandaloneStore()) {
472 delete m_container;
473 m_container = 0;
474 }
475 else if (m_container != 0)
476 throw ExcBadPrivateStore ("Attempt to remove a standalone store from an "
477 "object in a container or with a private store.");
478 return 0;
479 }
480}
bool usingStandaloneStore() const
Test to see if this object is currently using a standalone store.

◆ trackIndices()

bool SG::AuxElement::trackIndices ( ) const

Return true if index tracking is enabled for this object.

Always returns true. Included here to be consistent with AuxVectorBase when standalone objects may be used as template parameters.

◆ usingPrivateStore()

bool SG::AuxElement::usingPrivateStore ( ) const

Test to see if this object is currently using a private store.

Definition at line 280 of file AuxElement.cxx.

281{
282 return havePrivateData() &&
283 typeid(*m_container) == typeid(AuxElementPrivateData);
284}

◆ usingStandaloneStore()

bool SG::AuxElement::usingStandaloneStore ( ) const

Test to see if this object is currently using a standalone store.

Test to see if this object is currently using a private store.

Definition at line 290 of file AuxElement.cxx.

291{
292 return havePrivateData() &&
293 typeid(*m_container) == typeid(AuxElementStandaloneData);
294}

◆ SG::AuxVectorBase

friend class SG::AuxVectorBase
friend

Definition at line 965 of file AuxElement.h.

◆ SG::AuxVectorBase_test

friend class SG::AuxVectorBase_test
friend

Definition at line 966 of file AuxElement.h.

◆ SG::ConstAuxElement

friend class SG::ConstAuxElement
friend

Definition at line 964 of file AuxElement.h.

Member Data Documentation

◆ m_container

const SG::AuxVectorData* SG::ConstAuxElement::m_container
privateinherited

The container of which this object is an element.

Should be null if this object is not within a container, except that it may also point at a private store.

Definition at line 335 of file AuxElement.h.

◆ m_index

size_t SG::IAuxElement::m_index
privateinherited

The index of this element within its container.

Should be 0 if this object is not within a container.

Definition at line 128 of file IAuxElement.h.

◆ m_privateStoreState

PrivateStoreState SG::IAuxElement::m_privateStoreState
privateinherited

Definition at line 137 of file IAuxElement.h.

◆ supportsThinning

bool SG::AuxElement::supportsThinning = true
staticconstexpr

Mark that this type supports thinning operations.

See AthContainers/supportsThinning.h and AthenaPoolCnvSvc/T_AthenaPoolCnv.h. Helps guide which pool converter template will be used. If false, the default pool converter will be used rather than the aux store-specific one. Ordinary xAOD type should not touch this, but may be overridden in a derived class to handle certain special cases.

Definition at line 960 of file AuxElement.h.


The documentation for this class was generated from the following files: