ATLAS Offline Software
RootAuxDynStore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #include "RootAuxDynStore.h"
9 
10 
12  long long entry, bool standalone, std::recursive_mutex* iomtx)
13  : SG::AuxStoreInternal( standalone ),
14  m_entry(entry),
15  m_iomutex(iomtx)
16 {
17  for( auto id : reader.auxIDs() ) {
18  addAuxID(id);
19  }
20  lock();
21 }
22 
23 
24 const void* RootAuxDynStore::getData(SG::auxid_t auxid) const
25 {
26  guard_t guard (m_mutex);
27  // lock
28  const void* ret = SG::AuxStoreInternal::getData (auxid);
29  if (!ret) {
30  auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
31  this_nc->readData(auxid);
33  }
34  return ret;
35 }
36 
37 
38 void* RootAuxDynStore::getData(SG::auxid_t /*auxid*/, size_t /*size*/, size_t /*capacity*/)
39 {
40  // MN: how do we add new attributes to this store? A:for now we don't
41  throw("Non-const access to RootAuxDynStore is not supported");
42 }
43 
44 
45 const void* RootAuxDynStore::getIOData(SG::auxid_t auxid) const
46 {
47  guard_t guard (m_mutex);
48  const void* ret = SG::AuxStoreInternal::getIODataInternal (auxid, true);
49  if (!ret) {
50  auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
51  this_nc->readData(auxid);
53  }
54  return ret;
55 }
56 
73 void*
74 RootAuxDynStore::getDecoration (SG::auxid_t auxid, size_t size, size_t capacity)
75 {
76  guard_t guard (m_mutex);
77  if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
79  {
80  throw SG::ExcStoreLocked (auxid);
81  }
82  return SG::AuxStoreInternal::getDecoration (auxid, size, capacity);
83 }
84 
85 
93 {
94  guard_t guard( m_mutex );
95  if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
97  {
98  return false;
99  }
100  return SG::AuxStoreInternal::isDecoration (auxid);
101 }
102 
108 size_t RootAuxDynStore::size() const
109 {
110  const std::size_t s = SG::AuxStoreInternal::size();
111  if( s != 0 ) {
112  return s;
113  }
114 
115  for( SG::auxid_t id : getAuxIDs() ) {
116  if( getData( id ) != nullptr ) {
118  }
119  }
120 
121  return 0;
122 }
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:650
RootAuxDynStore::isDecoration
virtual bool isDecoration(SG::auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
Definition: RootAuxDynStore.cxx:92
RootAuxDynStore::m_mutex
mutex_t m_mutex
Definition: RootAuxDynStore.h:66
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:182
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::AuxStoreInternal::getData
virtual const void * getData(SG::auxid_t auxid) const override
Return the data vector for one aux data item.
Definition: AuxStoreInternal.cxx:83
SG::AuxStoreInternal::guard_t
AthContainers_detail::lock_guard< mutex_t > guard_t
Definition: AuxStoreInternal.h:446
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:108
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:74
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
RootAuxDynStore
Definition: RootAuxDynStore.h:16
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:384
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
ret
T ret(T t)
Definition: rootspy.cxx:260
SG::AuxStoreInternal::lock
virtual void lock() override
Lock the container.
Definition: AuxStoreInternal.cxx:538
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:424
RootAuxDynStore::getData
virtual const void * getData(SG::auxid_t auxid) const override
implementation of the IAuxStore interface
Definition: RootAuxDynStore.cxx:24
SG::AuxStoreInternal::size
virtual size_t size() const override
Return the number of elements in the store.
Definition: AuxStoreInternal.cxx:576
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:489
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
RootAuxDynIO::IRootAuxDynReader
Definition: RootAuxDynIO.h:75
SG::AuxStoreInternal::isDecoration
virtual bool isDecoration(auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
Definition: AuxStoreInternal.cxx:394
RootAuxDynIO.h
RootAuxDynStore::readData
virtual bool readData(SG::auxid_t auxid)=0
read data from ROOT and store it in m_vecs. Returns False on error
RootAuxDynStore::getIOData
virtual const void * getIOData(SG::auxid_t auxid) const override
implementation of the IAuxStoreIO interface
Definition: RootAuxDynStore.cxx:45
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:11