ATLAS Offline Software
Loading...
Searching...
No Matches
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$
12
13
15// #include "AsgDataHandles/exceptions.h"
16
17#include <iostream>
18
19namespace SG {
20
21
38VarHandleKey::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
68VarHandleKey& VarHandleKey::operator= (const std::string& sgkey)
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
88StatusCode VarHandleKey::assign (const std::string& sgkey)
89{
90 m_sgKey = sgkey;
91 return StatusCode::SUCCESS;
92}
93
94
103StatusCode VarHandleKey::initialize (bool used /*= true*/)
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
131 if (key().empty()) {
132 return StatusCode::SUCCESS;
133 }
134 return initialize (true);
135}
136
137
141const std::string& VarHandleKey::key() const
143 return m_sgKey;
144}
145
146
151{
152 return m_sgKey.empty();
153}
155} // namespace SG
156
157namespace std {
158 ostream& operator<<(ostream& s, const SG::VarHandleKey& m) {
159 // s << "'" << m.objKey() << "'";
160 s << "'" << m.key() << "'";
161 return s;
162 }
163}
A property holding a SG store/key/clid from which a VarHandle is made.
A property holding a SG store/key/clid from which a VarHandle is made.
VarHandleKey & operator=(const std::string &sgkey)
Change the key of the object to which we're referring.
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.
std::string m_sgKey
StoreGate key, that doesn't include the storename.
VarHandleKey(CLID clid, const std::string &sgkey, Gaudi::DataHandle::Mode a, const std::string &storeName=StoreID::storeName(StoreID::EVENT_STORE), bool isCond=false)
Constructor.
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
bool empty() const
Test if the key is blank.
holding In fact this class is here in order to allow STL container for all features This class is sho...
Forward declaration.
STL namespace.
ostream & operator<<(ostream &s, const SG::VarHandleKey &m)
void initialize()