ATLAS Offline Software
Loading...
Searching...
No Matches
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
24namespace 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 >
140 StatusCode record( ConstDataVector< T >* obj, const std::string& key,
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
DataVector adapter that acts like it holds const pointers.
Base class for the event (xAOD::TEvent and xAOD::REvent) classes.
Definition Event.h:59
Tool for accessing xAOD files outside of Athena.
This class takes care of holding EDM objects in memory.
Definition THolder.h:35
void keys(std::vector< std::string > &vkeys) const
provide a list of keys associated with a type
StatusCode record(std::unique_ptr< const T > obj, const std::string &key)
Add a const object to the store, explicitly taking ownership of it.
StatusCode remove(const std::string &key)
Remove an object from the store by name.
Definition TStore.cxx:57
StatusCode record_impl(T *obj, const std::string &key, ::Bool_t isOwner, ::Bool_t isConst)
Internal implementation of the templated record method.
SG::SGKeyMap< std::string > HashedKeys_t
Type of the internal storage for the hashed keys of the object names.
Definition TStore.h:166
void setActive()
Set this as the active transient store in the application.
Definition TStore.cxx:43
void print() const
Print the current contents of the transient store.
Definition TStore.cxx:124
friend class Event
Definition TStore.h:49
StatusCode retrieve(const T *&obj, const std::string &key) const
Retrieve either a constant or non-constant object from the store.
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
void clear()
Clear the store of all of its contents.
Definition TStore.cxx:105
virtual ~TStore()
Destructor.
Definition TStore.cxx:30
StatusCode record(T *obj, const std::string &key)
Add an object to the store.
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
const std::string & getName(SG::sgkey_t hash) const
Get the name corresponding to a hashed key.
Definition TStore.cxx:366
friend class TEvent
Make TEvent a friend of this class.
Definition TStore.h:48
StatusCode record(std::unique_ptr< T > obj, const std::string &key)
Add an object to the store, explicitly taking ownership of it.
HashedKeys_t m_keys
The key map.
Definition TStore.h:171
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
std::map< std::string, THolder * > Objects_t
Type of the internal container storing all the objects.
Definition TStore.h:164
TStore & operator=(const TStore &)=delete
Disallow copying the object.
const THolder * holder(const std::string &key) const
return holder for key
Definition TStore.cxx:50
TStore(const TStore &)=delete
Disallow copying the object.
StatusCode retrieve(T *&obj, const std::string &key) const
Retrieve a non-constant object from the store.
::Bool_t contains(const std::string &key) const
Function checking if an object is available from the store.
Objects_t m_objects
The object storage.
Definition TStore.h:169
StatusCode record(const T *obj, const std::string &key)
Add a const object to the store.
TStore()
Default constructor.
Definition TStore.cxx:24
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.
::Bool_t isConst(const std::string &key) const
Function checking if an object with a given type is constant.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
std::unordered_map< sgkey_t, T > SGKeyMap
A map using sgkey_t as a key.
Definition sgkey_t.h:93
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.