ATLAS Offline Software
RootAuxDynStore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 
8 #include "RootAuxDynStore.h"
10 
11 
13  long long entry, bool standalone, std::recursive_mutex* iomtx)
14  : SG::AuxStoreInternal( standalone ),
15  m_entry(entry),
16  m_iomutex(iomtx)
17 {
18  for( auto id : reader.auxIDs() ) {
19  addAuxID(id);
20  }
21  lock();
22 }
23 
24 
25 const void* RootAuxDynStore::getData(SG::auxid_t auxid) const
26 {
27  const SG::IAuxTypeVector* v = getVector( auxid );
28  if( v ) {
29  return v->toPtr();
30  }
31  return nullptr;
32 }
33 
34 
36 {
37  guard_t guard (m_mutex);
38  // lock
40  if (!ret) {
41  auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
42  if( this_nc->readData(auxid) ) {
43  ret = SG::AuxStoreInternal::getVector (auxid);
44  }
45  }
46  return ret;
47 }
48 
49 
50 void* RootAuxDynStore::getData(SG::auxid_t /*auxid*/, size_t /*size*/, size_t /*capacity*/)
51 {
52  // MN: how do we add new attributes to this store? A:for now we don't
53  throw("Non-const access to RootAuxDynStore is not supported");
54 }
55 
56 
57 const void* RootAuxDynStore::getIOData(SG::auxid_t auxid) const
58 {
59  guard_t guard (m_mutex);
60  const void* ret = SG::AuxStoreInternal::getIODataInternal (auxid, true);
61  if (!ret) {
62  auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
63  if( this_nc->readData(auxid) ) {
64  ret = SG::AuxStoreInternal::getIOData (auxid);
65  }
66  }
67  return ret;
68 }
69 
86 void*
87 RootAuxDynStore::getDecoration (SG::auxid_t auxid, size_t size, size_t capacity)
88 {
89  guard_t guard (m_mutex);
90  if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
92  {
93  throw SG::ExcStoreLocked (auxid);
94  }
95  return SG::AuxStoreInternal::getDecoration (auxid, size, capacity);
96 }
97 
98 
106 {
107  guard_t guard( m_mutex );
108  if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
110  {
111  return false;
112  }
113  return SG::AuxStoreInternal::isDecoration (auxid);
114 }
115 
121 size_t RootAuxDynStore::size() const
122 {
123  const std::size_t s = SG::AuxStoreInternal::size();
124  if( s != 0 ) {
125  return s;
126  }
127 
128  for( SG::auxid_t id : getAuxIDs() ) {
129  if( getData( id ) != nullptr ) {
131  }
132  }
133 
134  return 0;
135 }
SG::AuxStoreInternal::addAuxID
void addAuxID(auxid_t auxid)
Add a new auxid to the set of those being managed by this store.
Definition: AuxStoreInternal.cxx:676
RootAuxDynStore::isDecoration
virtual bool isDecoration(SG::auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
Definition: RootAuxDynStore.cxx:105
RootAuxDynStore::m_mutex
mutex_t m_mutex
Definition: RootAuxDynStore.h:67
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
SG::AuxStoreInternal::getDecoration
virtual void * getDecoration(auxid_t auxid, size_t size, size_t capacity) override
Return the data vector for one aux data decoration item.
Definition: AuxStoreInternal.cxx:198
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
L1CaloPhase1Monitoring.standalone
standalone
Definition: L1CaloPhase1Monitoring.py:120
SG::AuxStoreInternal::guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Definition: AuxStoreInternal.h:461
SG::ExcStoreLocked
Exception — Attempted to modify auxiliary data in a locked store.
Definition: Control/AthContainers/AthContainers/exceptions.h:183
exceptions.h
Exceptions that can be thrown from AthContainers.
RootAuxDynStore::size
virtual size_t size() const override
Return the number of elements in the store.
Definition: RootAuxDynStore.cxx:121
RootAuxDynStore::getDecoration
virtual void * getDecoration(SG::auxid_t auxid, size_t size, size_t capacity) override
Return the data vector for one aux data decoration item.
Definition: RootAuxDynStore.cxx:87
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
RootAuxDynStore
Definition: RootAuxDynStore.h:16
IAuxTypeVector.h
Abstract interface for manipulating vectors of arbitrary types.
SG::AuxStoreInternal::getAuxIDs
virtual const SG::auxid_set_t & getAuxIDs() const override
Return a set of identifiers for existing data items in this store.
Definition: AuxStoreInternal.cxx:400
RootAuxDynStore.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
SG::AuxStoreInternal::lock
virtual void lock() override
Lock the container.
Definition: AuxStoreInternal.cxx:564
SG::AuxStoreInternal::getIODataInternal
const void * getIODataInternal(auxid_t auxid, bool quiet) const
Return a pointer to the data to be stored for one aux data item.
Definition: AuxStoreInternal.cxx:450
RootAuxDynStore::getData
virtual const void * getData(SG::auxid_t auxid) const override
implementation of the IAuxStore interface
Definition: RootAuxDynStore.cxx:25
SG::AuxStoreInternal::size
virtual size_t size() const override
Return the number of elements in the store.
Definition: AuxStoreInternal.cxx:602
SG::AuxStoreInternal::getIOData
virtual const void * getIOData(SG::auxid_t auxid) const override
Return a pointer to the data to be stored for one aux data item.
Definition: AuxStoreInternal.cxx:515
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
RootAuxDynIO::IRootAuxDynReader
Definition: RootAuxDynIO.h:65
python.PyAthena.v
v
Definition: PyAthena.py:154
SG::AuxStoreInternal::getVector
virtual const IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
Definition: AuxStoreInternal.cxx:99
SG::AuxStoreInternal::isDecoration
virtual bool isDecoration(auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
Definition: AuxStoreInternal.cxx:420
SG::IAuxTypeVector
Abstract interface for manipulating vectors of arbitrary types.
Definition: IAuxTypeVector.h:42
RootAuxDynIO.h
RootAuxDynStore::getVector
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
Definition: RootAuxDynStore.cxx:35
RootAuxDynStore::getIOData
virtual const void * getIOData(SG::auxid_t auxid) const override
implementation of the IAuxStoreIO interface
Definition: RootAuxDynStore.cxx:57
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
collisions.reader
reader
read the goodrunslist xml file(s)
Definition: collisions.py:22
RootAuxDynStore::RootAuxDynStore
RootAuxDynStore(RootAuxDynIO::IRootAuxDynReader &reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
Definition: RootAuxDynStore.cxx:12