ATLAS Offline Software
Loading...
Searching...
No Matches
RootAuxDynStore.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
7#include "GaudiKernel/ThreadLocalContext.h"
8
9#include "RootAuxDynStore.h"
10#include "RootAuxDynReader.h"
11
12
14 long long entry, bool standalone, std::recursive_mutex* iomtx)
15 : SG::AuxStoreInternal( standalone ),
16 m_entry(entry),
17 m_ctx (Gaudi::Hive::currentContext()),
18 m_iomutex(iomtx)
19{
20 for( auto id : reader.auxIDs() ) {
21 addAuxID(id);
22 }
23 lock();
24}
25
26
27const void* RootAuxDynStore::getData(SG::auxid_t auxid) const
28{
29 const SG::IAuxTypeVector* v = getVector( auxid );
30 if( v ) {
31 return v->toPtr();
32 }
33 return nullptr;
34}
35
36
38{
39 guard_t guard (m_mutex);
40 // lock
41 const SG::IAuxTypeVector* ret = SG::AuxStoreInternal::getVector (auxid);
42 if (!ret) {
43 auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
44 if( this_nc->readData(auxid) ) {
45 ret = SG::AuxStoreInternal::getVector (auxid);
46 }
47 }
48 return ret;
49}
50
51
52void* RootAuxDynStore::getData(SG::auxid_t /*auxid*/, size_t /*size*/, size_t /*capacity*/)
53{
54 // MN: how do we add new attributes to this store? A:for now we don't
55 throw("Non-const access to RootAuxDynStore is not supported");
56}
57
58
60{
61 guard_t guard (m_mutex);
62 const void* ret = SG::AuxStoreInternal::getIODataInternal (auxid, true);
63 if (!ret) {
64 auto this_nc ATLAS_THREAD_SAFE = const_cast<RootAuxDynStore*>(this); // locked above
65 if( this_nc->readData(auxid) ) {
66 ret = SG::AuxStoreInternal::getIOData (auxid);
67 }
68 }
69 return ret;
70}
71
88void*
89RootAuxDynStore::getDecoration (SG::auxid_t auxid, size_t size, size_t capacity)
90{
91 guard_t guard (m_mutex);
92 if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
93 SG::AuxStoreInternal::getAuxIDs().count (auxid) > 0)
94 {
95 throw SG::ExcStoreLocked (auxid);
96 }
97 return SG::AuxStoreInternal::getDecoration (auxid, size, capacity);
98}
99
100
108{
109 guard_t guard( m_mutex );
110 if (SG::AuxStoreInternal::getIODataInternal (auxid, true) == 0 &&
111 SG::AuxStoreInternal::getAuxIDs().count (auxid) > 0)
112 {
113 return false;
114 }
115 return SG::AuxStoreInternal::isDecoration (auxid);
116}
117
124{
125 const std::size_t s = SG::AuxStoreInternal::size();
126 if( s != 0 ) {
127 return s;
128 }
129
130 for( SG::auxid_t id : getAuxIDs() ) {
131 if( getData( id ) != nullptr ) {
132 return SG::AuxStoreInternal::size();
133 }
134 }
135
136 return 0;
137}
Exceptions that can be thrown from AthContainers.
Abstract interface for manipulating vectors of arbitrary types.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
#define ATLAS_THREAD_SAFE
AthContainers_detail::lock_guard< mutex_t > guard_t
RootAuxDynStore(RootAuxDynReader &reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
virtual const void * getIOData(SG::auxid_t auxid) const override
implementation of the IAuxStoreIO interface
virtual const void * getData(SG::auxid_t auxid) const override
implementation of the IAuxStore interface
virtual void * getDecoration(SG::auxid_t auxid, size_t size, size_t capacity) override
Return the data vector for one aux data decoration item.
virtual size_t size() const override
Return the number of elements in the store.
std::recursive_mutex * m_iomutex
Optional mutex used to serialize I/O with RootStorageSvc (not owned).
virtual bool isDecoration(SG::auxid_t auxid) const override
Test if a particular variable is tagged as a decoration.
virtual const SG::IAuxTypeVector * getVector(SG::auxid_t auxid) const override
const EventContext & m_ctx
Event context associated with the event store.
Exception — Attempted to modify auxiliary data in a locked store.
Abstract interface for manipulating vectors of arbitrary types.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
=============================================================================
Forward declaration.
size_t auxid_t
Identifier for a particular aux data item.
Definition AuxTypes.h:27