ATLAS Offline Software
Loading...
Searching...
No Matches
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-2026 CERN for the benefit of the ATLAS collaboration
4*/
11
12
13#ifndef STOREGATE_VARHANDLEKEY_H
14#define STOREGATE_VARHANDLEKEY_H
15
16
19#include "GaudiKernel/DataHandle.h"
20#include "GaudiKernel/ServiceHandle.h"
21#include <format>
22#include <concepts>
23
24
25namespace SG {
26
27
31
32
33class VarHandleBase;
34class VarHandleKeyProperty;
35
60 : public Gaudi::DataHandle
61{
62public:
63 constexpr static bool isDecorHandleKey = false;
64
83 const std::string& sgkey,
84 Gaudi::DataHandle::Mode a,
85 const std::string& storeName = StoreID::storeName(StoreID::EVENT_STORE),
86 bool isCond = false);
87
88
93
94
107 VarHandleKey& operator= (const std::string& sgkey);
108
109
121 virtual StatusCode assign (const std::string& sgkey);
122
123
132 StatusCode initialize (bool used = true);
133
134
144 StatusCode initialize (AllowEmptyEnum);
145
146
150 CLID clid() const;
151
152
156 const std::string& key() const;
157
158
162 bool empty() const;
163
164
169
170
179
180
184 bool isEventStore() const;
185
186
196 virtual StatusCode start();
197
198
205
206protected:
210 virtual std::string pythonRepr() const override;
211
212private:
214 friend class VarHandleBase;
216
217
219 virtual void setKey(DataObjID key) override final;
220 virtual void updateKey(std::string key) override final;
221
222
235 void parseKey (const std::string& sgkey, const std::string& storeName);
236
237
242 void updateHandle (const std::string& name);
243
246
248 std::string m_sgKey;
249
252
254 bool m_isEventStore = false;
255
258};
259
260
261std::ostream& operator<<(std::ostream& s, const SG::VarHandleKey& m);
262
263
264} // namespace SG
265
266
267namespace std {
268
269
270// C++23 compatible formatter.
271template <std::derived_from<SG::VarHandleKey> T>
272struct formatter<T>
273 : public formatter<string_view>
274{
275 template <class FmtContext>
276 FmtContext::iterator format(const T& k, FmtContext& ctx) const;
277};
278
279
280} // namespace std
281
282
284
285
286#endif // not STOREGATE_VARHANDLEKEY_H
uint32_t CLID
The Class ID type.
static Double_t a
VarHandleKeyProperty is the class which wraps a SG::VarHandleKey.
A property holding a SG store/key/clid from which a VarHandle is made.
virtual void setKey(DataObjID key) override final
Don't allow calling these.
virtual void updateKey(std::string key) override final
Prevent this method from being called.
virtual std::string pythonRepr() const override
Python representation of Handle.
friend class VarHandleBase
Set the owning handle. Only callable from VarHandleBase.
static constexpr bool isDecorHandleKey
void parseKey(const std::string &sgkey, const std::string &storeName)
Handle assignment/construction from a string key.
VarHandleKey & operator=(const std::string &sgkey)
Change the key of the object to which we're referring.
SG::sgkey_t m_hashedKey
The hashed StoreGate key. May be 0 if not yet initialized.
CLID clid() const
Return the class ID for the referenced object.
ServiceHandle< IProxyDict > m_storeHandle
Handle to the referenced store.
bool isEventStore() const
Does this key reference the primary event store?
void setOwningHandle(VarHandleBase *handle)
const std::string & key() const
Return the StoreGate ID for the referenced object.
virtual StatusCode assign(const std::string &sgkey)
Change the key of the object to which we're referring.
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
SG::VarHandleKeyProperty PropertyType
Declare corresponding property type.
VarHandleBase * owningHandle()
Return the VarHandle that owns this key, if any.
VarHandleBase * m_owningHandle
Handle that owns this key, or nullptr if it is not owned.
std::string m_sgKey
StoreGate key, that doesn't include the storename.
virtual StatusCode start()
Called by the owning algorithm during the START transition.
bool m_isEventStore
Cache test for whether we're referencing the event store.
VarHandleKey(CLID clid, const std::string &sgkey, Gaudi::DataHandle::Mode a, const std::string &storeName=StoreID::storeName(StoreID::EVENT_STORE), bool isCond=false)
Constructor.
SG::sgkey_t hashedKey() const
Return the hashed StoreGate key.
bool empty() const
Test if the key is blank.
void updateHandle(const std::string &name)
Update the name of the store to which we're referring.
@ EVENT_STORE
Definition StoreID.h:26
static const std::string & storeName(const StoreID::type &s)
Definition StoreID.cxx:77
holding In fact this class is here in order to allow STL container for all features This class is sho...
Forward declaration.
uint32_t sgkey_t
Type used for hashed StoreGate key+CLID pairs.
Definition sgkey_t.h:32
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
STL namespace.
void initialize()
FmtContext::iterator format(const T &k, FmtContext &ctx) const