ATLAS Offline Software
Loading...
Searching...
No Matches
TypelessWriteHandleKey.cxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
3 */
10
11
15#include "GaudiKernel/IClassIDSvc.h"
16#include "GaudiKernel/ServiceHandle.h"
17
18
19namespace SG {
20
21
33 const std::string& key /*= ""*/,
34 const std::string& storeName /*= "StoreGateSvc"*/)
36 Gaudi::DataHandle::Writer,
37 storeName)
38{
39}
40
41
50TypelessWriteHandleKey::operator= (const std::string& sgkey)
51{
52 if (assign (sgkey).isFailure()) {
53 throw SG::ExcBadHandleKey (sgkey);
54 }
55 return *this;
56}
57
58
68StatusCode TypelessWriteHandleKey::assign (const std::string& key_in)
69{
70 std::string key = key_in;
71
72 // Handle a possible class name.
73 std::string::size_type islash = key.find ('/');
74 if (islash != std::string::npos) {
75 std::string::size_type istart = key.find ('+');
76 if (istart == std::string::npos) {
77 istart = 0;
78 }
79 else {
80 ++istart;
81 }
82
83 // Excise the class name part from the key.
84 std::string clname = key.substr (istart, islash-istart);
85 key.erase (istart, islash+1-istart);
86
87 // Look up the class name with the CLID service.
88 ServiceHandle<IClassIDSvc> clidsvc ("ClassIDSvc", "TypelessWriteHandleKey");
89 CHECK( clidsvc.retrieve() );
90 CLID clid = CLID_NULL;
91 CHECK( clidsvc->getIDOfTypeName (clname, clid) );
92
93 // Modify the CLID of this key.
94 Gaudi::DataHandle::setKey (DataObjID (clid, objKey()));
95 }
96
97 // Change the key/store. Class name has been removed from the string
98 // by this point.
100}
101
102
103} // namespace SG
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Exceptions that can be thrown from StoreGate.
uint32_t CLID
The Class ID type.
Property holding a write key for which the type can be configured.
an iterator over instances of a given type in StoreGateSvc.
Definition DataHandle.h:43
Exception — Bad key format for VarHandleKey.
Property holding a write key for which the type can be configured.
TypelessWriteHandleKey & operator=(const std::string &sgkey)
Change the key of the object to which we're referring.
TypelessWriteHandleKey(CLID clid=CLID_NULL, const std::string &key="", const std::string &storeName=StoreID::storeName(StoreID::EVENT_STORE))
Constructor.
virtual StatusCode assign(const std::string &key) override
Change the key of the object to which we're referring.
CLID clid() const
Return the class ID for the referenced object.
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.
VarHandleKey(CLID clid, const std::string &sgkey, Gaudi::DataHandle::Mode a, const std::string &storeName=StoreID::storeName(StoreID::EVENT_STORE), bool isCond=false)
Constructor.
=============================================================================
Forward declaration.