ATLAS Offline Software
View.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHVIEWS_VIEW_H
6 #define ATHVIEWS_VIEW_H
7 
8 #include "GaudiKernel/ServiceHandle.h"
9 
10 #include "AthenaKernel/CLASS_DEF.h"
13 #include "AthLinks/ElementLink.h"
14 #include "CxxUtils/sgkey_t.h"
16 #include "SGTools/transientKey.h"
17 #include "StoreGate/StoreGateSvc.h"
19 
20 #include <set>
21 #include <vector>
22 
23 // Forward declarations
24 namespace SG {
25  class DataProxy;
26 }
27 class DataObject;
28 
29 
30 namespace SG {
31 
46  class View final : public implements<IProxyDict> {
47  public:
55  View( const std::string& name, int index, bool allowFallThrough = true,
56  const std::string& storeName = "StoreGateSvc" );
57 
58  View() = delete;
59  virtual ~View() = default;
60  View (const View&) = delete;
61  View& operator= (const View&) = delete;
62 
66  size_t viewID() const {
67  return m_index;
68  }
69 
73  void linkParent( const IProxyDict* parent );
74 
78  const std::set< const SG::View* >& getParentLinks() const {
79  return m_parents;
80  }
81 
86  void setFilter( std::vector< std::string > const& inputFilter ) {
87  m_fallFilter = inputFilter;
88  }
89 
94  m_roi = roi;
95  }
96 
101  return m_roi;
102  }
103 
107  std::string dump( const std::string& indent = "" ) const;
108 
109 
117  virtual const std::string& name() const override {
118  return m_name;
119  }
120 
128  virtual SG::DataProxy* proxy_exact(SG::sgkey_t sgkey) const override;
129 
143  virtual SG::DataProxy* proxy(const CLID& id, const std::string& key) const override;
144 
151  virtual SG::DataProxy* proxy(const void* const pTransient) const override {
152  return m_store->proxy( pTransient );
153  }
154 
158  virtual std::vector<const SG::DataProxy*> proxies() const override {
159  return m_store->proxies();
160  }
161 
172  virtual StatusCode addToStore(CLID id, SG::DataProxy* proxy) override {
173  return m_store->addToStore( id, proxy );
174  }
175 
188  const std::string& key,
189  bool allowMods,
190  bool returnExisting) override;
191 
196  virtual void boundHandle (IResetable* handle) override {
197  return m_store->boundHandle( handle );
198  }
199 
204  virtual void unboundHandle (IResetable* handle) override {
205  return m_store->unboundHandle( handle );
206  }
207 
218  virtual bool tryELRemap ( sgkey_t sgkey_in, size_t index_in,
219  sgkey_t& sgkey_out, size_t& index_out) override;
232  virtual const std::string* keyToString( IStringPool::sgkey_t key ) const override;
233 
239  virtual const std::string* keyToString( IStringPool::sgkey_t key, CLID& clid ) const override;
240 
244  virtual IStringPool::sgkey_t stringToKey( const std::string& str, CLID clid ) override {
245  return m_store->stringToKey( viewKey(str), clid );
246  }
247 
251  virtual void registerKey( IStringPool::sgkey_t key, const std::string& str, CLID clid ) override {
252  m_store->registerKey( key, viewKey(str), clid );
253  }
257  private:
261  SG::DataProxy* findProxy( const CLID& id, const std::string& key, bool allowFallThrough ) const;
262 
267  std::string viewKey (const std::string& key) const {
268  return SG::transientKey (m_name + "_" + key);
269  }
270 
273 
276 
277  std::set< const SG::View* > m_parents;
278  std::vector< std::string > m_fallFilter;
279 
280  std::string m_name;
281  size_t m_index{0};
282  bool m_allowFallThrough{true};
283  };
284 } // namespace SG
285 
286 
291 
292 CLASS_DEF( ViewContainer , 1160627009 , 1 )
293 
294 #endif
common.sgkey
def sgkey(tool)
Definition: common.py:1027
SG::View::m_parents
std::set< const SG::View * > m_parents
Definition: View.h:277
SG::View::operator=
View & operator=(const View &)=delete
SG::View::m_allowFallThrough
bool m_allowFallThrough
Definition: View.h:282
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::View::addToStore
virtual StatusCode addToStore(CLID id, SG::DataProxy *proxy) override
Add a new proxy to the store.
Definition: View.h:172
SG::View::m_name
std::string m_name
Definition: View.h:280
index
Definition: index.py:1
SG::View::View
View(const View &)=delete
SG::View::proxy
virtual SG::DataProxy * proxy(const void *const pTransient) const override
Get a proxy referencing a given transient object.
Definition: View.h:151
ViewContainer
DataVector< SG::View > ViewContainer
View container for recording in StoreGate.
Definition: View.h:290
SG::View::recordObject
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting) override
Record an object in the store.
Definition: View.cxx:57
SG::View::getROI
const ElementLink< TrigRoiDescriptorCollection > & getROI() const
Return associated RoI.
Definition: View.h:100
SG::View::~View
virtual ~View()=default
IStringPool::sgkey_t
SG::sgkey_t sgkey_t
Type of the keys.
Definition: IStringPool.h:34
IProxyDict
A proxy dictionary.
Definition: AthenaKernel/AthenaKernel/IProxyDict.h:47
transientKey.h
SG::View::m_keyMap
KeyMap_t m_keyMap
Definition: View.h:275
SG::View::linkParent
void linkParent(const IProxyDict *parent)
Link to the previously used views.
Definition: View.cxx:35
IResetable
a resetable object (e.g. a SG DataHandle)
Definition: IResetable.h:15
SG::View::View
View()=delete
SG::View::m_roi
ElementLink< TrigRoiDescriptorCollection > m_roi
Definition: View.h:272
geometry_dat_to_json.indent
indent
Definition: geometry_dat_to_json.py:37
SG::View::registerKey
virtual void registerKey(IStringPool::sgkey_t key, const std::string &str, CLID clid) override
Remember an additional mapping from key to string/CLID.
Definition: View.h:251
SG::View::viewID
size_t viewID() const
Return view index.
Definition: View.h:66
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::View::name
virtual const std::string & name() const override
Name of the view.
Definition: View.h:117
SG::View::tryELRemap
virtual bool tryELRemap(sgkey_t sgkey_in, size_t index_in, sgkey_t &sgkey_out, size_t &index_out) override
Test to see if the target of an ElementLink has moved.
Definition: View.cxx:193
DataProxy
DataProxy provides the registry services for StoreGate.
Definition: DataProxy.h:32
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SG::View::keyToString
virtual const std::string * keyToString(IStringPool::sgkey_t key) const override
Find the string and CLID corresponding to a given key.
Definition: View.cxx:203
SG::View::setFilter
void setFilter(std::vector< std::string > const &inputFilter)
Set a filtering rule for anything loaded via fall-through.
Definition: View.h:86
SG::View::unboundHandle
virtual void unboundHandle(IResetable *handle) override
Tell the store that a handle has been unbound from a proxy.
Definition: View.h:204
SG::ConcurrentSGKeyMap
CxxUtils::ConcurrentMap< sgkey_t, T, CxxUtils::SimpleUpdater, SGKeyHash, SGKeyEqual, 0, s_sgkey_nullval > ConcurrentSGKeyMap
A concurrent map using sgkey_t as key.
Definition: sgkey_utilities.h:33
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
columnar::final
CM final
Definition: ColumnAccessor.h:106
sgkey_utilities.h
Additional utilities and types related to sgkey_t.
IProxyDict.h
SG::View::proxy
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const override
Get proxy with given id and key.
Definition: View.cxx:112
SG::View::proxy_exact
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const override
Get proxy given a hashed key+clid.
Definition: View.cxx:90
SG::View::boundHandle
virtual void boundHandle(IResetable *handle) override
Tell the store that a handle has been bound to a proxy.
Definition: View.h:196
SG::View::dump
std::string dump(const std::string &indent="") const
Print content of the view.
Definition: View.cxx:164
SG::View::getParentLinks
const std::set< const SG::View * > & getParentLinks() const
Returns the links to the previously used views.
Definition: View.h:78
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: CxxUtils/CxxUtils/sgkey_t.h:32
DataVector.h
An STL vector of pointers that by default owns its pointed-to elements.
SG::View::stringToKey
virtual IStringPool::sgkey_t stringToKey(const std::string &str, CLID clid) override
Find the key for a string/CLID pair.
Definition: View.h:244
sgkey_t.h
Define the type used for hashed StoreGate key+CLID pairs.
SG::View::proxies
virtual std::vector< const SG::DataProxy * > proxies() const override
Return the list of all current proxies in store.
Definition: View.h:158
SG::View::KeyMap_t
SG::ConcurrentSGKeyMap< sgkey_t > KeyMap_t
Definition: View.h:274
SG::View::viewKey
std::string viewKey(const std::string &key) const
Construct a key as used in the parent store.
Definition: View.h:267
SG::View::m_fallFilter
std::vector< std::string > m_fallFilter
Definition: View.h:278
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:67
SG::View::m_store
ServiceHandle< StoreGateSvc > m_store
Definition: View.h:271
SG::transientKey
std::string transientKey(const std::string &key)
Make a key transient.
Definition: transientKey.h:51
SG::View::findProxy
SG::DataProxy * findProxy(const CLID &id, const std::string &key, bool allowFallThrough) const
Internal implementation of proxy()
Definition: View.cxx:121
str
Definition: BTagTrackIpAccessor.cxx:11
SG::DataObjectSharedPtr
Smart pointer to manage DataObject reference counts.
Definition: DataObjectSharedPtr.h:45
SG::View::setROI
void setROI(const ElementLink< TrigRoiDescriptorCollection > &roi)
Associated RoI with this view.
Definition: View.h:93
SG::View
A "view" of the event store (IProxyDict).
Definition: View.h:46
python.PyAthena.obj
obj
Definition: PyAthena.py:132
SG::DataProxy
Definition: DataProxy.h:45
StoreGateSvc.h
CLASS_DEF.h
macros to associate a CLID to a type
TrigRoiDescriptorCollection.h
SG::View::m_index
size_t m_index
Definition: View.h:281
ServiceHandle< StoreGateSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37