ATLAS Offline Software
StoreGate/StoreGate/VarHandleKey.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4 */
13 #ifndef STOREGATE_VARHANDLEKEY_H
14 #define STOREGATE_VARHANDLEKEY_H
15 
16 
18 #include "AthenaKernel/StoreID.h"
19 #include "GaudiKernel/DataHandle.h"
20 #include "GaudiKernel/ServiceHandle.h"
21 
22 
23 namespace SG {
24 
25 
27  AllowEmpty = 1
28 };
29 
30 
31 class VarHandleBase;
32 class VarHandleKeyProperty;
33 
58  : public Gaudi::DataHandle
59 {
60 public:
61  constexpr static bool isDecorHandleKey = false;
62 
81  const std::string& sgkey,
83  const std::string& storeName = StoreID::storeName(StoreID::EVENT_STORE),
84  bool isCond = false);
85 
86 
91 
92 
105  VarHandleKey& operator= (const std::string& sgkey);
106 
107 
119  virtual StatusCode assign (const std::string& sgkey);
120 
121 
130  StatusCode initialize (bool used = true);
131 
132 
143 
144 
148  CLID clid() const;
149 
150 
154  const std::string& key() const;
155 
156 
160  bool empty() const;
161 
162 
167 
168 
177 
178 
182  bool isEventStore() const;
183 
184 
194  virtual StatusCode start();
195 
196 
203 
204 protected:
208  virtual std::string pythonRepr() const override;
209 
210 private:
212  friend class VarHandleBase;
214 
215 
217  virtual void setKey(DataObjID key) override final;
218  virtual void updateKey(std::string key) override final;
219 
220 
233  void parseKey (const std::string& sgkey, const std::string& storeName);
234 
235 
240  void updateHandle (const std::string& name);
241 
244 
246  std::string m_sgKey;
247 
250 
252  bool m_isEventStore = false;
253 
256 };
257 
258 
259 } // namespace SG
260 
261 namespace std {
262  ostream& operator<<(ostream& s, const SG::VarHandleKey& m);
263 }
264 
265 
267 
268 
269 #endif // not STOREGATE_VARHANDLEKEY_H
used
common.sgkey
def sgkey(tool)
Definition: common.py:1027
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
SG::VarHandleKey::m_isEventStore
bool m_isEventStore
Cache test for whether we're referencing the event store.
Definition: StoreGate/StoreGate/VarHandleKey.h:252
SG::VarHandleKey::storeHandle
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
SG::VarHandleBase
Base class for VarHandle types.
Definition: StoreGate/StoreGate/VarHandleBase.h:83
SG::VarHandleKey::m_storeHandle
ServiceHandle< IProxyDict > m_storeHandle
Handle to the referenced store.
Definition: StoreGate/StoreGate/VarHandleKey.h:243
SG::VarHandleKey::updateHandle
void updateHandle(const std::string &name)
Update the name of the store to which we're referring.
Definition: StoreGate/src/VarHandleKey.cxx:302
SG::VarHandleKey::m_hashedKey
SG::sgkey_t m_hashedKey
The hashed StoreGate key. May be 0 if not yet initialized.
Definition: StoreGate/StoreGate/VarHandleKey.h:249
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
SG::VarHandleKey::VarHandleKey
VarHandleKey(CLID clid, const std::string &sgkey, Gaudi::DataHandle::Mode a, const std::string &storeName=StoreID::storeName(StoreID::EVENT_STORE), bool isCond=false)
Constructor.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:38
SG::AllowEmptyEnum
AllowEmptyEnum
Definition: StoreGate/StoreGate/VarHandleKey.h:26
SG::VarHandleKey::pythonRepr
virtual std::string pythonRepr() const override
Python representation of Handle.
Definition: StoreGate/src/VarHandleKey.cxx:317
SG::VarHandleKey::setKey
virtual void setKey(DataObjID key) override final
Don't allow calling these.
Definition: StoreGate/src/VarHandleKey.cxx:194
VarHandleKey.icc
SG::VarHandleKey::assign
virtual StatusCode assign(const std::string &sgkey)
Change the key of the object to which we're referring.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:88
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::VarHandleKey::isEventStore
bool isEventStore() const
Does this key reference the primary event store?
SG::VarHandleKey::owningHandle
VarHandleBase * owningHandle()
Return the VarHandle that owns this key, if any.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CLID
uint32_t CLID
The Class ID type.
Definition: Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
SG::VarHandleKey::m_sgKey
std::string m_sgKey
StoreGate key, that doesn't include the storename.
Definition: StoreGate/StoreGate/VarHandleKey.h:246
StoreID.h
IProxyDict.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
SG::VarHandleKey::operator=
VarHandleKey & operator=(const std::string &sgkey)
Change the key of the object to which we're referring.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:68
EventContainers::Mode
Mode
Definition: IdentifiableContainerBase.h:13
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
SG::sgkey_t
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition: sgkey_t.h:32
SG::VarHandleKey::clid
CLID clid() const
Return the class ID for the referenced object.
Definition: StoreGate/src/VarHandleKey.cxx:185
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:59
SG::VarHandleKey::m_owningHandle
VarHandleBase * m_owningHandle
Handle that owns this key, or nullptr if it is not owned.
Definition: StoreGate/StoreGate/VarHandleKey.h:255
SG::VarHandleKey::parseKey
void parseKey(const std::string &sgkey, const std::string &storeName)
Handle assignment/construction from a string key.
Definition: StoreGate/src/VarHandleKey.cxx:225
a
TList * a
Definition: liststreamerinfos.cxx:10
SG::VarHandleKey::hashedKey
SG::sgkey_t hashedKey() const
Return the hashed StoreGate key.
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
SG::VarHandleKey::setOwningHandle
void setOwningHandle(VarHandleBase *handle)
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::VarHandleKey::updateKey
virtual void updateKey(std::string key) override final
Prevent this method from being called.
Definition: StoreGate/src/VarHandleKey.cxx:203
SG::VarHandleKeyProperty
VarHandleKeyProperty is the class which wraps a SG::VarHandleKey.
Definition: VarHandleKeyProperty.h:79
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:27
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77
SG::VarHandleKey::start
virtual StatusCode start()
Called by the owning algorithm during the START transition.
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
ServiceHandle< IProxyDict >
SG::VarHandleKey::isDecorHandleKey
constexpr static bool isDecorHandleKey
Definition: StoreGate/StoreGate/VarHandleKey.h:61