ATLAS Offline Software
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
SG::WriteCondHandleKey< T > Class Template Reference

#include <WriteCondHandleKey.h>

Inheritance diagram for SG::WriteCondHandleKey< T >:
Collaboration diagram for SG::WriteCondHandleKey< T >:

Public Types

using PropertyType = SG::VarHandleKeyProperty
 Declare corresponding property type. More...
 

Public Member Functions

 WriteCondHandleKey (const std::string &key, const std::string &dbKey)
 Constructor for WriteCondHandle @key StoreGate key @dbKey key in the database. More...
 
 WriteCondHandleKey (const std::string &key)
 Constructor for WriteCondHandle that takes just a SG key @key StoreGate key. More...
 
template<class OWNER , typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
 WriteCondHandleKey (OWNER *owner, std::string name, const std::string &key={}, std::string doc="")
 auto-declaring Property Constructor. More...
 
StatusCode initialize (bool used=true)
 
StatusCode initialize (AllowEmptyEnum)
 
const std::string & dbKey () const
 
void setDbKey (const std::string &dbKey)
 
virtual StatusCode start () override
 Called by the owning algorithm during the START transition. More...
 
virtual StatusCode assign (const std::string &sgkey)
 Change the key of the object to which we're referring. More...
 
CLID clid () const
 Return the class ID for the referenced object. More...
 
const std::string & key () const
 Return the StoreGate ID for the referenced object. More...
 
bool empty () const
 Test if the key is blank. More...
 
const ServiceHandle< IProxyDict > & storeHandle () const
 Return handle to the referenced store. More...
 
VarHandleBaseowningHandle ()
 Return the VarHandle that owns this key, if any. More...
 
bool isEventStore () const
 Does this key reference the primary event store? More...
 
SG::sgkey_t hashedKey () const
 Return the hashed StoreGate key. More...
 

Protected Member Functions

bool isInit () const
 
CondCont< T > *getCC ATLAS_NOT_CONST_THREAD_SAFE () const
 
StoreGateSvcgetCS () const
 
virtual std::string pythonRepr () const override
 Python representation of Handle. More...
 

Private Member Functions

void setOwningHandle (VarHandleBase *handle)
 
virtual void setKey (DataObjID key) override final
 Don't allow calling these. More...
 
virtual void updateKey (std::string key) override final
 Prevent this method from being called. More...
 
void parseKey (const std::string &sgkey, const std::string &storeName)
 Handle assignment/construction from a string key. More...
 
void updateHandle (const std::string &name)
 Update the name of the store to which we're referring. More...
 

Private Attributes

ServiceHandle< StoreGateSvcm_cs
 
CondCont< T > * m_cc {0}
 
std::string m_dbKey {""}
 
bool m_isInit {false}
 
ServiceHandle< IProxyDictm_storeHandle
 Handle to the referenced store. More...
 
std::string m_sgKey
 StoreGate key, that doesn't include the storename. More...
 
SG::sgkey_t m_hashedKey = 0
 The hashed StoreGate key. May be 0 if not yet initialized. More...
 
bool m_isEventStore = false
 Cache test for whether we're referencing the event store. More...
 
VarHandleBasem_owningHandle = nullptr
 Handle that owns this key, or nullptr if it is not owned. More...
 

Friends

class WriteCondHandle< T >
 

Detailed Description

template<class T>
class SG::WriteCondHandleKey< T >

Definition at line 18 of file WriteCondHandleKey.h.

Member Typedef Documentation

◆ PropertyType

Declare corresponding property type.

Definition at line 91 of file StoreGate/StoreGate/VarHandleKey.h.

Constructor & Destructor Documentation

◆ WriteCondHandleKey() [1/3]

template<class T >
SG::WriteCondHandleKey< T >::WriteCondHandleKey ( const std::string &  key,
const std::string &  dbKey 
)
inline

Constructor for WriteCondHandle @key StoreGate key @dbKey key in the database.

Definition at line 31 of file WriteCondHandleKey.h.

31  :
32  CondHandleKey<T>(key, dbKey, Gaudi::DataHandle::Writer)
33  {}

◆ WriteCondHandleKey() [2/3]

template<class T >
SG::WriteCondHandleKey< T >::WriteCondHandleKey ( const std::string &  key)
inline

Constructor for WriteCondHandle that takes just a SG key @key StoreGate key.

the value of the dbKey is the same as the StoreGate key

Definition at line 41 of file WriteCondHandleKey.h.

41  :
42  CondHandleKey<T>(key, key, Gaudi::DataHandle::Writer)
43  {}

◆ WriteCondHandleKey() [3/3]

template<class T >
template<class OWNER , typename = typename std::enable_if<std::is_base_of<IProperty, OWNER>::value>::type>
SG::WriteCondHandleKey< T >::WriteCondHandleKey ( OWNER *  owner,
std::string  name,
const std::string &  key = {},
std::string  doc = "" 
)
inline

auto-declaring Property Constructor.

Parameters
namename of the Property
keydefault StoreGate key for the object.
docdocumentation string

will associate the named Property with this RHK via declareProperty

The provided key may actually start with the name of the store, separated by a "+": "MyStore+Obj". If no "+" is present the store named by storeName is used.

Definition at line 60 of file WriteCondHandleKey.h.

62  {},
63  std::string doc="") :
64  WriteCondHandleKey<T>(key) {
65  auto p = owner->declareProperty(std::move(name), *this, std::move(doc));
66  p->template setOwnerType<OWNER>();
67  }

Member Function Documentation

◆ assign()

StatusCode SG::VarHandleKey::assign ( const std::string &  sgkey)
virtualinherited

Change the key of the object to which we're referring.

Parameters
sgkeyThe StoreGate key for the object.

The provided key may actually start with the name of the store, separated by a "+": "MyStore+Obj". If no "+" is present the store is not changed. A key name that starts with a slash is interpreted as a hierarchical key name, not an empty store name.

Returns failure the key string format is bad.

Reimplemented in SG::WriteDecorHandleKey< T >, SG::WriteDecorHandleKey< xAOD::ElectronContainer >, SG::WriteDecorHandleKey< DMTest::CVecWithData_v1 >, SG::WriteDecorHandleKey< DMTest::JVec_v1 >, SG::WriteDecorHandleKey< DataVector >, SG::WriteDecorHandleKey< xAOD::EventInfo >, SG::WriteDecorHandleKey< C >, SG::WriteDecorHandleKey< DMTest::PLinks_v1 >, SG::WriteDecorHandleKey< xAOD::TrackParticleContainer >, SG::WriteDecorHandleKey< NEW >, SG::WriteDecorHandleKey< xAOD::EventInfo_v1 >, SG::WriteDecorHandleKey< CONTAINER >, SG::WriteDecorHandleKey< MyDataObj >, SG::WriteDecorHandleKey< T_RoIContainer >, SG::WriteDecorHandleKey< DMTest::C_v1 >, SG::WriteDecorHandleKey< container_t >, SG::WriteDecorHandleKey< SG::AuxElement >, SG::ReadDecorHandleKey< T >, SG::ReadDecorHandleKey< DMTest::JVec_v1 >, SG::ReadDecorHandleKey< DataVector >, SG::ReadDecorHandleKey< CONSTITUENTS >, SG::ReadDecorHandleKey< C >, SG::ReadDecorHandleKey< xAOD::TruthParticleContainer >, SG::ReadDecorHandleKey< DMTest::PLinks_v1 >, SG::ReadDecorHandleKey< xAOD::EventInfo_v1 >, SG::ReadDecorHandleKey< xAOD::FlowElement_v1 >, SG::ReadDecorHandleKey< CONTAINER >, SG::ReadDecorHandleKey< JetContainer >, SG::ReadDecorHandleKey< xAOD::PFO_v1 >, SG::ReadDecorHandleKey< MyDataObj >, SG::ReadDecorHandleKey< T_RoIContainer >, SG::ReadDecorHandleKey< DMTest::C_v1 >, SG::ReadDecorHandleKey< T_Cont >, SG::ReadDecorHandleKey< SG::AuxElement >, SG::ReadDecorHandleKey< OLD >, and SG::TypelessWriteHandleKey.

Definition at line 88 of file AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx.

89 {
90  m_sgKey = sgkey;
91  return StatusCode::SUCCESS;
92 }

◆ ATLAS_NOT_CONST_THREAD_SAFE()

template<class T >
CondCont<T>* getCC SG::CondHandleKey< T >::ATLAS_NOT_CONST_THREAD_SAFE ( ) const
inlineprotectedinherited

Definition at line 52 of file CondHandleKey.h.

52 { return m_cc; }

◆ clid()

CLID SG::VarHandleKey::clid ( ) const
inherited

Return the class ID for the referenced object.

Definition at line 177 of file StoreGate/src/VarHandleKey.cxx.

178 {
179  return Gaudi::DataHandle::fullKey().clid();
180 }

◆ dbKey()

template<class T >
const std::string& SG::CondHandleKey< T >::dbKey ( ) const
inlineinherited

Definition at line 31 of file CondHandleKey.h.

31 { return m_dbKey; }

◆ empty()

bool SG::VarHandleKey::empty ( ) const
inherited

Test if the key is blank.

Definition at line 150 of file AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx.

151 {
152  return m_sgKey.empty();
153 }

◆ getCS()

template<class T >
StoreGateSvc* SG::CondHandleKey< T >::getCS ( ) const
protectedinherited

◆ hashedKey()

SG::sgkey_t SG::VarHandleKey::hashedKey ( ) const
inherited

Return the hashed StoreGate key.

May be 0 if not yet initialized.

◆ initialize() [1/2]

template<class T >
StatusCode SG::CondHandleKey< T >::initialize ( AllowEmptyEnum  )
inherited

◆ initialize() [2/2]

template<class T >
StatusCode SG::CondHandleKey< T >::initialize ( bool  used = true)
inherited

◆ isEventStore()

bool SG::VarHandleKey::isEventStore ( ) const
inherited

Does this key reference the primary event store?

◆ isInit()

template<class T >
bool SG::CondHandleKey< T >::isInit ( ) const
inlineprotectedinherited

Definition at line 46 of file CondHandleKey.h.

46 { return m_isInit; }

◆ key()

const std::string & SG::VarHandleKey::key ( ) const
inherited

Return the StoreGate ID for the referenced object.

Definition at line 141 of file AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx.

142 {
143  return m_sgKey;
144 }

◆ owningHandle()

VarHandleBase* SG::VarHandleKey::owningHandle ( )
inherited

Return the VarHandle that owns this key, if any.

This should only be non-null for keys that are created automatically by a VarHandle when it is not created from a VarHandleKey. This should always be null for keys that are created explicitly.

◆ parseKey()

void SG::VarHandleKey::parseKey ( const std::string &  key,
const std::string &  storeName 
)
privateinherited

Handle assignment/construction from a string key.

Parameters
sgkeyThe StoreGate key for the referenced object.

The provided key may actually start with the name of the store, separated by a "+": "MyStore+Obj". If no "+" is present, the store named by storeName is used. A key name that starts with a slash is interpreted as a hierarchical key name, not an empty store name.

see implementation comments for further details

Parameters
sgkeyThe StoreGate key for the referenced object.

The provided key may actually start with the name of the store, separated by a "+": "MyStore+Obj". If no "+" is present the store named by storeName is used. A key name that starts with a slash is interpreted as a hierarchical key name, not an empty store name.

we also have to check that if the key contains the store name, it matches the store name that they Handle was constructed with

blank keys result in blank DataObjIDs

Definition at line 217 of file StoreGate/src/VarHandleKey.cxx.

219 {
220  m_hashedKey = 0;
221 
222  std::string sn;
223  // test if storeName has classname
224  std::string::size_type sp = storeName.find('/');
225  if (sp == std::string::npos) {
226  sn = storeName;
227  } else {
228  sn = storeName.substr(sp+1,storeName.length()-sp+1);
229  }
230 
231  if (key.empty()) {
232  this->updateHandle(sn);
233  Gaudi::DataHandle::updateKey("");
234  m_sgKey.clear();
235  return;
236  }
237 
238  // StoreName separator is "+"
239  sp = key.find(storeSeparator);
240  if(sp == std::string::npos) {
241  m_sgKey = key;
242  } else {
243  sn = key.substr(0,sp);
244  m_sgKey = key.substr(sp+1,key.length()-sp-1);
245  }
246 
247 
248  this->updateHandle(sn);
249 
250  StoreID::type st;
251  // would be nice if we could get the storeID from the storeHandle, but
252  // we can't be sure that the store has been created when the VHK is
253  // constructed.
254  //
255 
256  st = StoreID::findStoreID(sn);
257 
259  if (m_sgKey.find('/') != std::string::npos) {
260  throw SG::ExcBadHandleKey("key \"" + key
261  + "\": keys with \"/\" only allowed for "
263  + " - store is \""
264  + sn + "\"");
265  }
266  } else {
267  sp = m_sgKey.rfind('/');
268  if (sp != std::string::npos) {
269  if (sp == 0
270  && m_sgKey.size() == 1) {
271  // Replace '\' with blank key
272  m_sgKey.clear();
273  } else if ( sp == m_sgKey.length()-1) {
274  throw SG::ExcBadHandleKey("key \"" + key
275  + "\": must not end with a \"/\"");
276  }
277  }
278  }
279 
280  if (m_sgKey.empty()) {
281  Gaudi::DataHandle::updateKey("");
282  } else {
283  Gaudi::DataHandle::updateKey(sn + storeSeparator + m_sgKey);
284  }
285 
286 
287 }

◆ pythonRepr()

std::string SG::VarHandleKey::pythonRepr ( ) const
overrideprotectedvirtualinherited

Python representation of Handle.

Reimplemented in SG::WriteDecorHandleKey< T >, and SG::ReadDecorHandleKey< T >.

Definition at line 309 of file StoreGate/src/VarHandleKey.cxx.

310 {
311  const std::string& className = fullKey().className().empty() ?
312  Gaudi::DataHandle::default_type : fullKey().className();
313 
314  std::ostringstream ost;
315  ost << "DataHandle(";
317  ost << ",";
318  switch (mode()) {
320  Gaudi::Utils::toStream("W", ost); break;
321  default:
322  Gaudi::Utils::toStream("R", ost); break;
323  }
325  ost << ","; Gaudi::Utils::toStream(isCondition(), ost);
326  ost << ")";
327 
328  return ost.str();
329 }

◆ setDbKey()

template<class T >
void SG::CondHandleKey< T >::setDbKey ( const std::string &  dbKey)
inlineinherited

Definition at line 32 of file CondHandleKey.h.

32 { m_dbKey = dbKey; }

◆ setKey()

void SG::VarHandleKey::setKey ( DataObjID  key)
finaloverrideprivatevirtualinherited

Don't allow calling these.

Prevent this method from being called.

Definition at line 186 of file StoreGate/src/VarHandleKey.cxx.

187 {
188  throw SG::ExcForbiddenMethod ("VarHandleKey::setKey");
189 }

◆ setOwningHandle()

void SG::VarHandleKey::setOwningHandle ( VarHandleBase handle)
privateinherited

◆ start()

template<class T >
virtual StatusCode SG::CondHandleKey< T >::start ( )
overridevirtualinherited

Called by the owning algorithm during the START transition.

AthAlgorithm and friends will call this during START. This allows for extra initialization that we can't do during initialize(), such as retrieving a conditions container from the store.

Reimplemented from SG::VarHandleKey.

◆ storeHandle()

const ServiceHandle<IProxyDict>& SG::VarHandleKey::storeHandle ( ) const
inherited

Return handle to the referenced store.

◆ updateHandle()

void SG::VarHandleKey::updateHandle ( const std::string &  name)
privateinherited

Update the name of the store to which we're referring.

Parameters
nameThe new store name.

Definition at line 294 of file StoreGate/src/VarHandleKey.cxx.

295 {
296  // Don't invalidate a stored pointer if the handle is already pointing
297  // at the desired service.
298  if (m_storeHandle.name() != name) {
299  m_hashedKey = 0;
300  m_storeHandle = ServiceHandle<IProxyDict>(name, "VarHandleKey");
303  }
304 }

◆ updateKey()

void SG::VarHandleKey::updateKey ( std::string  key)
finaloverrideprivatevirtualinherited

Prevent this method from being called.

Definition at line 195 of file StoreGate/src/VarHandleKey.cxx.

196 {
197  throw SG::ExcForbiddenMethod ("VarHandleKey::updateKey");
198 }

Friends And Related Function Documentation

◆ WriteCondHandle< T >

template<class T >
friend class WriteCondHandle< T >
friend

Definition at line 1 of file WriteCondHandleKey.h.

Member Data Documentation

◆ m_cc

template<class T >
CondCont<T>* SG::CondHandleKey< T >::m_cc {0}
privateinherited

Definition at line 59 of file CondHandleKey.h.

◆ m_cs

template<class T >
ServiceHandle<StoreGateSvc> SG::CondHandleKey< T >::m_cs
privateinherited

Definition at line 58 of file CondHandleKey.h.

◆ m_dbKey

template<class T >
std::string SG::CondHandleKey< T >::m_dbKey {""}
privateinherited

Definition at line 61 of file CondHandleKey.h.

◆ m_hashedKey

SG::sgkey_t SG::VarHandleKey::m_hashedKey = 0
privateinherited

The hashed StoreGate key. May be 0 if not yet initialized.

Definition at line 250 of file StoreGate/StoreGate/VarHandleKey.h.

◆ m_isEventStore

bool SG::VarHandleKey::m_isEventStore = false
privateinherited

Cache test for whether we're referencing the event store.

Definition at line 253 of file StoreGate/StoreGate/VarHandleKey.h.

◆ m_isInit

template<class T >
bool SG::CondHandleKey< T >::m_isInit {false}
privateinherited

Definition at line 63 of file CondHandleKey.h.

◆ m_owningHandle

VarHandleBase* SG::VarHandleKey::m_owningHandle = nullptr
privateinherited

Handle that owns this key, or nullptr if it is not owned.

Definition at line 256 of file StoreGate/StoreGate/VarHandleKey.h.

◆ m_sgKey

std::string SG::VarHandleKey::m_sgKey
privateinherited

StoreGate key, that doesn't include the storename.

Definition at line 247 of file StoreGate/StoreGate/VarHandleKey.h.

◆ m_storeHandle

ServiceHandle<IProxyDict> SG::VarHandleKey::m_storeHandle
privateinherited

Handle to the referenced store.

Definition at line 244 of file StoreGate/StoreGate/VarHandleKey.h.


The documentation for this class was generated from the following file:
common.sgkey
def sgkey(tool)
Definition: common.py:1028
python.trigbs_prescaleL1.ost
ost
Definition: trigbs_prescaleL1.py:104
SG::CondHandleKey::m_isInit
bool m_isInit
Definition: CondHandleKey.h:63
SG::VarHandleKey::m_isEventStore
bool m_isEventStore
Cache test for whether we're referencing the event store.
Definition: StoreGate/StoreGate/VarHandleKey.h:253
Gaudi::Utils::toStream
std::ostream & toStream(const SG::VarHandleKeyArray &v, std::ostream &o)
Gaudi function used to convert a property to a string.
Definition: StoreGate/src/VarHandleKeyArray.cxx:47
SG::VarHandleKey::m_storeHandle
ServiceHandle< IProxyDict > m_storeHandle
Handle to the referenced store.
Definition: StoreGate/StoreGate/VarHandleKey.h:244
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:294
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:250
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
storeSeparator
constexpr char const storeSeparator
Definition: StoreGate/src/VarHandleKey.cxx:27
SG::CondHandleKey::m_cc
CondCont< T > * m_cc
Definition: CondHandleKey.h:59
JetTagCalibConfig.className
string className
Definition: JetTagCalibConfig.py:36
StoreID::CONDITION_STORE
@ CONDITION_STORE
Definition: StoreID.h:28
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
StoreID::PILEUP_STORE
@ PILEUP_STORE
Definition: StoreID.h:31
SG::ExcBadHandleKey
Exception — Bad key format for VarHandleKey.
Definition: Control/StoreGate/StoreGate/exceptions.h:62
Preparation.mode
mode
Definition: Preparation.py:94
StoreID::METADATA_STORE
@ METADATA_STORE
Definition: StoreID.h:29
SG::ExcForbiddenMethod
Exception — Forbidden method called.
Definition: Control/StoreGate/StoreGate/exceptions.h:77
SG::VarHandleKey::m_sgKey
std::string m_sgKey
StoreGate key, that doesn't include the storename.
Definition: StoreGate/StoreGate/VarHandleKey.h:247
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
SG::CondHandleKey::m_dbKey
std::string m_dbKey
Definition: CondHandleKey.h:61
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
StoreID::type
type
Definition: StoreID.h:24
StoreID::findStoreID
static StoreID::type findStoreID(const std::string &storeName)
Definition: StoreID.cxx:21
LHEF::Writer
Pythia8::Writer Writer
Definition: Prophecy4fMerger.cxx:12
StoreID::EVENT_STORE
@ EVENT_STORE
Definition: StoreID.h:26
SG::CondHandleKey::dbKey
const std::string & dbKey() const
Definition: CondHandleKey.h:31
StoreID::storeName
static const std::string & storeName(const StoreID::type &s)
Definition: StoreID.cxx:77
ServiceHandle< IProxyDict >