ATLAS Offline Software
TStore.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef XAODROOTACCESS_TSTORE_H
6 #define XAODROOTACCESS_TSTORE_H
7 
8 // System include(s):
9 #include <string>
10 #include <map>
11 #include <memory>
12 #include <vector>
13 
14 // ROOT include(s):
15 #include <Rtypes.h>
16 
17 // EDM include(s):
19 #include "SGCore/sgkey_t.h"
20 
21 // Local include(s):
23 
24 namespace xAOD {
25 
26  // Forward declaration(s):
27  class THolder;
28  class TEvent;
29  class Event;
30 
45  class TStore {
46 
48  friend class TEvent;
49  friend class Event;
50 
51  public:
53  TStore();
55  TStore( const TStore& ) = delete;
57  virtual ~TStore();
58 
60  TStore& operator=( const TStore& ) = delete;
61 
63  void setActive();
64 
67 
69  template< typename T >
70  ::Bool_t contains( const std::string& key ) const;
71 
73  template< typename T >
74  ::Bool_t isConst( const std::string& key ) const;
75 
77  template< typename T >
78  StatusCode retrieve( const T*& obj, const std::string& key ) const;
80  template< typename T >
81  StatusCode retrieve( T*& obj, const std::string& key ) const;
82 
84  template< typename T >
85  StatusCode record( T* obj, const std::string& key );
87  template< typename T >
88  StatusCode record( std::unique_ptr< T > obj, const std::string& key );
89 
91  template< typename T >
92  StatusCode record( const T* obj, const std::string& key );
94  template< typename T >
95  StatusCode record( std::unique_ptr< const T > obj, const std::string& key );
96 
98  template< typename T >
99  void keys( std::vector< std::string >& vkeys ) const;
100 
102  const THolder* holder( const std::string& key ) const;
103 
105  StatusCode remove( const std::string& key );
107  StatusCode remove( void* ptr );
108 
110  void clear();
111 
113 
115  void print() const;
116 
117  protected:
119  ::Bool_t contains( const std::string& key,
120  const std::type_info& ti ) const;
122  ::Bool_t isConst( const std::string& key,
123  const std::type_info& ti ) const;
125  void* getObject( const std::string& key, const std::type_info& ti ) const;
127  const void* getConstObject( const std::string& key,
128  const std::type_info& ti ) const;
130  StatusCode record( void* obj, const std::string& key,
131  const std::string& classname,
132  ::Bool_t isOwner, ::Bool_t isConst );
134  StatusCode record( void* obj, const std::string& key,
135  const std::type_info& ti,
136  ::Bool_t isOwner, ::Bool_t isConst );
137 
139  template< class T >
141  const std::type_info& ti,
142  ::Bool_t isOwner, ::Bool_t isConst );
144  StatusCode record( THolder* hldr, const std::string& key );
145 
148 
150  ::Bool_t contains( SG::sgkey_t hash ) const;
152  ::Bool_t contains( const void* ptr ) const;
154  const std::string& getName( SG::sgkey_t hash ) const;
156  const std::string& getName( const void* ptr ) const;
158  void getNames(const std::string& targetClassName,
159  std::vector<std::string>& vkeys ) const;
160 
162 
164  typedef std::map< std::string, THolder* > Objects_t;
167 
172 
173  private:
175  template< typename T >
176  StatusCode record_impl( T* obj, const std::string& key,
177  ::Bool_t isOwner, ::Bool_t isConst );
178 
179  }; // class TStore
180 
181 } // namespace xAOD
182 
183 // Include the template implementation.
184 #include "TStore.icc"
185 
186 #endif // XAODROOTACCESS_TSTORE_H
xAOD::TStore::~TStore
virtual ~TStore()
Destructor.
Definition: TStore.cxx:30
xAOD::TStore::m_keys
HashedKeys_t m_keys
The key map.
Definition: TStore.h:171
xAOD::TStore::holder
const THolder * holder(const std::string &key) const
return holder for key
Definition: TStore.cxx:50
TStore.icc
ConstDataVector.h
DataVector adapter that acts like it holds const pointers.
xAOD::THolder
This class takes care of holding EDM objects in memory.
Definition: THolder.h:35
Event
Definition: trigbs_orderedMerge.cxx:42
xAOD::TStore::record
StatusCode record(const T *obj, const std::string &key)
Add a const object to the store.
xAOD::TStore::retrieve
StatusCode retrieve(const T *&obj, const std::string &key) const
Retrieve either a constant or non-constant object from the store.
xAOD::TStore::getName
const std::string & getName(SG::sgkey_t hash) const
Get the name corresponding to a hashed key.
Definition: TStore.cxx:366
xAOD::TStore::record
StatusCode record(std::unique_ptr< const T > obj, const std::string &key)
Add a const object to the store, explicitly taking ownership of it.
xAOD::TStore::setActive
void setActive()
Set this as the active transient store in the application.
Definition: TStore.cxx:43
xAOD::TStore::Objects_t
std::map< std::string, THolder * > Objects_t
Type of the internal container storing all the objects.
Definition: TStore.h:164
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
xAOD::TStore::clear
void clear()
Clear the store of all of its contents.
Definition: TStore.cxx:105
xAOD::TStore::record
StatusCode record(std::unique_ptr< T > obj, const std::string &key)
Add an object to the store, explicitly taking ownership of it.
xAOD::TStore::contains
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.
xAOD::TStore::TStore
TStore(const TStore &)=delete
Disallow copying the object.
xAOD::TStore::record
StatusCode record(ConstDataVector< T > *obj, const std::string &key, const std::type_info &ti, ::Bool_t isOwner, ::Bool_t isConst)
Function doing the first step of recording a ConstDataVector object.
xAOD::TStore::isConst
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
sgkey_t.h
xAOD::TStore::retrieve
StatusCode retrieve(T *&obj, const std::string &key) const
Retrieve a non-constant object from the store.
xAOD::TStore::record_impl
StatusCode record_impl(T *obj, const std::string &key, ::Bool_t isOwner, ::Bool_t isConst)
Internal implementation of the templated record method.
xAOD::TStore::remove
StatusCode remove(const std::string &key)
Remove an object from the store by name.
Definition: TStore.cxx:57
xAOD::TStore::HashedKeys_t
SG::SGKeyMap< std::string > HashedKeys_t
Type of the internal storage for the hashed keys of the object names.
Definition: TStore.h:166
xAOD::TStore::getObject
void * getObject(const std::string &key, const std::type_info &ti) const
Function retrieving a non-const object in a non-template way.
Definition: TStore.cxx:191
StatusCode.h
xAOD::TStore::m_objects
Objects_t m_objects
The object storage.
Definition: TStore.h:169
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: sgkey_t.h:32
xAOD::TStore::print
void print() const
Print the current contents of the transient store.
Definition: TStore.cxx:124
xAOD::TStore::getConstObject
const void * getConstObject(const std::string &key, const std::type_info &ti) const
Function retrieving a const object in a non-template way.
Definition: TStore.cxx:211
xAOD::TStore
A relatively simple transient store for objects created in analysis.
Definition: TStore.h:45
xAOD::TStore::record
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
xAOD::TStore::operator=
TStore & operator=(const TStore &)=delete
Disallow copying the object.
ConstDataVector< T >
xAOD::TStore::keys
void keys(std::vector< std::string > &vkeys) const
provide a list of keys associated with a type
SG::SGKeyMap
std::unordered_map< sgkey_t, T > SGKeyMap
A map using sgkey_t as a key.
Definition: sgkey_t.h:93
xAOD::TStore::getNames
void getNames(const std::string &targetClassName, std::vector< std::string > &vkeys) const
Function determining the list keys associated with a type name.
Definition: TStore.cxx:409
xAOD::Event
Base class for the event (xAOD::TEvent and xAOD::REvent) classes.
Definition: Event.h:59
python.PyAthena.obj
obj
Definition: PyAthena.py:132
xAOD::TStore::TStore
TStore()
Default constructor.
Definition: TStore.cxx:24
xAOD::TEvent
Tool for accessing xAOD files outside of Athena.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:85
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37