ATLAS Offline Software
AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
15 // #include "AsgDataHandles/exceptions.h"
16 
17 #include <iostream>
18 
19 namespace SG {
20 
21 
38 VarHandleKey::VarHandleKey (const std::string& sgkey)
39  : m_sgKey (sgkey)
40 {
41 }
42 // VarHandleKey::VarHandleKey (CLID clid,
43 // const std::string& sgkey,
44 // Gaudi::DataHandle::Mode a,
45 // const std::string& storeName /*= "StoreGateSvc"*/,
46 // bool isCond /*= false*/)
47 // : Gaudi::DataHandle (DataObjID (clid, sgkey), isCond, a),
48 // m_storeHandle (storeName, "VarHandleKey")
49 // {
50 // parseKey (sgkey, storeName);
51 // m_isEventStore = (m_storeHandle.name() == StoreID::storeName(StoreID::EVENT_STORE) ||
52 // m_storeHandle.name() == StoreID::storeName(StoreID::PILEUP_STORE));
53 // }
54 
55 
69 {
70  if (assign (sgkey).isFailure ()) {
71  throw std::runtime_error (std::string("Could not assign VarHandleKey with key ") + sgkey);
72  }
73  return *this;
74 }
75 
76 
89 {
90  m_sgKey = sgkey;
91  return StatusCode::SUCCESS;
92 }
93 
94 
104 {
105  if (!used) {
106  m_sgKey = "";
107  return StatusCode::SUCCESS;
108  }
109 
110  if (key() == "") {
111  // REPORT_ERROR (StatusCode::FAILURE)
112  // << "Cannot initialize a Read/Write/Update handle with a null key.";
113  return StatusCode::FAILURE;
114  }
115 
116  return StatusCode::SUCCESS;
117 }
118 
119 
130 {
131  if (key().empty()) {
132  return StatusCode::SUCCESS;
133  }
134  return initialize (true);
135 }
136 
137 
141 const std::string& VarHandleKey::key() const
142 {
143  return m_sgKey;
144 }
145 
146 
151 {
152  return m_sgKey.empty();
153 }
154 
155 } // namespace SG
156 
157 namespace std {
158  ostream& operator<<(ostream& s, const SG::VarHandleKey& m) {
159  // s << "'" << m.objKey() << "'";
160  s << "'" << m.key() << "'";
161  return s;
162  }
163 }
used
common.sgkey
def sgkey(tool)
Definition: common.py:1028
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
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:29
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::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
SG::VarHandleKey::m_sgKey
std::string m_sgKey
StoreGate key, that doesn't include the storename.
Definition: StoreGate/StoreGate/VarHandleKey.h:247
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
operator<<
std::ostream & operator<<(std::ostream &lhs, const TestGaudiProperty &rhs)
Definition: TestGaudiProperty.cxx:69
SG::VarHandleKey
A property holding a SG store/key/clid from which a VarHandle is made.
Definition: StoreGate/StoreGate/VarHandleKey.h:62
VarHandleKey.h
A property holding a SG store/key/clid from which a VarHandle is made.